8200719: Cannot connect to IPv6 host when exists any active network interface without IPv6 address
Reviewed-by: clanger, chegar
Contributed-by: joelpelaez@gmail.com
--- 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;