From 4898c477a95fff23499e830635323216a2c798a9 Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Sat, 27 Oct 2018 18:12:37 +0000 Subject: [PATCH] Merged in antmerlino/nuttx/multicast-fix (pull request #739) Fixes logic in ipv6_input to handle more than ff02::/16 multicast addresses. Don't forward mcast packets if scope is not appropriate Approved-by: GregoryN --- net/devif/ipv6_input.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index d905c41625..453d27e609 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -309,17 +309,26 @@ int ipv6_input(FAR struct net_driver_s *dev) * address yet assigned to the device). We should actually pick off * certain multicast address (all hosts multicast address, and the * solicited-node multicast address). We will cheat here and accept - * all multicast packets that are sent to the ff02::/16 addresses. + * all multicast packets that are sent to the ff00::/8 addresses. */ #if defined(CONFIG_NET_BROADCAST) && defined(NET_UDP_HAVE_STACK) - if (ipv6->proto == IP_PROTO_UDP && - ipv6->destipaddr[0] == HTONS(0xff02)) + if (ipv6->proto == IP_PROTO_UDP && net_is_addr_mcast(ipv6->destipaddr)) { #ifdef CONFIG_NET_IPFORWARD_BROADCAST - /* Forward broadcast packets */ - ipv6_forward_broadcast(dev, ipv6); + /* Packets sent to ffx0 are reserved, ffx1 are interface-local, and ffx2 + * are interface-local, and therefore, should not be forwarded + */ + + if ((ipv6->destipaddr[0] & HTONS(0xff0f) != HTONS(0xff00)) && + (ipv6->destipaddr[0] & HTONS(0xff0f) != HTONS(0xff01)) && + (ipv6->destipaddr[0] & HTONS(0xff0f) != HTONS(0xff02))) + { + /* Forward broadcast packets */ + + ipv6_forward_broadcast(dev, ipv6); + } #endif return udp_ipv6_input(dev); }