RFR: JDK-8313804: JDWP support for -Djava.net.preferIPv6Addresses=system [v2]

Chris Plummer cjplummer at openjdk.org
Tue Sep 19 23:39:06 UTC 2023


On Mon, 18 Sep 2023 23:57:33 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

> For 748, it's handling a situation where IPv4 isn't specifically preferred. The implementation comment notes 'if preferredAddressFamily is AF_INET6 or not set'.

What does "specifically preferred" mean? By default it will be set to AF_INET. If it is set to AF_INET,  you can't tell if `java.net.preferIPv6Addresses=false` was specified (which implies AF_INET), or if nothing was specified and it just defaulted to AF_INET. The comment and the code read as if preferredAddressFamily will be something other than AF_INET unless `java.net.preferIPv6Addresses=false` is used. Maybe the code is correct and the comment needs some cleaning up. TBH I don't understand what this code is suppose to do.

 743     // Binding to IN6ADDR_ANY allows to serve both IPv4 and IPv6 connections,
 744     // but binding to mapped INADDR_ANY (::ffff:0.0.0.0) allows to serve IPv4
 745     // connections only. Make sure that IN6ADDR_ANY is preferred over
 746     // mapped INADDR_ANY if preferredAddressFamily is AF_INET6 or not set.
 747 
 748     if (preferredAddressFamily != AF_INET) {
 749         inet_pton(AF_INET6, "::ffff:0.0.0.0", &mappedAny);
 750 
 751         if (isEqualIPv6Addr(listenAddr, mappedAny)) {
 752             for (ai = addrInfo; ai != NULL; ai = ai->ai_next) {
 753                 if (isEqualIPv6Addr(listenAddr, in6addr_any)) {
 754                     listenAddr = ai;
 755                     break;
 756                 }
 757             }
 758         }
 759     }

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15796#issuecomment-1726680570


More information about the serviceability-dev mailing list