Skip to content

Commit 4ddcaf1

Browse files
linuswkuba-moo
authored andcommitted
net: dsa: rtl8366: Properly clear member config
When removing a port from a VLAN we are just erasing the member config for the VLAN, which is wrong: other ports can be using it. Just mask off the port and only zero out the rest of the member config once ports using of the VLAN are removed from it. Reported-by: Florian Fainelli <[email protected]> Fixes: d865295 ("net: dsa: realtek-smi: Add Realtek SMI driver") Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d7739b0 commit 4ddcaf1

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

drivers/net/dsa/rtl8366.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,19 @@ int rtl8366_vlan_del(struct dsa_switch *ds, int port,
452452
return ret;
453453

454454
if (vid == vlanmc.vid) {
455-
/* clear VLAN member configurations */
456-
vlanmc.vid = 0;
457-
vlanmc.priority = 0;
458-
vlanmc.member = 0;
459-
vlanmc.untag = 0;
460-
vlanmc.fid = 0;
461-
455+
/* Remove this port from the VLAN */
456+
vlanmc.member &= ~BIT(port);
457+
vlanmc.untag &= ~BIT(port);
458+
/*
459+
* If no ports are members of this VLAN
460+
* anymore then clear the whole member
461+
* config so it can be reused.
462+
*/
463+
if (!vlanmc.member && vlanmc.untag) {
464+
vlanmc.vid = 0;
465+
vlanmc.priority = 0;
466+
vlanmc.fid = 0;
467+
}
462468
ret = smi->ops->set_vlan_mc(smi, i, &vlanmc);
463469
if (ret) {
464470
dev_err(smi->dev,

0 commit comments

Comments
 (0)