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

Mark Sheppard msheppar at openjdk.org
Thu Jun 15 11:30:57 UTC 2023


On Thu, 15 Jun 2023 10:47:58 GMT, Michael McMahon <michaelm 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.

so is it the case that for INET6 two call setsockopt calls need to be called one for IP_MULTICAST_ALL and one for IPV6_MULTICAST_ALL. IFF that is the case I think two conditional blocks, on the domain, to emphasize this would be clearer and convey such semantics more cleanly

if (domain == AF_INET6) {
 ....
  if((setsockopt(fd, IPPROTO_IPV6, IP_MULTICAST_ALL, (char*)&arg, sizeof(arg)) < 0) && ... {
   ....
  }
  if((setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_ALL, (char*)&arg, sizeof(arg)) < 0) && ... {
   ....
  }
} else {
  if((setsockopt(fd, IPPROTO_IP, IP_MULTICAST_ALL, (char*)&arg, sizeof(arg)) < 0) && ... {
   ....
  }
}

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

PR Comment: https://git.openjdk.org/jdk/pull/14491#issuecomment-1592868150


More information about the nio-dev mailing list