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

Arthur Eubanks aeubanks at google.com
Wed May 8 05:52:09 UTC 2019


Bug: https://bugs.openjdk.java.net/browse/JDK-8223532
Webrev: http://cr.openjdk.java.net/~aeubanks/8223532/webrev.00/

There are a couple of functions in
src/java.base/unix/native/libnet/NetworkInterface.c which try to create
IPv4 sockets, then check if errno is EPROTONOSUPPORT. If errno is
EPROTONOSUPPORT, then IPv6 is tried, else it immediately bails.

We have a kernel that returns EAFNOSUPPORT when IPv4 is disabled and there
is an attempt to create an AF_INET socket.

Rather than adding a check for EAFNOSUPPORT, which seems too specific, just
don't bother trying to create an IPv4 socket if IPv4 is not available. This
uses ipv4_available(), introduced in
http://hg.openjdk.java.net/jdk/jdk/rev/22323f20401b.

Since previously the code assumed that we have at least IPv4, now when
initializing ipv4/6_available(), make sure that at least one of them is
available, or else bail. One problem I have with this is that the error
message when neither is present is not descriptive:
Error occurred during initialization of boot layer
java.lang.UnsatisfiedLinkError: unsupported JNI version 0xFFFFFFFF required
by path/to/jdk/build/jdk/lib/libnet.so
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/net-dev/attachments/20190507/773684e1/attachment.html>


More information about the net-dev mailing list