[OpenWrt-Devel] [PATCH netifd] bridge: allow setting hash_max value

Linus Lüssing linus.luessing at c0d3.blue
Tue May 26 15:49:11 EDT 2015


If the number of entries in the MDB exceeds hash_max then the
multicast snooping capabilities of the bridge are disabled
automatically.

The default value for hash_max is 512 which is already exceeded by some
wireless community mesh networks. They need to be able to set a higher
value.

Signed-off-by: Linus Lüssing <linus.luessing at c0d3.blue>
---
 bridge.c       |    6 ++++++
 system-linux.c |    5 +++++
 system.h       |    1 +
 3 files changed, 12 insertions(+)

diff --git a/bridge.c b/bridge.c
index fd553dc..9da5314 100644
--- a/bridge.c
+++ b/bridge.c
@@ -33,6 +33,7 @@ enum {
 	BRIDGE_ATTR_MAX_AGE,
 	BRIDGE_ATTR_BRIDGE_EMPTY,
 	BRIDGE_ATTR_MULTICAST_QUERIER,
+	BRIDGE_ATTR_HASH_MAX,
 	__BRIDGE_ATTR_MAX
 };
 
@@ -47,6 +48,7 @@ static const struct blobmsg_policy bridge_attrs[__BRIDGE_ATTR_MAX] = {
 	[BRIDGE_ATTR_IGMP_SNOOP] = { "igmp_snooping", BLOBMSG_TYPE_BOOL },
 	[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 },
 };
 
 static const struct uci_blob_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = {
@@ -551,6 +553,7 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb)
 	cfg->forward_delay = 2;
 	cfg->igmp_snoop = true;
 	cfg->multicast_querier = true;
+	cfg->hash_max = 512;
 	cfg->bridge_empty = false;
 	cfg->priority = 0x7FFF;
 
@@ -569,6 +572,9 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb)
 	if ((cur = tb[BRIDGE_ATTR_MULTICAST_QUERIER]))
 		cfg->multicast_querier = blobmsg_get_bool(cur);
 
+	if ((cur = tb[BRIDGE_ATTR_HASH_MAX]))
+		cfg->hash_max = blobmsg_get_u32(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 08b6757..061617d 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -785,6 +785,7 @@ sec_to_jiffies(int val)
 
 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)
@@ -804,6 +805,10 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
 	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);
+	system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/hash_max",
+		bridge->ifname, buf);
+
 	args[0] = BRCTL_SET_BRIDGE_PRIORITY;
 	args[1] = cfg->priority;
 	system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);
diff --git a/system.h b/system.h
index 94e0dd9..0a8d644 100644
--- a/system.h
+++ b/system.h
@@ -58,6 +58,7 @@ struct bridge_config {
 	int ageing_time;
 	int hello_time;
 	int max_age;
+	int hash_max;
 };
 
 enum macvlan_opt {
-- 
1.7.10.4
_______________________________________________
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