Skip to content

Add support for IP_MULTICAST_ALL to EpollDatagramChannel and IOUringDatagramChannel (netty 4.2)#15755

Merged
normanmaurer merged 15 commits into
netty:4.2from
mahoestar:feat-IP_MULTICAST_ALL
Nov 13, 2025
Merged

Add support for IP_MULTICAST_ALL to EpollDatagramChannel and IOUringDatagramChannel (netty 4.2)#15755
normanmaurer merged 15 commits into
netty:4.2from
mahoestar:feat-IP_MULTICAST_ALL

Conversation

@mahoestar
Copy link
Copy Markdown
Contributor

@mahoestar mahoestar commented Oct 15, 2025

Motivation:

IP multicast behaviour varies between Windows and Linux.

On Windows, you only receive datagrams for the groups your socket has joined.

On Linux, by default, you receive datagrams for all groups joined by the host.

This behaviour can be controlled using the IP_MULTICAST_ALL (or IPV6_MULTICAST_ALL) socket option - it is set to 1 by default.

OpenJDK sets this to 0 on all NIO and Net multicast channels, it is not configurable.

This PR makes the option configurable for epoll socket channels, so that behaviour can be made consistent between NIO and native datagram channels.

Modification:

Add IP_MULTICAST_ALL and IPV6_MULTICAST_ALL options to native epoll transport and native io uring transport.

Set IP_MULTICAST_ALL to 0 when constructing epoll and io uring datagram channels.

Result:

Fixes #15753.

IP multicast behaviour varies between Windows and Linux.

On Windows, you only receive datagrams for the groups your socket
has joined.

On Linux, by default, you receive datagrams for all groups joined
by the host.

This behaviour can be controlled using the IP_MULTICAST_ALL (or
IPV6_MULTICAST_ALL) socket option - it is set to 1 by default.

OpenJDK sets this to 0 on all NIO and Net multicast channels, it
is not configurable.

This PR makes the option configurable for epoll socket channels,
so that behaviour can be made consistent between NIO and Epoll
DatagramChannel.
@mahoestar mahoestar changed the title feat: support for IP_MULTICAST_ALL for epoll (netty 4.2) Add support for IP_MULTICAST_ALL to EpollDatagramChannel (netty 4.2) Oct 15, 2025
@normanmaurer
Copy link
Copy Markdown
Member

I think we also want to have this for IoUringDatagramChannel.

@mahoestar
Copy link
Copy Markdown
Contributor Author

Agreed - will add that now.

Comment thread transport-native-epoll/src/main/c/netty_epoll_linuxsocket.c Outdated
Comment thread transport-native-epoll/src/main/c/netty_epoll_linuxsocket.c Outdated
Comment thread transport-native-epoll/src/main/c/netty_epoll_linuxsocket.c Outdated
Comment thread transport-native-epoll/src/main/c/netty_epoll_linuxsocket.c Outdated
Comment thread transport-native-epoll/src/main/c/netty_epoll_linuxsocket.c Outdated
Comment thread transport-native-epoll/src/main/c/netty_epoll_linuxsocket.c Outdated
Comment thread transport-native-epoll/src/main/c/netty_epoll_linuxsocket.c Outdated
Comment thread transport-native-epoll/src/main/c/netty_epoll_linuxsocket.c Outdated
@normanmaurer
Copy link
Copy Markdown
Member

@mahoestar did you sign our ical ? https://netty.io/s/icla ?

@normanmaurer normanmaurer added this to the 4.2.8.Final milestone Oct 16, 2025
@normanmaurer
Copy link
Copy Markdown
Member

Let's merge this one and then do another PR for io_uring as well

@mahoestar
Copy link
Copy Markdown
Contributor Author

Sorry for radio silence - needed to get the CLA signed.

Corporate CLA has been signed by my employer now.

I'll review all requested changes on this and the netty5 PR now.

@mahoestar
Copy link
Copy Markdown
Contributor Author

mahoestar commented Oct 21, 2025

This PR doesn't yet set the IP_MULTICAST_ALL automatically - I can port those changes across before you merge if you would like?

Then can raise io_uring support for 4.2 as a separate PR.

@normanmaurer
Copy link
Copy Markdown
Member

@mahoestar can you just do the changes required here and we will port it to other branches later on ?

@normanmaurer
Copy link
Copy Markdown
Member

@mahoestar also please sign our ICLA and let me know one done: https://netty.io/s/icla

@normanmaurer
Copy link
Copy Markdown
Member

@mahoestar also please sign our ICLA and let me know one done: https://netty.io/s/icla

@mahoestar ping

@mahoestar
Copy link
Copy Markdown
Contributor Author

Hi, sorry for the delay.

My employer has signed the CCLA - is that sufficient? I should be listed under approved contributors there.

I will make the following changes in this branch now:

  • Automatic setting of IP_MULTICAST_ALL
  • IO uring support

Is that OK?

@normanmaurer
Copy link
Copy Markdown
Member

Hi, sorry for the delay.

My employer has signed the CCLA - is that sufficient? I should be listed under approved contributors there.

Yes!

I will make the following changes in this branch now:

  • Automatic setting of IP_MULTICAST_ALL
  • IO uring support

Is that OK?

Sounds good... feel free to close the other PR in the meantime.

@mahoestar
Copy link
Copy Markdown
Contributor Author

I've made the changes.

I'm not sure what behaviour would be best from the constructor of Epoll/IOUringDatagramChannel - whether we should throw a channel exception on failing to set IP_MULTICAST_ALL, or to log an internal error.

I suppose an error is possible if using an old kernel.

@mahoestar mahoestar changed the title Add support for IP_MULTICAST_ALL to EpollDatagramChannel (netty 4.2) Add support for IP_MULTICAST_ALL to EpollDatagramChannel and IOUringDatagramChannel (netty 4.2) Nov 7, 2025
@normanmaurer
Copy link
Copy Markdown
Member

I've made the changes.

I'm not sure what behaviour would be best from the constructor of Epoll/IOUringDatagramChannel - whether we should throw a channel exception on failing to set IP_MULTICAST_ALL, or to log an internal error.

I suppose an error is possible if using an old kernel.

Yeah I think logging might be the best bet for compat reasons.

import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.channel.DefaultAddressedEnvelope;
import io.netty.channel.*;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert wildcard imports.

public final class EpollDatagramChannel extends AbstractEpollChannel implements DatagramChannel {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(AbstractByteBuf.class);
private static final boolean IP_MULTICAST_ALL =
SystemPropertyUtil.getBoolean("io.netty5.transport.linux.ipMulticastAll", false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SystemPropertyUtil.getBoolean("io.netty5.transport.linux.ipMulticastAll", false);
SystemPropertyUtil.getBoolean("io.netty.transport.linux.ipMulticastAll", false);

try {
fd.setIpMulticastAll(IP_MULTICAST_ALL);
} catch (IOException e) {
throw new ChannelException(e);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to just log

import io.netty.channel.ChannelPromise;
import io.netty.channel.DefaultAddressedEnvelope;
import io.netty.channel.IoRegistration;
import io.netty.channel.*;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert wildcard support

public final class IoUringDatagramChannel extends AbstractIoUringChannel implements DatagramChannel {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(AbstractByteBuf.class);
private static final boolean IP_MULTICAST_ALL =
SystemPropertyUtil.getBoolean("io.netty5.transport.linux.ipMulticastAll", false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SystemPropertyUtil.getBoolean("io.netty5.transport.linux.ipMulticastAll", false);
SystemPropertyUtil.getBoolean("io.netty.transport.linux.ipMulticastAll", false);

try {
fd.setIpMulticastAll(IP_MULTICAST_ALL);
} catch (IOException e) {
throw new ChannelException(e);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just log

- Revert wildcard imports
- Correct system property names (not netty5)
- Log on failure to set IP_MULTICAST_ALL when constructing datagram channels.
@normanmaurer normanmaurer merged commit 7759a07 into netty:4.2 Nov 13, 2025
16 of 19 checks passed
@normanmaurer
Copy link
Copy Markdown
Member

@mahoestar thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for IP_MULTICAST_ALL channel option on EpollDatagramChannel

2 participants