changeset 49704:bc1c7e41e285

8200719: Cannot connect to IPv6 host when exists any active network interface without IPv6 address Reviewed-by: clanger, chegar Contributed-by: joelpelaez@gmail.com
author clanger
date Mon, 16 Apr 2018 11:11:52 +0200
parents d2bea17edd96
children 68ac1caf3d7e
files src/java.base/unix/native/libnet/net_util_md.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;