From: Felix Fietkau Date: Tue, 18 Oct 2011 23:00:32 +0000 (+0200) Subject: set the igmp snooping option for bridges X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=8c6361136d8c976407b03252b6cfadecb441b37a;p=project%2Fnetifd.git set the igmp snooping option for bridges --- diff --git a/bridge.c b/bridge.c index fe4b477..1adabb9 100644 --- a/bridge.c +++ b/bridge.c @@ -13,6 +13,7 @@ enum { BRIDGE_ATTR_IFNAME, BRIDGE_ATTR_STP, BRIDGE_ATTR_FORWARD_DELAY, + BRIDGE_ATTR_IGMP_SNOOP, BRIDGE_ATTR_AGEING_TIME, BRIDGE_ATTR_HELLO_TIME, BRIDGE_ATTR_MAX_AGE, @@ -26,6 +27,7 @@ static const struct blobmsg_policy bridge_attrs[__BRIDGE_ATTR_MAX] = { [BRIDGE_ATTR_AGEING_TIME] = { "ageing_time", BLOBMSG_TYPE_INT32 }, [BRIDGE_ATTR_HELLO_TIME] = { "hello_time", BLOBMSG_TYPE_INT32 }, [BRIDGE_ATTR_MAX_AGE] = { "max_age", BLOBMSG_TYPE_INT32 }, + [BRIDGE_ATTR_IGMP_SNOOP] = { "igmp_snooping", BLOBMSG_TYPE_BOOL }, }; static const union config_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = { @@ -340,6 +342,7 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb) /* defaults */ cfg->stp = true; cfg->forward_delay = 1; + cfg->igmp_snoop = true; if ((cur = tb[BRIDGE_ATTR_STP])) cfg->stp = blobmsg_get_bool(cur); @@ -347,6 +350,9 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb) if ((cur = tb[BRIDGE_ATTR_FORWARD_DELAY])) cfg->forward_delay = blobmsg_get_u32(cur); + if ((cur = tb[BRIDGE_ATTR_IGMP_SNOOP])) + cfg->igmp_snoop = blobmsg_get_bool(cur); + if ((cur = tb[BRIDGE_ATTR_AGEING_TIME])) { cfg->ageing_time = blobmsg_get_u32(cur); cfg->flags |= BRIDGE_OPT_AGEING_TIME; diff --git a/system-linux.c b/system-linux.c index 2425445..3d6230d 100644 --- a/system-linux.c +++ b/system-linux.c @@ -99,12 +99,17 @@ static void system_set_sysctl(const char *path, const char *val) close(fd); } -static void system_set_disable_ipv6(struct device *dev, const char *val) +static void system_set_dev_sysctl(const char *path, const char *device, const char *val) { char buf[256]; - snprintf(buf, sizeof(buf), "/proc/sys/net/ipv6/conf/%s/disable_ipv6", dev->ifname); - system_set_sysctl(buf, "0"); + snprintf(buf, sizeof(buf), path, val); + system_set_sysctl(buf, val); +} + +static void system_set_disable_ipv6(struct device *dev, const char *val) +{ + system_set_dev_sysctl("/proc/sys/net/ipv6/conf/%s/disable_ipv6", dev->ifname, val); } // Evaluate netlink messages @@ -411,6 +416,9 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg) args[1] = sec_to_jiffies(cfg->forward_delay); system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args); + system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_snooping", + bridge->ifname, cfg->igmp_snoop ? "1" : "0"); + if (cfg->flags & BRIDGE_OPT_AGEING_TIME) { args[0] = BRCTL_SET_AGEING_TIME; args[1] = sec_to_jiffies(cfg->ageing_time); diff --git a/system.h b/system.h index cfe7c9f..dee7137 100644 --- a/system.h +++ b/system.h @@ -16,6 +16,7 @@ enum bridge_opt { struct bridge_config { enum bridge_opt flags; bool stp; + bool igmp_snoop; int forward_delay; int ageing_time;