[PATCH 1/3] bridge: allow turning on vlan_filtering
John Crispin
john at phrozen.org
Sun Jul 12 12:50:18 EDT 2020
If we want a bridge to be vlan aware we need to be able to turn on
filtering.
Signed-off-by: John Crispin <john at phrozen.org>
---
bridge.c | 6 ++++++
system-linux.c | 6 ++++++
system.h | 2 ++
3 files changed, 14 insertions(+)
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-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 {
--
2.25.1
More information about the openwrt-devel
mailing list