JDK-8200719: Cannot connect to IPv6 host when exists any active network interface without IPv6 address

Langer, Christoph christoph.langer at sap.com
Wed Apr 11 09:42:21 UTC 2018


Hi Joel,

your fix sounds reasonable. In fact, I'm not even sure if the sin6_scope_id should be set for multicast. Maybe it should be done only for link local addresses.

Additionally, I guess the selection of the default interface (for IPv6) should be improved because I still can imagine a scenario where the first interface only has IPv4 but you want to do an IPv6 link local connect where you need a scope.

Do you have signed an OCA as per [1], section "0. Become a Contributor"? Then I can help you with sponsoring this...

Best regards
Christoph

[1] http://openjdk.java.net/contribute/

> -----Original Message-----
> From: net-dev [mailto:net-dev-bounces at openjdk.java.net] On Behalf Of
> Joel Peláez Jorge
> Sent: Dienstag, 10. April 2018 00:37
> To: net-dev at openjdk.java.net
> Subject: JDK-8200719: Cannot connect to IPv6 host when exists any active
> network interface without IPv6 address
> 
> Hi,
> 
> I am new in the OpenJDK Community and I contribute with a fix for the bug
> 8200719 related to networking in macOS system.
> 
> I wrote a minimal patch that only set the scope id when the address is link-
> local or multicast. This change avoid send IPv6 packets on a wrong interface.
> 
> Bug: https://bugs.openjdk.java.net/browse/JDK-8200719
> 
> Patch:
> 
> diff -r f088ec60bed5 src/java.base/unix/native/libnet/net_util_md.c
> --- a/src/java.base/unix/native/libnet/net_util_md.c Mon Apr 09 10:39:29
> 2018 -0700
> +++ b/src/java.base/unix/native/libnet/net_util_md.c Mon Apr 09 16:50:18
> 2018 -0500
> @@ -89,7 +89,8 @@
>       }
>       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;
> 
> 
> Thanks,
> Joel


More information about the net-dev mailing list