Repository navigation
HADOOP-19962. Support IPv6 CIDR rules in MachineList - #8812
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
IPv4-mapped IPv6 CIDRs are not rejected as intended, causing the corresponding test to fail.
1 open finding
What changed in this PR
Adds IPv6 CIDR parsing and family-aware matching to MachineList, with expanded IPv4/IPv6 test coverage.
Changes:
- Implements IPv6 prefix matching and validation.
- Prevents cross-family CIDR lookup errors.
- Adds boundary, compatibility, and invalid-input tests.
| File | Summary |
|---|---|
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/MachineList.java |
Adds IPv6 CIDR parsing and matching. |
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestMachineList.java |
Adds IPv4/IPv6 CIDR and regression coverage. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
slfan1989
left a comment
There was a problem hiding this comment.
The implementation looks good to me. +1
I independently ran the four relevant test classes: all 57 tests passed, including the IPv4-mapped CIDR rejection case.
One suggestion: could you add a service-authorization test covering IPv6 clients with IPv4-only and matching IPv6 blocked CIDRs? This would explicitly cover the behavior change documented in the PR.
Let's also wait for the remaining CI checks before merging.
This comment was marked as outdated.
This comment was marked as outdated.
…cked host lists Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thanks @slfan1989 for taking a look. Added |
…x length once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment was marked as outdated.
This comment was marked as outdated.
|
🎊 +1 overall
This message was automatically generated. |
|
Thanks @slfan1989 @joseluisll for the reviews. |

Generated-by: Claude Code (Opus 5.5)
Description of PR
MachineListparses CIDR entries with commons-netSubnetUtils, which supports IPv4 only. Two things fail as a result:2001:db8::/32makes theMachineListconstructor throwIllegalArgumentException. Ahadoop.proxyuser.*.hostsvalue or a service level authorization host list with an IPv6 range cannot be loaded.MachineList.includes(InetAddress)throwIllegalArgumentExceptioninstead of returning false. This affects a dual stack cluster with an unchanged IPv4 configuration.This PR adds prefix matching for IPv6 CIDR entries and makes the range lookup aware of the address family.
SubnetUtils, so their results are unchanged.::ffff:a.b.c.d): the JDK returns a mapped client address asInet4Address, so it matches IPv4 entries only. A mapped CIDR entry is rejected at construction because it could never match. It should be written as an IPv4 CIDR.IllegalArgumentException, as an invalid IPv4 CIDR entry is today. The prefix length must be a number from 0 to 128.fe80::%eth0/64) is rejected. The scope id of a client address is ignored, as it already is for exact IPv6 entries.Behavior change to note: on trunk, an IPv6 client checked against a list with an IPv4 CIDR entry failed with an exception, which dropped the RPC connection. Such a client is now evaluated normally. With a blocked host list (
*.hosts.blocked) that has only IPv4 ranges, IPv6 clients are no longer rejected as a side effect. Add IPv6 ranges to the blocked list if they should be blocked.Sub-task of HADOOP-11890.
How was this patch tested?
Added 10 tests to
TestMachineList:/33and/61prefixes, which do not end on a byte boundary./128and::/0./32,/31,/0) and exact IPv6 entries, to show that existing behavior is kept.On trunk, 8 of the 10 new tests fail with
IllegalArgumentException. The other 2 cover behavior that already works (exact IPv6 entries, rejection of invalid entries).Added
TestServiceAuthorization#testBlockedMachineListWithIPv6Client, which covers the behavior change above throughServiceAuthorizationManager.authorize: an IPv6 client is authorized when the blocked host list has only IPv4 ranges, and is rejected withAuthorizationExceptiononce a matching IPv6 CIDR is added to the blocked host list.mvn test -Dtest='TestMachineList,TestProxyUsers,TestServiceAuthorization,TestFileBasedIPList'inhadoop-commonwith JDK 17: 58 tests run, 0 failures, 0 errors, 0 skipped.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