summaryrefslogtreecommitdiff
path: root/system-linux.c
diff options
context:
space:
mode:
authorLinus Lüssing <linus.luessing@c0d3.blue>2016-05-22 22:33:48 +0200
committerFelix Fietkau <nbd@nbd.name>2016-05-22 22:39:08 +0200
commita0e96d0bdad7e39590ffc8dcb46935f35ee55284 (patch)
treed0beb14de0ab781f5146076577308f7a00fed3d2 /system-linux.c
parent6fd6be6b7f3fc4883fdc464fcbcb2b5e8d8e8174 (diff)
downloadnetifd-a0e96d0bdad7e39590ffc8dcb46935f35ee55284.tar.gz
bridge: make learning and unicast-flood configurable per bridge port
Tuning these two options allows a more fine grained configuration of the forwarding database (fdb) of a bridge. The former allows to enable or disable the learning of the presence of MAC addresses behind a bridge port. (default: enabled on all ports) The latter allows to tune the behaviour in case a destination MAC address of a frame is unknown to the fdb, like only flooding on specific ports or not flooding on any port. (default: flood on all ports, except incoming) This can be useful to create a dumb hub, for instance for monitoring purposes. Or in larger layer 2 mesh networks to avoid keeping redundant databases (e.g. with the batman-adv translation table). Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/system-linux.c b/system-linux.c
index 351a994..621f99b 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -372,6 +372,16 @@ static void system_bridge_set_startup_query_interval(struct device *dev, const c
dev->ifname, val);
}
+static void system_bridge_set_learning(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/class/net/%s/brport/learning", dev->ifname, val);
+}
+
+static void system_bridge_set_unicast_flood(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/class/net/%s/brport/unicast_flood", dev->ifname, val);
+}
+
static int system_get_sysctl(const char *path, char *buf, const size_t buf_sz)
{
int fd = -1, ret = -1;
@@ -648,6 +658,14 @@ int system_bridge_addif(struct device *bridge, struct device *dev)
system_bridge_set_multicast_router(dev, buf, false);
}
+ if (dev->settings.flags & DEV_OPT_LEARNING &&
+ !dev->settings.learning)
+ system_bridge_set_learning(dev, "0");
+
+ if (dev->settings.flags & DEV_OPT_UNICAST_FLOOD &&
+ !dev->settings.unicast_flood)
+ system_bridge_set_unicast_flood(dev, "0");
+
return ret;
}