[
https://issues.apache.org/jira/browse/HADOOP-20083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18147990#comment-18147990
]
ASF GitHub Bot commented on HADOOP-20083:
-----------------------------------------
smengcl commented on PR #8983:
URL: https://github.com/apache/hadoop/pull/8983#issuecomment-7032853837
Thanks @Hexiaoqiao for the review.
> MachineList matches a hostname entry against only one of its addresses
> ----------------------------------------------------------------------
>
> Key: HADOOP-20083
> URL: https://issues.apache.org/jira/browse/HADOOP-20083
> Project: Hadoop Common
> Issue Type: Sub-task
> Reporter: Siyao Meng
> Assignee: Siyao Meng
> Priority: Major
> Labels: pull-request-available
> Fix For: 3.6.0
>
>
> {{MachineList}} resolves each hostname entry once, in the constructor, with
> {{InetAddress.getByName}}, and keeps only that one address
> ([MachineList.java:169|https://github.com/apache/hadoop/blob/904cde0c848781e67dde0b0aece8acad2e320204/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/MachineList.java#L169]).
> {{includes}} then looks the caller's address up in that set
> ([MachineList.java:224|https://github.com/apache/hadoop/blob/904cde0c848781e67dde0b0aece8acad2e320204/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/MachineList.java#L224]).
> {{getByName}} returns the first address of the host. With the JDK default
> ({{java.net.preferIPv6Addresses=false}}) that is the IPv4 address of a
> dual-stack host, so the host is not matched when it connects over IPv6. With
> {{preferIPv6Addresses=true}} it is the reverse. A hostname with several IPv4
> addresses has the same problem today.
> This affects every user of {{MachineList}}: {{hadoop.proxyuser.<user>.hosts}}
> ({{DefaultImpersonationProvider}}), the service level authorization host
> lists ({{ServiceAuthorizationManager}}) and {{FileBasedIPList}}. For example,
> on a dual-stack cluster a proxy user whose host is listed by name is rejected
> when it reaches the NameNode over IPv6.
> Reproduced on trunk ({{904cde0c848}}) with {{localhost}}, which resolves to
> both 127.0.0.1 and ::1:
> {noformat}
> InetAddress.getAllByName("localhost") = [localhost/127.0.0.1,
> localhost/0:0:0:0:0:0:0:1]
> new MachineList(["localhost"]).includes(127.0.0.1) = true
> new MachineList(["localhost"]).includes(::1) = false
> {noformat}
> With {{-Djava.net.preferIPv6Addresses=true}} the two results swap.
> *Proposed fix:*
> * Resolve hostname entries with {{getAllByName}} and keep every address.
> * Add {{getAllByName}} to {{InetAddressFactory}} so tests can simulate a host
> with several addresses.
> * Add tests for a dual-stack hostname matched from both address families.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]