[ipv6] RFR: 8223532: Don't try creating IPv4 sockets in NetworkInterface.c if IPv4 is not supported

Arthur Eubanks aeubanks at google.com
Fri May 10 16:37:50 UTC 2019


Sounds good.
New webrev: http://cr.openjdk.java.net/~aeubanks/8223532/webrev.03/

This is almost exactly the changes we made internally to this file.

*From: *Chris Hegarty <chris.hegarty at oracle.com>
*Date: *Fri, May 10, 2019 at 3:56 AM
*To: *Arthur Eubanks
*Cc: *OpenJDK Network Dev list

Arthur,
>
> On 09/05/2019 21:05, Arthur Eubanks wrote:
> >
> > ...
> > New webrev:
> > http://cr.openjdk.java.net/~aeubanks/8223532/webrev.02/index.html
> > This also contains some changes from Mark's suggestions. That thread
> > appears to have been separated from this thread in my inbox for some
> reason.
>
> Curve ball! Sorry.
>
> There is much history in this native code, and how ipv6_available
> evolved ( it is far from perfect! ). The use of ipv4_available ( as
> Mark mentions ) is not quite a good fit here (SOCK_STREAM Vs.
> SOCK_DGRAM).
>
> After further thought, I have now convinced myself that, from the
> perspective of the JDK's usage ( at least in NetworkInterface ), that
> it would be better to effectively treat EPROTONOSUPPORT and EAFNOSUPPORT
> the same, as "the specified protocol, domain, type, address family, is
> not supported". This should not be controversial given the constant
> values that are passed to socket(2).
>
> Given this, then the changes can be minimal, direct, and localized.
> Effectively:
>
>    -      if (errno != EPROTONOSUPPORT) {
>    ---
>    +      if (!(errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT)) {
>
> And in enumInterfaces, something like:
>
>      /* Enumerate IPv4 addresses */
>      sock = openSocket(env, AF_INET);
>      if (sock < 0 && (*env)->ExceptionOccurred(env)) {
>          return NULL;
>      }
>
>      if (sock >= 0) {
>          ifs = enumIPv4Interfaces(env, sock, NULL);
>          close(sock);
>
>          if ((*env)->ExceptionOccurred(env)) {
>              freeif(ifs);
>              return NULL;
>          }
>      }
>      ...
>
>          if (ipv6_available()) {
>             sock = openSocket(env, AF_INET6);
>             if (sock < 0 && (*env)->ExceptionOccurred(env)) {
>                 freeif(ifs);
>                 return NULL;
>             }
>
>             if (sock >= 0) {
>                 ifs = enumIPv6Interfaces(env, sock, ifs);
>                 close(sock);
>
>                 if ((*env)->ExceptionOccurred(env)) {
>                     freeif(ifs);
>                     return NULL;
>                 }
>             }
>         }
> ---
>
> Let's keep this JIRA issue focused on the task in-hand ( ip6-only
> support ). Other technical debt and behavioural issues ( beyond the most
> trivial ) can be addressed separately.
>
> -Chris.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/net-dev/attachments/20190510/69d7c717/attachment.html>


More information about the net-dev mailing list