DatagramChannel::disconnect appears to rebind socket to the wildcard address

Alan Bateman Alan.Bateman at oracle.com
Thu Sep 26 06:38:51 UTC 2019



On 25/09/2019 21:03, Kurt Miller wrote:
> :
> Your welcome. It is something simple. Roughly speaking:
>
> - set flag when bind on dgram socket sets IP addr
> - when disconnecting (connect(2) called w/AF_UNSPEC) if flag
> is set, don't reset it to INADDR_ANY
>
Thanks. One other issue that was found by the same combo test is 
JDK-8231258 [1] and it may be of interest. It's a somewhat nonsensical 
scenario but appears to demonstrates an issue on macOS where getsockname 
returns an expected local address. I don't know if it arises with 
OpenBSD or other BSDs.

The scenario is an IPv6 UDP socket. IPV6_V6ONLY is disabled so dual 
stack. The socket is bound to a local IPv4 address (using an IPv4-mapped 
IPv6 address). The socket is connected to an IPv6 address. At this 
point, getsockname returns an IPv4 compatible IPv6 address (as in 
::<ip4address>) rather than an IPv4-mapped IPv6 address (as in 
::ffff:<ip4address>). It would be surprising if anything real world 
would create this same scenario, instead it's something that a test 
exercise all combinations of bind/connect finds.

-Alan

[1] https://bugs.openjdk.java.net/browse/JDK-8231258




More information about the bsd-port-dev mailing list