RFR [14] 8236441: Bound MulticastSocket fails when setting outbound interface on Windows

Alan Bateman Alan.Bateman at oracle.com
Fri Dec 20 20:17:33 UTC 2019


On 20/12/2019 17:53, Chris Hegarty wrote:
> The MulticastSocket implementation on Windows uses the two stacks
> implementation. The two stacks implementation creates a socket on the
> IPv4 stack and another on the IPv6 stack. Operations are then performed
> on both sockets as appropriate. If the socket is bound to a specific
> address, then the IP version of the socket that matches that address is
> retained, and the other closed.
>
> This is a complicated implementation, which will hopefully be replaced
> soon, but in the meantime there is a serious bug with handling the
> IP_MULTICAST_IF[2] socket option. The code does not correctly cater for
> the fact that one of the file descriptors may be closed, leading to
> SocketExceptions with a message of: "An operation was attempted on
> something that is not a socket (Error setting socket option)"
>
> Webrev:
>    https://cr.openjdk.java.net/~chegar/8236441/webrev.00/
> JIRA:
>    https://bugs.openjdk.java.net/browse/JDK-8236441
>
This looks okay to me. There are a few inconsistencies in this code in 
that some places it checks if fd1 >= 0, others != -1 but I don't think 
there are correctness issues. You probably don't need to check 
ipv6_supported as fd1 can't be valid if IPv6 is disabled but won't 
change the branches that are executed.

In passing, the pre-existing comment at L1881 in this patch doesn't look 
right. The index will be 0 when an outgoing interface is not set.

-Alan.



More information about the net-dev mailing list