[PATCH-22.03] netifd: bridge: add support option for untagged

LiXiong Liu lxliu at ikuai8.com
Thu Sep 8 19:20:13 PDT 2022


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