summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2020-07-12 18:50:18 +0200
committerFelix Fietkau <nbd@nbd.name>2020-07-18 17:41:57 +0200
commitccd9ddc10219ae90784411c7774a0d56dbced59b (patch)
treed95f8f41e6107c8e48f252afeea67b5696fee5e2
parentcb0c07b48fdd137b035fee065e1db1aa7e6c0b1a (diff)
bridge: add support for turning on vlan_filtering
If we want a bridge to be vlan aware we need to be able to turn on filtering. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--bridge.c6
-rw-r--r--system-dummy.c3
-rw-r--r--system-linux.c6
-rw-r--r--system.h2
4 files changed, 16 insertions, 1 deletions
diff --git a/bridge.c b/bridge.c
index c1f4ffa..e4ec597 100644
--- a/bridge.c
+++ b/bridge.c
@@ -38,6 +38,7 @@ enum {
BRIDGE_ATTR_QUERY_INTERVAL,
BRIDGE_ATTR_QUERY_RESPONSE_INTERVAL,
BRIDGE_ATTR_LAST_MEMBER_INTERVAL,
+ BRIDGE_ATTR_VLAN_FILTERING,
__BRIDGE_ATTR_MAX
};
@@ -57,6 +58,7 @@ static const struct blobmsg_policy bridge_attrs[__BRIDGE_ATTR_MAX] = {
[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 },
+ [BRIDGE_ATTR_VLAN_FILTERING] = { "vlan_filtering", BLOBMSG_TYPE_BOOL },
};
static const struct uci_blob_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = {
@@ -577,6 +579,7 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb)
cfg->hash_max = 512;
cfg->bridge_empty = false;
cfg->priority = 0x7FFF;
+ cfg->vlan_filtering = false;
if ((cur = tb[BRIDGE_ATTR_STP]))
cfg->stp = blobmsg_get_bool(cur);
@@ -633,6 +636,9 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb)
if ((cur = tb[BRIDGE_ATTR_BRIDGE_EMPTY]))
cfg->bridge_empty = blobmsg_get_bool(cur);
+
+ if ((cur = tb[BRIDGE_ATTR_VLAN_FILTERING]))
+ cfg->vlan_filtering = blobmsg_get_bool(cur);
}
static enum dev_change_type
diff --git a/system-dummy.c b/system-dummy.c
index 080e5a2..a4bf05d 100644
--- a/system-dummy.c
+++ b/system-dummy.c
@@ -32,7 +32,8 @@ int system_init(void)
int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
{
- D(SYSTEM, "brctl addbr %s\n", bridge->ifname);
+ D(SYSTEM, "brctl addbr %s vlan_filtering=%d\n",
+ bridge->ifname, cfg->vlan_filtering);
return 0;
}
diff --git a/system-linux.c b/system-linux.c
index 3b09bbb..97b38e7 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -470,6 +470,11 @@ static void system_set_sendredirects(struct device *dev, const char *val)
system_set_dev_sysctl("/proc/sys/net/ipv4/conf/%s/send_redirects", dev->ifname, val);
}
+static void system_bridge_set_vlan_filtering(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/sys/devices/virtual/net/%s/bridge/vlan_filtering", dev->ifname, val);
+}
+
static int system_get_sysctl(const char *path, char *buf, const size_t buf_sz)
{
int fd = -1, ret = -1;
@@ -1170,6 +1175,7 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
system_bridge_set_forward_delay(bridge, buf);
system_bridge_conf_multicast(bridge, cfg, buf, sizeof(buf));
+ system_bridge_set_vlan_filtering(bridge, cfg->vlan_filtering ? "1" : "0");
snprintf(buf, sizeof(buf), "%d", cfg->priority);
system_bridge_set_priority(bridge, buf);
diff --git a/system.h b/system.h
index 252fd92..258b1af 100644
--- a/system.h
+++ b/system.h
@@ -127,6 +127,8 @@ struct bridge_config {
int hello_time;
int max_age;
int hash_max;
+
+ bool vlan_filtering;
};
enum macvlan_opt {