BRIDGE_ATTR_BRIDGE_EMPTY,
BRIDGE_ATTR_MULTICAST_QUERIER,
BRIDGE_ATTR_HASH_MAX,
+ BRIDGE_ATTR_ROBUSTNESS,
+ BRIDGE_ATTR_QUERY_INTERVAL,
+ BRIDGE_ATTR_QUERY_RESPONSE_INTERVAL,
+ BRIDGE_ATTR_LAST_MEMBER_INTERVAL,
__BRIDGE_ATTR_MAX
};
[BRIDGE_ATTR_BRIDGE_EMPTY] = { "bridge_empty", BLOBMSG_TYPE_BOOL },
[BRIDGE_ATTR_MULTICAST_QUERIER] = { "multicast_querier", BLOBMSG_TYPE_BOOL },
[BRIDGE_ATTR_HASH_MAX] = { "hash_max", BLOBMSG_TYPE_INT32 },
+ [BRIDGE_ATTR_ROBUSTNESS] = { "robustness", BLOBMSG_TYPE_INT32 },
+ [BRIDGE_ATTR_QUERY_INTERVAL] = { "query_interval", BLOBMSG_TYPE_INT32 },
+ [BRIDGE_ATTR_QUERY_RESPONSE_INTERVAL] = { "query_response_interval", BLOBMSG_TYPE_INT32 },
+ [BRIDGE_ATTR_LAST_MEMBER_INTERVAL] = { "last_member_interval", BLOBMSG_TYPE_INT32 },
};
static const struct uci_blob_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = {
cfg->forward_delay = 2;
cfg->igmp_snoop = true;
cfg->multicast_querier = true;
+ cfg->robustness = 2;
+ cfg->query_interval = 12500;
+ cfg->query_response_interval = 1000;
+ cfg->last_member_interval = 100;
cfg->hash_max = 512;
cfg->bridge_empty = false;
cfg->priority = 0x7FFF;
if ((cur = tb[BRIDGE_ATTR_HASH_MAX]))
cfg->hash_max = blobmsg_get_u32(cur);
+ if ((cur = tb[BRIDGE_ATTR_ROBUSTNESS])) {
+ cfg->robustness = blobmsg_get_u32(cur);
+ cfg->flags |= BRIDGE_OPT_ROBUSTNESS;
+ }
+
+ if ((cur = tb[BRIDGE_ATTR_QUERY_INTERVAL])) {
+ cfg->query_interval = blobmsg_get_u32(cur);
+ cfg->flags |= BRIDGE_OPT_QUERY_INTERVAL;
+ }
+
+ if ((cur = tb[BRIDGE_ATTR_QUERY_RESPONSE_INTERVAL])) {
+ cfg->query_response_interval = blobmsg_get_u32(cur);
+ cfg->flags |= BRIDGE_OPT_QUERY_RESPONSE_INTERVAL;
+ }
+
+ if ((cur = tb[BRIDGE_ATTR_LAST_MEMBER_INTERVAL])) {
+ cfg->last_member_interval = blobmsg_get_u32(cur);
+ cfg->flags |= BRIDGE_OPT_LAST_MEMBER_INTERVAL;
+ }
+
if ((cur = tb[BRIDGE_ATTR_AGEING_TIME])) {
cfg->ageing_time = blobmsg_get_u32(cur);
cfg->flags |= BRIDGE_OPT_AGEING_TIME;
dev->ifname, val);
}
+static void system_bridge_set_robustness(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_startup_query_count",
+ dev->ifname, val);
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_last_member_count",
+ dev->ifname, val);
+}
+
+static void system_bridge_set_query_interval(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_query_interval",
+ dev->ifname, val);
+}
+
+static void system_bridge_set_query_response_interval(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_query_response_interval",
+ dev->ifname, val);
+}
+
+static void system_bridge_set_last_member_interval(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_last_member_interval",
+ dev->ifname, val);
+}
+
+static void system_bridge_set_membership_interval(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_membership_interval",
+ dev->ifname, val);
+}
+
+static void system_bridge_set_other_querier_timeout(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_querier_interval",
+ dev->ifname, val);
+}
+
+static void system_bridge_set_startup_query_interval(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_startup_query_interval",
+ dev->ifname, val);
+}
+
static int system_get_sysctl(const char *path, char *buf, const size_t buf_sz)
{
int fd = -1, ret = -1;
return (unsigned long) val * 100;
}
-int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
+static void system_bridge_conf_multicast_deps(struct device *bridge,
+ struct bridge_config *cfg,
+ char *buf,
+ int buf_len)
{
- char buf[64];
- unsigned long args[4] = {};
+ int val;
- if (ioctl(sock_ioctl, SIOCBRADDBR, bridge->ifname) < 0)
- return -1;
+ if (cfg->flags & BRIDGE_OPT_ROBUSTNESS ||
+ cfg->flags & BRIDGE_OPT_QUERY_INTERVAL ||
+ cfg->flags & BRIDGE_OPT_QUERY_RESPONSE_INTERVAL) {
+ val = cfg->robustness * cfg->query_interval +
+ cfg->query_response_interval;
- args[0] = BRCTL_SET_BRIDGE_STP_STATE;
- args[1] = !!cfg->stp;
- system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+ snprintf(buf, buf_len, "%i", val);
+ system_bridge_set_membership_interval(bridge, buf);
- args[0] = BRCTL_SET_BRIDGE_FORWARD_DELAY;
- args[1] = sec_to_jiffies(cfg->forward_delay);
- system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+ val = cfg->robustness * cfg->query_interval +
+ cfg->query_response_interval / 2;
+
+ snprintf(buf, buf_len, "%i", val);
+ system_bridge_set_other_querier_timeout(bridge, buf);
+ }
+ if (cfg->flags & BRIDGE_OPT_QUERY_INTERVAL) {
+ val = cfg->query_interval / 4;
+
+ snprintf(buf, buf_len, "%i", val);
+ system_bridge_set_startup_query_interval(bridge, buf);
+ }
+}
+
+static void system_bridge_conf_multicast(struct device *bridge,
+ struct bridge_config *cfg,
+ char *buf,
+ int buf_len)
+{
system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_snooping",
bridge->ifname, cfg->igmp_snoop ? "1" : "0");
system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/multicast_querier",
bridge->ifname, cfg->multicast_querier ? "1" : "0");
- snprintf(buf, sizeof(buf), "%i", cfg->hash_max);
+ snprintf(buf, buf_len, "%i", cfg->hash_max);
system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/hash_max",
bridge->ifname, buf);
if (bridge->settings.flags & DEV_OPT_MULTICAST_ROUTER) {
- snprintf(buf, sizeof(buf), "%i", bridge->settings.multicast_router);
+ snprintf(buf, buf_len, "%i", bridge->settings.multicast_router);
system_bridge_set_multicast_router(bridge, buf, true);
}
+ if (cfg->flags & BRIDGE_OPT_ROBUSTNESS) {
+ snprintf(buf, buf_len, "%i", cfg->robustness);
+ system_bridge_set_robustness(bridge, buf);
+ }
+
+ if (cfg->flags & BRIDGE_OPT_QUERY_INTERVAL) {
+ snprintf(buf, buf_len, "%i", cfg->query_interval);
+ system_bridge_set_query_interval(bridge, buf);
+ }
+
+ if (cfg->flags & BRIDGE_OPT_QUERY_RESPONSE_INTERVAL) {
+ snprintf(buf, buf_len, "%i", cfg->query_response_interval);
+ system_bridge_set_query_response_interval(bridge, buf);
+ }
+
+ if (cfg->flags & BRIDGE_OPT_LAST_MEMBER_INTERVAL) {
+ snprintf(buf, buf_len, "%i", cfg->last_member_interval);
+ system_bridge_set_last_member_interval(bridge, buf);
+ }
+
+ system_bridge_conf_multicast_deps(bridge, cfg, buf, buf_len);
+}
+
+int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
+{
+ char buf[64];
+ unsigned long args[4] = {};
+
+ if (ioctl(sock_ioctl, SIOCBRADDBR, bridge->ifname) < 0)
+ return -1;
+
+ args[0] = BRCTL_SET_BRIDGE_STP_STATE;
+ args[1] = !!cfg->stp;
+ system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+
+ args[0] = BRCTL_SET_BRIDGE_FORWARD_DELAY;
+ args[1] = sec_to_jiffies(cfg->forward_delay);
+ system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
+
+ system_bridge_conf_multicast(bridge, cfg, buf, sizeof(buf));
+
args[0] = BRCTL_SET_BRIDGE_PRIORITY;
args[1] = cfg->priority;
system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);