Siyao Meng created HADOOP-20024:
-----------------------------------

             Summary: DataTransferSaslUtil.getPeerAddress fails on IPv6 peer 
addresses
                 Key: HADOOP-20024
                 URL: https://issues.apache.org/jira/browse/HADOOP-20024
             Project: Hadoop Common
          Issue Type: Sub-task
            Reporter: Siyao Meng
            Assignee: Siyao Meng


{{DataTransferSaslUtil.getPeerAddress}} takes the host from 
{{Peer.getRemoteAddressString()}} with {{split(":")[0]}}:

{code:java}
String remoteAddr = peer.getRemoteAddressString().split(":")[0];
{code}

[DataTransferSaslUtil.java:167|https://github.com/apache/hadoop/blob/9ede2e95c6fb577d7ae8664833d5e151cbfc47c9/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/DataTransferSaslUtil.java#L167]

For an IPv6 peer the remote address looks like {{/[fd00:dead:beef::21]:9866}} 
or {{/0:0:0:0:0:0:0:1:9866}}, so the split gives {{/[fd00}} or {{/0}}. Guava 
{{InetAddresses.forString}} then throws {{IllegalArgumentException: ... is not 
an IP string literal}}.

{{getPeerAddress}} is called by {{SaslDataTransferClient}} and 
{{SaslDataTransferServer}} for the trusted-channel check and SASL negotiation. 
On an IPv6 cluster with data transfer protection enabled, client reads from a 
DataNode ({{hdfs dfs -cat}}, {{-get}}) fail. The write path does not call it, 
so a successful put can hide the problem.

*Proposed fix:* strip the port in a way that respects {{[ipv6]:port}}, remove 
the brackets, then pass the literal to {{InetAddresses.forString}}. IPv4 and 
host name forms are unchanged. Add unit tests for IPv4, bracketed IPv6 and 
unbracketed {{/ipv6:port}} forms.

Related to HADOOP-17543, which covers the DatanodeID address strings; this is a 
separate call site.

POC: 
https://github.com/smengcl/hadoop/commit/243a614c122669a567b441341192665d23c11085



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to