From 85c07855f533db2972144ea2b7ebd086388dd2ce Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 5 Dec 2023 15:57:08 +0100 Subject: [PATCH 32/68] netifd: fix vlan-awareness bug Signed-off-by: John Crispin --- .../netifd/patches/004-vlan-awareness.patch | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 package/network/config/netifd/patches/004-vlan-awareness.patch diff --git a/package/network/config/netifd/patches/004-vlan-awareness.patch b/package/network/config/netifd/patches/004-vlan-awareness.patch new file mode 100644 index 0000000000..00d43957e1 --- /dev/null +++ b/package/network/config/netifd/patches/004-vlan-awareness.patch @@ -0,0 +1,83 @@ +diff --git a/bridge.c b/bridge.c +index c931923e3299..2128ec75a0fb 100644 +--- a/bridge.c ++++ b/bridge.c +@@ -223,7 +223,9 @@ bridge_set_member_vlan(struct bridge_member *bm, struct bridge_vlan *vlan, bool + if (!port) + return; + +- if (bridge_member_vlan_is_pvid(bm, port)) ++ if (!add && bm->pvid == vlan->vid) ++ bm->pvid = 0; ++ else if (add && bridge_member_vlan_is_pvid(bm, port)) + bm->pvid = vlan->vid; + + __bridge_set_member_vlan(bm, vlan, port, add); +@@ -275,12 +277,12 @@ bridge_set_vlan_state(struct bridge_state *bst, struct bridge_vlan *vlan, bool a + { + struct bridge_member *bm; + struct bridge_vlan *vlan2; ++ bool clear_pvid = false; + + bridge_set_local_vlan(bst, vlan, add); + + vlist_for_each_element(&bst->members, bm, node) { + struct bridge_vlan_port *port; +- int new_pvid = -1; + + port = bridge_find_vlan_member_port(bm, vlan); + if (!port) +@@ -293,17 +295,18 @@ bridge_set_vlan_state(struct bridge_state *bst, struct bridge_vlan *vlan, bool a + vlan2 = bridge_recalc_member_pvid(bm); + if (vlan2 && vlan2->vid != vlan->vid) { + bridge_set_member_vlan(bm, vlan2, false); ++ bm->pvid = vlan2->vid; + bridge_set_member_vlan(bm, vlan2, true); ++ } else if (!vlan2) { ++ clear_pvid = true; + } +- new_pvid = vlan2 ? vlan2->vid : 0; + } + +- if (!bm->present) +- continue; ++ if (bm->present) ++ __bridge_set_member_vlan(bm, vlan, port, add); + +- __bridge_set_member_vlan(bm, vlan, port, add); +- if (new_pvid >= 0) +- bm->pvid = new_pvid; ++ if (clear_pvid) ++ bm->pvid = 0; + } + } + +@@ -1369,14 +1372,14 @@ bridge_vlan_update(struct vlist_tree *tree, struct vlist_node *node_new, + struct bridge_state *bst = container_of(tree, struct bridge_state, dev.vlans); + struct bridge_vlan *vlan_new = NULL, *vlan_old = NULL; + +- if (!bst->has_vlans || !bst->active) +- goto out; +- + if (node_old) + vlan_old = container_of(node_old, struct bridge_vlan, node); + if (node_new) + vlan_new = container_of(node_new, struct bridge_vlan, node); + ++ if (!bst->has_vlans || !bst->active) ++ goto out; ++ + if (node_new && node_old && bridge_vlan_equal(vlan_old, vlan_new)) { + list_splice_init(&vlan_old->hotplug_ports, &vlan_new->hotplug_ports); + goto out; +@@ -1391,9 +1394,8 @@ bridge_vlan_update(struct vlist_tree *tree, struct vlist_node *node_new, + if (node_new) + vlan_new->pending = true; + +- bst->dev.config_pending = true; +- + out: ++ bst->dev.config_pending = true; + bridge_vlan_free(vlan_old); + } + -- 2.34.1