8200719: Cannot connect to IPv6 host when exists any active network interface without IPv6 address
authorclanger
Mon, 16 Apr 2018 11:11:52 +0200
changeset 49704 bc1c7e41e285
parent 49703 d2bea17edd96
child 49705 68ac1caf3d7e
child 56432 e75e22b59664
child 56434 69b4183fd7b8
8200719: Cannot connect to IPv6 host when exists any active network interface without IPv6 address Reviewed-by: clanger, chegar Contributed-by: joelpelaez@gmail.com
src/java.base/unix/native/libnet/net_util_md.c
--- a/src/java.base/unix/native/libnet/net_util_md.c	Mon Apr 16 09:36:01 2018 +0100
+++ b/src/java.base/unix/native/libnet/net_util_md.c	Mon Apr 16 11:11:52 2018 +0200
@@ -89,7 +89,9 @@
     }
     int defaultIndex;
     struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)him;
-    if (sin6->sin6_family == AF_INET6 && (sin6->sin6_scope_id == 0)) {
+    if (sin6->sin6_family == AF_INET6 && (sin6->sin6_scope_id == 0) &&
+        (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
+         IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))) {
         defaultIndex = (*env)->GetStaticIntField(env, ni_class,
                                                  ni_defaultIndexID);
         sin6->sin6_scope_id = defaultIndex;