From: Nick Podolak <nicholas.podo...@detchlabs.com> Add multicast flag control to interfaces in netifd Signed-off-by: Nick Podolak <nicholas.e.podo...@gmail.com> ---
My repeated apologies for butchering the canonical patch message body formatting. I think I have got the format and my mail client settings correct this time though. Thanks for your patience. device.c | 9 +++++++++ device.h | 3 +++ system-linux.c | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/device.c b/device.c index 6dc4fa9..b755d05 100644 --- a/device.c +++ b/device.c @@ -40,6 +40,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [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 @@ device_merge_settings(struct device *dev, struct device_settings *n) 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 @@ device_init_settings(struct device *dev, struct blob_attr **tb) 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; @@ -901,6 +908,8 @@ device_dump_status(struct blob_buf *b, struct device *dev) 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) diff --git a/device.h b/device.h index a6c131a..5a85f48 100644 --- a/device.h +++ b/device.h @@ -34,6 +34,7 @@ enum { DEV_ATTR_ENABLED, DEV_ATTR_IPV6, DEV_ATTR_PROMISC, + DEV_ATTR_MULTICAST, DEV_ATTR_RPFILTER, DEV_ATTR_ACCEPTLOCAL, DEV_ATTR_IGMPVERSION, @@ -86,6 +87,7 @@ enum { 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 */ @@ -135,6 +137,7 @@ struct device_settings { uint8_t macaddr[6]; bool ipv6; bool promisc; + bool multicast; unsigned int rpfilter; bool acceptlocal; unsigned int igmpversion; diff --git a/system-linux.c b/system-linux.c index d3bb64d..ddde843 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1091,6 +1091,11 @@ system_if_get_settings(struct device *dev, struct device_settings *s) 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 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned !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); -- 2.6.3 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel