Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Nov 2024 20:56:24 +0000
From:      bugzilla-noreply@freebsd.org
To:        java@FreeBSD.org
Subject:   [Bug 282251] java/openjdk22: IPv6 / INET6 is broken
Message-ID:  <bug-282251-8522-ZhEQb8kLh9@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-282251-8522@https.bugs.freebsd.org/bugzilla/>
References:  <bug-282251-8522@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D282251

--- Comment #3 from antonfb@hesiod.org ---
I stand by my comment.

I put your code into a class with imports etc.

This is java22
seine.hesiod.org:anton[1]: java -version
openjdk version "22.0.2" 2024-07-16
OpenJDK Runtime Environment (build 22.0.2+9-1)
OpenJDK 64-Bit Server VM (build 22.0.2+9-1, mixed mode, sharing)


First run (without preferipv4stack=3Dfalse):
seine.hesiod.org:anton[11]: java bugtest
Connected Socket[addr=3Dseine.hesiod.org/192.168.2.3,port=3D46994,localport=
=3D21181]
to Socket[addr=3D/192.168.2.3,port=3D21181,localport=3D46994]
Connected Socket[addr=3D/127.0.0.1,port=3D57640,localport=3D10314] to
Socket[addr=3D/127.0.0.1,port=3D10314,localport=3D57640]
Failed to connect to localhost with INET6
java.net.SocketException: Protocol family unavailable
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:565)
        at java.base/sun.nio.ch.Net.bind(Net.java:554)
        at java.base/sun.nio.ch.NioSocketImpl.bind(NioSocketImpl.java:636)
        at java.base/java.net.ServerSocket.bind(ServerSocket.java:390)
        at java.base/java.net.ServerSocket.<init>(ServerSocket.java:277)
        at bugtest.main(bugtest.java:47)

Second run (with java flag):
seine.hesiod.org:anton[12]: java -Djava.net.preferIPv4Stack=3Dfalse bugtest
Failed to connect to localhost with unspecified protocol
java.net.SocketException: Invalid argument
        at java.base/sun.nio.ch.Net.connect0(Native Method)
        at java.base/sun.nio.ch.Net.connect(Net.java:589)
        at java.base/sun.nio.ch.Net.connect(Net.java:578)
        at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:58=
3)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:=
327)
        at java.base/java.net.Socket.connect(Socket.java:752)
        at java.base/java.net.Socket.connect(Socket.java:687)
        at java.base/java.net.Socket.<init>(Socket.java:556)
        at java.base/java.net.Socket.<init>(Socket.java:357)
        at bugtest.main(bugtest.java:14)
Failed to connect to localhost with INET
java.net.BindException: Can't assign requested address
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:565)
        at java.base/sun.nio.ch.Net.bind(Net.java:554)
        at java.base/sun.nio.ch.NioSocketImpl.bind(NioSocketImpl.java:636)
        at java.base/java.net.ServerSocket.bind(ServerSocket.java:390)
        at java.base/java.net.ServerSocket.<init>(ServerSocket.java:277)
        at bugtest.main(bugtest.java:30)
Failed to connect to localhost with INET6
java.net.SocketException: Invalid argument
        at java.base/sun.nio.ch.Net.connect0(Native Method)
        at java.base/sun.nio.ch.Net.connect(Net.java:589)
        at java.base/sun.nio.ch.Net.connect(Net.java:578)
        at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:58=
3)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:=
327)
        at java.base/java.net.Socket.connect(Socket.java:752)
        at java.base/java.net.Socket.connect(Socket.java:687)
        at java.base/java.net.Socket.<init>(Socket.java:556)
        at java.base/java.net.Socket.<init>(Socket.java:357)
        at bugtest.main(bugtest.java:48)

Third run (with flag & sysctl net.inet6.ip6.v6only=3D0)
seine.hesiod.org:anton[13]: java -Djava.net.preferIPv4Stack=3Dfalse bugtest
Connected Socket[addr=3Dseine.hesiod.org/192.168.2.3,port=3D46531,localport=
=3D13926]
to Socket[addr=3D/192.168.2.3,port=3D13926,localport=3D46531]
Connected Socket[addr=3D/127.0.0.1,port=3D63268,localport=3D33512] to
Socket[addr=3D/127.0.0.1,port=3D33512,localport=3D63268]
Connected Socket[addr=3Dseine.hesiod.org/192.168.2.3,port=3D53154,localport=
=3D63501]
to Socket[addr=3D/192.168.2.3,port=3D63501,localport=3D53154]

So as I wrote five years ago the jdk was intentionally broken WRT ipv6.
To make it work, you must pass the -Djava.net.preferIPv4Stack=3Dfalse to yo=
ur
java vm AND change the global sysctl net.inet6.ip6.v6only=3D0

If you want to unbreak this I'm not certain what to do. I would like to see
this fixed and ipv6 cleanly supported without having to set the system wide
level setting. I don't think the code fix is the problem. The problem will =
be
that the maintainers do not want this fixed.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-282251-8522-ZhEQb8kLh9>