summaryrefslogtreecommitdiffhomepage
path: root/system-linux.c
diff options
context:
space:
mode:
authorLinus Lüssing <linus.luessing@c0d3.blue>2015-08-23 17:19:28 +0200
committerFelix Fietkau <nbd@openwrt.org>2015-08-25 08:48:36 +0200
commite057fcb4a260c70f0271f8fdcd7140775a09791f (patch)
treedce1a7e96e814543c693f1b660de3f12ef823958 /system-linux.c
parent1488a64acb77f721fc10d90b0453d95b488460e1 (diff)
bridge: Allow setting multicast_router option
The multicast_router option of a bridge allows to control the forwarding behaviour of multicast packets independant of the listener state: * 0: Only forward if specific listener is present * 1 (default): Forward if specific listener or a multicast router was detected (currently only learned via query messages, no MRD support yet) * 2: Always forward any multicast traffic on this port Since MRD is not mandated you might end up with silent multicast routers (e.g. if your link has more than one multicast router; only one can become the selected, "noisy" querier). Here you might need a manual configuration option like the "multicast_router" option. Other scenarios where this can be useful are for instance: * Segmentation of IGMP/MLD domains together with ebtables * Dedicated bridge port for monitoring/debugging purposes 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 944245c..01500a5 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -325,6 +325,13 @@ static void system_bridge_set_hairpin_mode(struct device *dev, const char *val)
system_set_dev_sysctl("/sys/class/net/%s/brport/hairpin_mode", dev->ifname, val);
}
+static void system_bridge_set_multicast_router(struct device *dev, const char *val, bool bridge)
+{
+ system_set_dev_sysctl(bridge ? "/sys/class/net/%s/bridge/multicast_router" :
+ "/sys/class/net/%s/brport/multicast_router",
+ dev->ifname, val);
+}
+
static int system_get_sysctl(const char *path, char *buf, const size_t buf_sz)
{
int fd = -1, ret = -1;
@@ -585,6 +592,7 @@ system_bridge_set_wireless(struct device *bridge, struct device *dev)
int system_bridge_addif(struct device *bridge, struct device *dev)
{
+ char buf[64];
char *oldbr;
int ret = 0;
@@ -595,6 +603,11 @@ int system_bridge_addif(struct device *bridge, struct device *dev)
if (dev->wireless)
system_bridge_set_wireless(bridge, dev);
+ if (dev->settings.flags & DEV_OPT_MULTICAST_ROUTER) {
+ snprintf(buf, sizeof(buf), "%i", dev->settings.multicast_router);
+ system_bridge_set_multicast_router(dev, buf, false);
+ }
+
return ret;
}
@@ -845,6 +858,11 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
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);
+ system_bridge_set_multicast_router(bridge, buf, true);
+ }
+
args[0] = BRCTL_SET_BRIDGE_PRIORITY;
args[1] = cfg->priority;
system_bridge_if(bridge->ifname, NULL, SIOCDEVPRIVATE, &args);