Skip to content

Commit 12ecf35

Browse files
KanjiMonstersmb49
authored andcommitted
net: dsa: b53: fix clearing PVID of a port
BugLink: https://bugs.launchpad.net/bugs/2115252 [ Upstream commit f480851 ] Currently the PVID of ports are only set when adding/updating VLANs with PVID set or removing VLANs, but not when clearing the PVID flag of a VLAN. E.g. the following flow $ ip link add br0 type bridge vlan_filtering 1 $ ip link set sw1p1 master bridge $ bridge vlan add dev sw1p1 vid 10 pvid untagged $ bridge vlan add dev sw1p1 vid 10 untagged Would keep the PVID set as 10, despite the flag being cleared. Fix this by checking if we need to unset the PVID on vlan updates. Fixes: a2482d2 ("net: dsa: b53: Plug in VLAN support") Signed-off-by: Jonas Gorski <[email protected]> Tested-by: Florian Fainelli <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 4d37f28 commit 12ecf35

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,12 +1537,21 @@ int b53_vlan_add(struct dsa_switch *ds, int port,
15371537
bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
15381538
bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
15391539
struct b53_vlan *vl;
1540+
u16 old_pvid, new_pvid;
15401541
int err;
15411542

15421543
err = b53_vlan_prepare(ds, port, vlan);
15431544
if (err)
15441545
return err;
15451546

1547+
b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), &old_pvid);
1548+
if (pvid)
1549+
new_pvid = vlan->vid;
1550+
else if (!pvid && vlan->vid == old_pvid)
1551+
new_pvid = b53_default_pvid(dev);
1552+
else
1553+
new_pvid = old_pvid;
1554+
15461555
vl = &dev->vlans[vlan->vid];
15471556

15481557
b53_get_vlan_entry(dev, vlan->vid, vl);
@@ -1562,9 +1571,9 @@ int b53_vlan_add(struct dsa_switch *ds, int port,
15621571
b53_set_vlan_entry(dev, vlan->vid, vl);
15631572
b53_fast_age_vlan(dev, vlan->vid);
15641573

1565-
if (pvid && !dsa_is_cpu_port(ds, port)) {
1574+
if (!dsa_is_cpu_port(ds, port) && new_pvid != old_pvid) {
15661575
b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port),
1567-
vlan->vid);
1576+
new_pvid);
15681577
b53_fast_age_vlan(dev, vlan->vid);
15691578
}
15701579

0 commit comments

Comments
 (0)