[OpenWrt-Devel] [PATCH 1/2] [netifd] multicast flag control

Podolak, Nicholas Nicholas.Podolak at cubic.com
Tue Oct 20 10:31:01 EDT 2015


From: Nick Podolak <nicholas.podolak at dtechlabs.com>

This patch set allows for interfaces defined in UCI to enable and disable multicast support on their underlying device.  This has particular use on GRE tunnels which previously did NOT enable multicast by default.  Since GRE is commonly used to create router to router links that support multicast for use by routing protocols (e.g. OSPF, EIGRP, etc), or specifically for multicast applications, this modification seemed necessary.

This first patch adds the multicast capability to all interfaces/devices.


Signed-off-by: Nick Podolak <nicholas.podolak at dtechlabs.com>

Index: netifd-2015-09-27/device.c
===================================================================
--- netifd-2015-09-27.orig/device.c    2015-10-13 15:21:54.358124119 -0400
+++ netifd-2015-09-27/device.c    2015-10-13 15:21:54.346124119 -0400
@@ -40,6 +40,7 @@
     [DEV_ATTR_ENABLED] = { .name = "enabled", .type = BLOBMSG_TYPE_BOOL },
     [DEV_ATTR_IPV6] = { .name = "ipv6", .type = BLOBMSG_TYPE_BOOL },
     [DEV_ATTR_PROMISC] = { .name = "promisc", .type = BLOBMSG_TYPE_BOOL },
+    [DEV_ATTR_MULTICAST] = { .name = "multicast", .type = BLOBMSG_TYPE_BOOL },
     [DEV_ATTR_RPFILTER] = { .name = "rpfilter", .type = BLOBMSG_TYPE_STRING },
     [DEV_ATTR_ACCEPTLOCAL] = { .name = "acceptlocal", .type = BLOBMSG_TYPE_BOOL },
     [DEV_ATTR_IGMPVERSION] = { .name = "igmpversion", .type = BLOBMSG_TYPE_INT32 },
@@ -162,6 +163,7 @@
         sizeof(n->macaddr));
     n->ipv6 = s->flags & DEV_OPT_IPV6 ? s->ipv6 : os->ipv6;
     n->promisc = s->flags & DEV_OPT_PROMISC ? s->promisc : os->promisc;
+    n->multicast = s->flags & DEV_OPT_MULTICAST ? s->multicast : os->multicast;
     n->rpfilter = s->flags & DEV_OPT_RPFILTER ? s->rpfilter : os->rpfilter;
     n->acceptlocal = s->flags & DEV_OPT_ACCEPTLOCAL ? s->acceptlocal : os->acceptlocal;
     n->igmpversion = s->flags & DEV_OPT_IGMPVERSION ? s->igmpversion : os->igmpversion;
@@ -222,6 +224,11 @@
         s->flags |= DEV_OPT_PROMISC;
     }

+    if ((cur = tb[DEV_ATTR_MULTICAST])) {
+        s->multicast = blobmsg_get_bool(cur);
+        s->flags |= DEV_OPT_MULTICAST;
+    }
+
     if ((cur = tb[DEV_ATTR_RPFILTER])) {
         if (system_resolve_rpfilter(blobmsg_data(cur), &s->rpfilter))
             s->flags |= DEV_OPT_RPFILTER;
@@ -899,6 +906,8 @@
             blobmsg_add_u8(b, "ipv6", st.ipv6);
         if (st.flags & DEV_OPT_PROMISC)
             blobmsg_add_u8(b, "promisc", st.promisc);
+        if (st.flags & DEV_OPT_MULTICAST)
+            blobmsg_add_u8(b, "multicast", st.multicast);
         if (st.flags & DEV_OPT_RPFILTER)
             blobmsg_add_u32(b, "rpfilter", st.rpfilter);
         if (st.flags & DEV_OPT_ACCEPTLOCAL)
Index: netifd-2015-09-27/system-linux.c
===================================================================
--- netifd-2015-09-27.orig/system-linux.c    2015-10-13 15:21:54.358124119 -0400
+++ netifd-2015-09-27/system-linux.c    2015-10-13 15:21:54.350124119 -0400
@@ -1091,6 +1091,11 @@
         s->flags |= DEV_OPT_PROMISC;
     }

+    if (ioctl(sock_ioctl, SIOCGIFFLAGS, &ifr) == 0) {
+        s->multicast = ifr.ifr_flags & IFF_MULTICAST;
+        s->flags |= DEV_OPT_MULTICAST;
+    }
+
     if (!system_get_rpfilter(dev, buf, sizeof(buf))) {
         s->rpfilter = strtoul(buf, NULL, 0);
         s->flags |= DEV_OPT_RPFILTER;
@@ -1193,6 +1198,11 @@
                     !s->promisc ? IFF_PROMISC : 0) < 0)
             s->flags &= ~DEV_OPT_PROMISC;
     }
+    if (s->flags & DEV_OPT_MULTICAST & apply_mask) {
+        if (system_if_flags(dev->ifname, s->multicast ? IFF_MULTICAST : 0,
+                    !s->multicast ? IFF_MULTICAST : 0) < 0)
+            s->flags &= ~DEV_OPT_MULTICAST;
+    }
     if (s->flags & DEV_OPT_RPFILTER & apply_mask) {
         snprintf(buf, sizeof(buf), "%d", s->rpfilter);
         system_set_rpfilter(dev, buf);
Index: netifd-2015-09-27/device.h
===================================================================
--- netifd-2015-09-27.orig/device.h    2015-10-13 15:21:54.358124119 -0400
+++ netifd-2015-09-27/device.h    2015-10-13 15:21:54.350124119 -0400
@@ -34,6 +34,7 @@
     DEV_ATTR_ENABLED,
     DEV_ATTR_IPV6,
     DEV_ATTR_PROMISC,
+    DEV_ATTR_MULTICAST,
     DEV_ATTR_RPFILTER,
     DEV_ATTR_ACCEPTLOCAL,
     DEV_ATTR_IGMPVERSION,
@@ -88,6 +89,7 @@
     DEV_OPT_DADTRANSMITS        = (1 << 13),
     DEV_OPT_MULTICAST_TO_UNICAST    = (1 << 14),
     DEV_OPT_MULTICAST_ROUTER    = (1 << 15),
+    DEV_OPT_MULTICAST        = (1 << 16),
 };

 /* events broadcasted to all users of a device */
@@ -136,6 +138,7 @@
     uint8_t macaddr[6];
     bool ipv6;
     bool promisc;
+    bool multicast;
     unsigned int rpfilter;
     bool acceptlocal;
     unsigned int igmpversion;
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list