Date: Wed, 08 Nov 2023 14:35:18 +0000 From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 274964] java/openjdk21 Dual-stack IPv4/IPv6 applications no longer work with sysctl net.inet6.ip6.v6only=1 Message-ID: <bug-274964-7788@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D274964 Bug ID: 274964 Summary: java/openjdk21 Dual-stack IPv4/IPv6 applications no longer work with sysctl net.inet6.ip6.v6only=3D1 Product: Ports & Packages Version: Latest Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: Individual Port(s) Assignee: java@FreeBSD.org Reporter: djn@araxis.com Flags: maintainer-feedback?(java@FreeBSD.org) Assignee: java@FreeBSD.org We have a Tomcat-based application (with Tomcat configured to use the Apache Portable Runtime) that listens on both IPv4 and IPv6. Java is invoked with -Djava.net.preferIPv4Stack=3Dfalse to enable IPv6 support. This application works perfectly on FreeBSD with OpenJDK 17 and accepts both IPv4 and IPv6 connections, even though the FreeBSD 13.2-RELEASE-p3 host has= the default sysctl net.inet6.ip6.v6only=3D1 setting. The exact same application= and configuration fails to listen to IPv4 clients when deployed with OpenJDK 21. We have another JVM server application, this time created using Scala HTTP4s (https://http4s.org/), and thus not using the Apache Portable Runtime. This application (again run with -Djava.net.preferIPv4Stack=3Dfalse) exhibits the exact same behaviour: with OpenJDK 17, both IPv4 and IPv6 clients can conne= ct; with OpenJDK 21, only IPv6 clients can connect. The problem is thus not specific to the Apache Portable Runtime. Both applications work as expected with OpenJDK 21 if the FreeBSD host has sysctl net.inet6.ip6.v6only set to 0. However, setting sysctl net.inet6.ip6.v6only=3D0 is not required using OpenJDK 17. Both applications are running in FreeBSD jails, but I do not believe that is likely a factor. I am not sure whether I am looking at the relevant code or not, but the Fre= eBSD OpenJDK 17 port has BSD-specific code in src/java.base/unix/native/libnet/PlainSocketImpl.c that appears to set the IPV6_V6ONLY flag to 0 when opening a socket if IPv4 is available. See https://github.com/battleblow/jdk17u/blob/373026a81f5000e6df990eb9faec37f51= 8ee711e/src/java.base/unix/native/libnet/PlainSocketImpl.c#L184 The networking code appears to have been re-arranged in OpenJDK 21 (relativ= e to OpenJDK 17), so that particular source file no longer exists. However, a se= arch for IPV6_V6ONLY in the jdk21u GitHub repository does not reveal any plausib= le direct equivalent code. This explicit enabling of IPV6_V6ONLY when opening a socket in OpenJDK 17 may perhaps be the reason why OpenJDK 17 works for us without sysctl net.inet6.ip6.v6only=3D0 but OpenJDK 21 doesn=E2=80=99t. Note that we also tested the FreeBSD OpenJDK 18, 19, and 20 ports. Like Ope= nJDK 21, these also fail to work with our dual-stack applications. This issue is almost certainly related to the old OpenJDK 11 bug #239890, b= ut I am guessing that bug was obsolete as of OpenJDK 17, since the described scenario does seem to work there. --=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-274964-7788>