[PATCH-22.03] netifd: bridge: add support option for untagged
LiXiong Liu
lxliu at ikuai8.com
Thu Sep 8 19:25:38 PDT 2022
### swconfig & DSA VLAN Configuration Comparison
Doesn't just support Tunnk on lan5,
also need access to 192.168.1.1
so must setting untagged at br-lan
#switch-vlan
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch0'
option vlan '0'
option vid '0'
option ports '2 3 5 6'
config switch_vlan
option device 'switch0'
option vlan '100'
option vid '100'
option ports '0 1 4t'
#bridge-vlan
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'
list ports 'lan2'
list ports 'lan3'
list ports 'lan4'
list ports 'lan5'
config bridge-vlan
option device 'br-lan'
option untagged '1'
option vlan '1'
list ports 'lan3'
list ports 'lan4'
list ports 'lan5'
config bridge-vlan
option device 'br-lan'
option vlan '100'
list ports 'lan1:u*'
list ports 'lan1:u*'
list ports 'lan5:t'
#bridge vlan show
port vlan-id
lan1 100 PVID Egress Untagged
lan2 100 PVID Egress Untagged
lan3 1 PVID Egress Untagged
lan4 1 PVID Egress Untagged
lan5 1 PVID Egress Untagged
10
br-lan 1 PVID Egress Untagged
10
Signed-off-by: LiXiong Liu <lxliu at ikuai8.com>
---
.../patches/100-bridge-vlan-support-untagged.patch | 58 ++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 package/network/config/netifd/patches/100-bridge-vlan-support-untagged.patch
diff --git a/package/network/config/netifd/patches/100-bridge-vlan-support-untagged.patch b/package/network/config/netifd/patches/100-bridge-vlan-support-untagged.patch
new file mode 100644
index 0000000..02485c0
--- /dev/null
+++ b/package/network/config/netifd/patches/100-bridge-vlan-support-untagged.patch
@@ -0,0 +1,58 @@
+Support setting untagged at br-lan
+
+--- a/bridge.c 2022-09-08 21:03:06.401331415 +0800
++++ b/bridge.c 2022-09-08 21:13:19.261304451 +0800
+@@ -230,10 +230,15 @@ bridge_set_member_vlan(struct bridge_mem
+ static void
+ bridge_set_local_vlan(struct bridge_state *bst, struct bridge_vlan *vlan, bool add)
+ {
++ unsigned int vflags = BRVLAN_F_SELF;
++
+ if (!vlan->local && add)
+ return;
+
+- system_bridge_vlan(bst->dev.ifname, vlan->vid, add, BRVLAN_F_SELF);
++ if (vlan->untagged)
++ vflags |= (BRVLAN_F_PVID|BRVLAN_F_UNTAGGED);
++
++ system_bridge_vlan(bst->dev.ifname, vlan->vid, add, vflags);
+ }
+
+ static void
+--- a/config.c 2022-09-08 21:03:06.541331409 +0800
++++ b/config.c 2022-09-08 21:05:26.007372217 +0800
+@@ -311,6 +311,7 @@ config_parse_vlan(struct device *dev, st
+ BRVLAN_ATTR_LOCAL,
+ BRVLAN_ATTR_PORTS,
+ BRVLAN_ATTR_ALIAS,
++ BRVLAN_ATTR_UNTAG,
+ __BRVLAN_ATTR_MAX,
+ };
+ static const struct blobmsg_policy vlan_attrs[__BRVLAN_ATTR_MAX] = {
+@@ -318,6 +319,7 @@ config_parse_vlan(struct device *dev, st
+ [BRVLAN_ATTR_LOCAL] = { "local", BLOBMSG_TYPE_BOOL },
+ [BRVLAN_ATTR_PORTS] = { "ports", BLOBMSG_TYPE_ARRAY },
+ [BRVLAN_ATTR_ALIAS] = { "alias", BLOBMSG_TYPE_ARRAY },
++ [BRVLAN_ATTR_UNTAG] = { "untagged", BLOBMSG_TYPE_BOOL },
+ };
+ static const struct uci_blob_param_info vlan_attr_info[__BRVLAN_ATTR_MAX] = {
+ [BRVLAN_ATTR_PORTS] = { .type = BLOBMSG_TYPE_STRING },
+@@ -367,6 +369,8 @@ config_parse_vlan(struct device *dev, st
+ vlan->local = true;
+ if (tb[BRVLAN_ATTR_LOCAL])
+ vlan->local = blobmsg_get_bool(tb[BRVLAN_ATTR_LOCAL]);
++ if (tb[BRVLAN_ATTR_UNTAG])
++ vlan->untagged = blobmsg_get_bool(tb[BRVLAN_ATTR_UNTAG]);
+
+ vlan->n_ports = n_ports;
+ vlan->ports = port = (struct bridge_vlan_port *)&vlan[1];
+--- a/device.h 2022-09-08 21:03:06.401331415 +0800
++++ b/device.h 2022-09-08 21:03:14.833887415 +0800
+@@ -294,6 +294,7 @@ struct bridge_vlan {
+ uint16_t vid;
+ bool local;
+ bool pending;
++ bool untagged;
+ };
+
+ extern const struct uci_blob_param_list device_attr_list;
--
1.9.1
More information about the openwrt-devel
mailing list