Repository navigation
HADOOP-19960. Support IPv6 reverse DNS names in DNS.reverseDns - #8807
Conversation
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>
There was a problem hiding this comment.
🟢 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.
This comment was marked as outdated.
This comment was marked as outdated.
joseluisll
left a comment
There was a problem hiding this comment.
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>
|
🎊 +1 overall
This message was automatically generated. |
slfan1989
left a comment
There was a problem hiding this comment.
@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
|
Thanks @joseluisll @slfan1989 for the reviews. |
Generated-by: Claude Code (Opus 5.5)
Description of PR
DNS.reverseDnsbuilds onlyin-addr.arpanames. For an IPv6 address it throwsArrayIndexOutOfBoundsExceptionbefore any lookup is made.DNS.getHostscatches onlyNamingException, soDNS.getDefaultHostfails for any named interface that has an IPv6 address. This affectshadoop.security.dns.interface,dfs.datanode.dns.interfaceandDNSDomainNameResolver.getHostnameByIPoncejava.net.preferIPv4Stackis not set to true.This PR builds the
ip6.arpaname defined by RFC 3596 for IPv6 addresses: the 32 nibbles of the address in reverse order, followed byip6.arpa.Inet4Address, so they still usein-addr.arpa.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 callsDNS.reverseDnswith an IPv6 address and an invalid DNS server and expects aNamingException. On trunk it fails withArrayIndexOutOfBoundsException.mvn test -Dtest=TestDNSinhadoop-commonwith 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)threwArrayIndexOutOfBoundsExceptionbefore the change and returnslocalhostafter it.For code changes:
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.
LICENSE,LICENSE-binary,NOTICE-binaryfiles?AI Tooling
Contains content generated by Claude Code.
where is the name of the AI tool used.
https://www.apache.org/legal/generative-tooling.html
🤖 Generated with Claude Code