RFR: 8241800: Disable IPV6_MULTICAST_ALL to prevent interference from all multicast groups

Michael McMahon michaelm at openjdk.org
Thu Jun 15 11:30:58 UTC 2023


On Thu, 15 Jun 2023 11:21:52 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Hi,
>> 
>> Can I get the following change reviewed please? It disables the IPV6_MULTICAST_ALL socket option on UDP sockets on Linux systems which support the option (kernel version 4.20+). This has the effect of disabling the surprising default behavior of multicast sockets on Linux where sockets can receive packets sent to groups the receiver has not joined, if some other socket has joined that group on the same system.
>> 
>> The equivalent behavior has already been implemented for IPv4 sockets.
>> 
>> Thanks,
>> Michael.
>
> src/java.base/unix/native/libnio/ch/Net.c line 310:
> 
>> 308:                 close(fd);
>> 309:                 return -1;
>> 310:             }
> 
> It might be better to move this to just below the attempt to set IPV6_MULTICAST_HOPS as that code only runs for IPv6 datagrams.
> 
> That said, I'm a bit concerned that this will fail on older kernels. Are you sure the error is ENOPROTOOPT?

Yes, the error is the same as for the IPv4 option. If you like I can change the test to set the option and check an exception is not thrown in those cases.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14491#discussion_r1230865928


More information about the nio-dev mailing list