[HELP] Why isn't multicast loopback switched on by default?
Description
@acassis I noticed recently that multicast loopback is disabled by default in NuttX. I have a pair of applications which when I run them on the same device using Linux, discover each other via multicast loopback. However when I run these applications on the same device using NuttX (kernel mode), they do not discover each other, even though applications on other devices can see their multicast traffic.
In nuttx/net/udp/udp_send.c, you can see that there is support for IP_MULTICAST_LOOP in the code. I have the relevant options set in my defconfig, so if that bit is set then it should be looping back.
It seems that IP_MULTICAST_LOOP is set by default in Linux, but in NuttX the bit is not set by default in conn->sconn.s_options.
I have two questions based on this, and I'm hoping someone more knowledgeable than I about this stuff can help.
- Why doesn't NuttX set this bit by default?
- Should NuttX set this bit by default?
I can use the sockets API to set this in my communications stack, but it isn't clear to me what is the right place to do it.
Verification
- [x] I have verified before submitting the report.
This Linux programming document from 1998 Multicast Programming says in section 6.1 IP_MULTICAST_LOOP "Loopback is by default enabled.", so I find it strange that NuttX doesn't have at least a config by which it may be default enabled.
@sastel I think it is because NuttX try to only enable the minimal thinks possible. But things are changing, in the past we could enable or disable signals, until someone realized signal was a required by POSIX. Now we don't have option to disable signals. Although we got better compatibility we lose the ability to not use it in small microcontrollers.
Maybe a better compromise is just enabling by default what is required by the POSIX standard but keep the option to disable it. I think multicast loopback could follow this approach.
@wengzhe @xiaoxiang781216 @raiden00pl please comment
it's fine to enable multicast loop by default like Linux
Would it be an idea to add a "POSIX-compliance" Kconfig option, default yes. If disabled, a list of all the individual features that can be disabled is shown. As items are added to that list over time, we could try and encourage proper help explanations of the advantage gained if each that item is disabled?
POSIX-compliance isn't an option. It's also bad to add an option to control the minor default behavior, since only few people can remember them.
Ok, but I see people lamenting the loss of options that allow NuttX to better suit small processors. Shouldn't we accommodate that somehow as NON default options?
This suggestion is only changing the default value, no size impact on the final image. ICMP already has an option and disabled by default.
I got sidetracked by Alan's comment about signals.
Loopback default state is a Linux vs NuttX argument that I have no opinion on if it doesn't break existing code/apps for NuttX users.
@xiaoxiang781216 where would you enable it?
I was thinking in udp_alloc.
@xiaoxiang781216 where would you enable it?
I was thinking in
udp_alloc.
yes, it's good place to set the initial value.