smengcl commented on code in PR #11541:
URL: https://github.com/apache/ozone/pull/11541#discussion_r4276482368


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HddsServerUtil.java:
##########
@@ -199,6 +200,21 @@ public static List<InetAddress> 
getValidInetsForCurrentHost()
     return hostIps;
   }
 
+  /**
+   * A network interface returns every IPv6 address with the interface as 
scope, which
+   * {@link #isScopedOrMaskingIPv6Address(InetAddress)} rejects. Only a 
link-local address needs the scope, so it is
+   * dropped from any other address.
+   *
+   * @param addr the InetAddress as returned by a network interface
+   * @return the address without scope, or the same address if it is 
link-local or not an IPv6 address
+   */
+  public static InetAddress dropScopeUnlessLinkLocal(InetAddress addr) throws 
UnknownHostException {
+    if (addr instanceof Inet6Address && !addr.isLinkLocalAddress()) {
+      return InetAddress.getByAddress(addr.getAddress());
+    }

Review Comment:
   No change: `java.net.Inet6Address` is already imported in this file (line 
67), and the module builds.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HddsServerUtil.java:
##########
@@ -68,6 +68,7 @@
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.NetworkInterface;
+import java.net.UnknownHostException;

Review Comment:
   No change: `InetAddress.getByAddress(byte[])` is declared `throws 
UnknownHostException` (for an illegal address length), so the import and the 
`throws` clause are needed to compile.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HddsServerUtil.java:
##########
@@ -199,6 +200,21 @@ public static List<InetAddress> 
getValidInetsForCurrentHost()
     return hostIps;
   }
 
+  /**
+   * A network interface returns every IPv6 address with the interface as 
scope, which
+   * {@link #isScopedOrMaskingIPv6Address(InetAddress)} rejects. Only a 
link-local address needs the scope, so it is
+   * dropped from any other address.
+   *
+   * @param addr the InetAddress as returned by a network interface
+   * @return the address without scope, or the same address if it is 
link-local or not an IPv6 address
+   */
+  public static InetAddress dropScopeUnlessLinkLocal(InetAddress addr) throws 
UnknownHostException {
+    if (addr instanceof Inet6Address && !addr.isLinkLocalAddress()) {
+      return InetAddress.getByAddress(addr.getAddress());
+    }
+    return addr;
+  }

Review Comment:
   No change: `InetAddress.getByAddress(byte[])` is declared `throws 
UnknownHostException`, so removing the `throws` clause would not compile.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to