net/ipforward: Forbid non-forwardable multicast scopes.#18738
net/ipforward: Forbid non-forwardable multicast scopes.#18738ankohuu wants to merge 1 commit intoapache:masterfrom
Conversation
RFC 3171 reserves 224.0.0.0/24 for link-local IPv4 multicast scope, so packets in this range must not be forwarded by routers, regardless of the TTL value. IPv6 also defines multicast scopes that must not be forwarded beyond the local topology. In particular, interface-local and link-local multicast destinations must not be routed across interfaces. Add IPv4/IPv6 scope checks so non-forwardable multicast packets are rejected before entering the multicast forwarding path. Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
|
@ankohuu very nice! Is this multicast behavior of NuttX a BUG or a limitation? If so, please open an Issue here to map and fix it later |
| if ((net_ip4addr_conv32(ipv4->destipaddr) & | ||
| HTONL(0xffffff00)) == HTONL(0xe0000000)) | ||
| { | ||
| return; |
There was a problem hiding this comment.
Maybe it could be interesting to report a network debug warning here, or, do you think it is not necessary? If not, why not?
There was a problem hiding this comment.
I don’t think this needs to be added:
- During IGMP initialization, 224.0.0.1 is joined, which looks reasonable. https://github.com/apache/nuttx/blob/12e8f92a282fac58e0dfff587ea3d9502e4804c0/net/igmp/igmp_initialize.c#L86
- For multicast forwarding, the current logic appears to depend on the groups joined by the local host; I’m not trying to change this behavior.
- So hitting this case is expected
Let's don’t report it, just drop it.
Hi acassis, Overall, I tend to think the current multicast behavior in NuttX is not correct. MC forwarding should not be driven by the groups that the local host itself has joined, but, I would not call the current implementation useless; this is why I described it as behaving more like a relay. Why I limited this change to the current scope:
I can open an issue to put this into the backlog:
Then I am glad to open a bug to track this properly if still necessary Shunchao |
Summary
NuttX currently supports forwarding of IP multicast packets. This forwarding is not comparable to multicast-capable switches or routers, which rely on
IGMP/MLDsnooping or multicast routing protocols. Instead, it performs a simpleflooding mechanism based on locally joined
IGMPgroups, effectively behaving maybe like a relay.This PR does not change the existing behavior. It only blocks cases that should not be forwarded under the current model.
224.0.0.0/24for link-local IPv4 multicast scopeRFC 3171224.0.0.0 - 224.0.0.255 (224.0.0/24) Local Network Control BlockRFC 4291Interface-Local scope spans only a single interface on a node and is useful only for loopback transmission of multicast.Impact
IP multicast packets behavior changed in above cases.
Testing
The issue was identified while I try to set up a NAT environment using the NuttX simulator. The test setup consists of a sim instance with two network interfaces, both backed by TAP devices.
Env
Config
.config file
Test step
Log: