Skip to content

HADOOP-19960. Support IPv6 reverse DNS names in DNS.reverseDns - #8807

Merged
smengcl merged 2 commits into
apache:trunkfrom
smengcl:HADOOP-19960
Oct 11, 2026
Merged

smengcl merged 2 commits into
apache:trunkfrom
smengcl:HADOOP-19960

Conversation

@smengcl

@smengcl smengcl commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Generated-by: Claude Code (Opus 5.5)

Description of PR

DNS.reverseDns builds only in-addr.arpa names. For an IPv6 address it throws ArrayIndexOutOfBoundsException before any lookup is made. DNS.getHosts catches only NamingException, so DNS.getDefaultHost fails for any named interface that has an IPv6 address. This affects hadoop.security.dns.interface, dfs.datanode.dns.interface and DNSDomainNameResolver.getHostnameByIP once java.net.preferIPv4Stack is not set to true.

This PR builds the ip6.arpa name defined by RFC 3596 for IPv6 addresses: the 32 nibbles of the address in reverse order, followed by ip6.arpa.

  • IPv4 names are unchanged.
  • IPv4 mapped addresses are unchanged. The JDK returns them as Inet4Address, so they still use in-addr.arpa.
  • The scope id of a scoped address is not part of the name.

Sub-task of HADOOP-11890.

How was this patch tested?

Added TestDNS#testReverseDnsName, which checks the generated names without a DNS server: an IPv4 address, the example from RFC 3596 section 2.5, 2001:db8::1, ::1, an IPv4 mapped address and a scoped link local address.

Added TestDNS#testReverseDnsIPv6WithInvalidServer, which calls DNS.reverseDns with an IPv6 address and an invalid DNS server and expects a NamingException. On trunk it fails with ArrayIndexOutOfBoundsException.

mvn test -Dtest=TestDNS in hadoop-common with JDK 17: 14 tests run, 0 failures, 0 errors, 0 skipped.

Also verified by hand on a host with IPv6 enabled: DNS.getDefaultHost("lo0", null, true) threw ArrayIndexOutOfBoundsException before the change and returns localhost after it.

For code changes:

  • Does the title of this PR start with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
  • Object storage: Have the integration tests been executed and the endpoint
    declared according to the connector-specific documentation? Note: Automated CI
    testing doesn't cover all cases so manual testing with cloud storage is still
    required.
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE, LICENSE-binary, NOTICE-binary files?

AI Tooling

Contains content generated by Claude Code.

🤖 Generated with Claude Code

DNS.reverseDns built only in-addr.arpa names, so an IPv6 address threw ArrayIndexOutOfBoundsException. DNS.getHosts catches only NamingException, so DNS.getDefaultHost failed for any named interface that has an IPv6 address.

Build the ip6.arpa name (RFC 3596) for IPv6 addresses. IPv4 names are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is correct, focused, and adequately tested without altering existing IPv4 behavior.

0 open findings

What changed in this PR

Adds RFC 3596-compliant IPv6 reverse DNS names while preserving IPv4 behavior.

Changes:

  • Generates reversed IPv6 nibble names under ip6.arpa.
  • Adds coverage for IPv4, IPv6, mapped, loopback, and scoped addresses.
File Description
DNS.java Adds IPv6 reverse-name generation.
TestDNS.java Tests reverse-name generation cases.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@hadoop-yetus

This comment was marked as outdated.

@joseluisll joseluisll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks correct to me. I checked getReverseDnsName against the RFC 3596 example, against bytes with the high bit set (ffff:8000::fe80, the & 0xf handles the sign extension), against IPv4-mapped addresses (still in-addr.arpa) and against scoped link-local addresses (the scope id is dropped). TestDNS passes locally on this branch with JDK 21.

I have one optional suggestion inline: a regression test through reverseDns itself.

… method

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 56s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 50m 5s trunk passed
+1 💚 compile 17m 58s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 compile 18m 7s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 checkstyle 1m 32s trunk passed
+1 💚 mvnsite 2m 0s trunk passed
+1 💚 javadoc 1m 27s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 1m 26s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 3m 20s trunk passed
+1 💚 shadedclient 36m 25s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 16s the patch passed
+1 💚 compile 16m 50s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javac 16m 50s the patch passed
+1 💚 compile 18m 24s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 javac 18m 24s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 27s hadoop-common-project/hadoop-common: The patch generated 0 new + 25 unchanged - 1 fixed = 25 total (was 26)
+1 💚 mvnsite 2m 1s the patch passed
+1 💚 javadoc 1m 24s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 1m 25s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 3m 21s the patch passed
+1 💚 shadedclient 36m 47s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 23m 58s hadoop-common in the patch passed.
+1 💚 asflicense 1m 11s The patch does not generate ASF License warnings.
242m 56s
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8807/2/artifact/out/Dockerfile
GITHUB PR #8807
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux ad1b94123104 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 81d3c5e
Default Java Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8807/2/testReport/
Max. process+thread count 1296 (vs. ulimit of 10000)
modules C: hadoop-common-project/hadoop-common U: hadoop-common-project/hadoop-common
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8807/2/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@slfan1989 slfan1989 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smengcl Thanks for the contribution! LGTM.

The IPv6 reverse DNS name generation follows RFC 3596 and preserves IPv4 behavior. I verified that the new regression test passes with the fix and fails with the original implementation.

The latest Yetus and GitHub Actions checks are green.

Ready to merge.

cc: @jojochuang

@smengcl

smengcl commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @joseluisll @slfan1989 for the reviews.

@smengcl
smengcl merged commit 3aeb542 into apache:trunk Oct 11, 2026
6 checks passed
@smengcl
smengcl deleted the HADOOP-19960 branch October 11, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants