Skip to content

Commit b2bc58d

Browse files
vladimirolteandavem330
authored andcommitted
net: bridge: vlan: check early for lack of BRENTRY flag in br_vlan_add_existing
When a VLAN is added to a bridge port, a master VLAN gets created on the bridge for context, but it doesn't have the BRENTRY flag. Then, when the same VLAN is added to the bridge itself, that enters through the br_vlan_add_existing() code path and gains the BRENTRY flag, thus it becomes "existing". It seems natural to check for this condition early, because the current code flow is to notify switchdev of the addition of a VLAN that isn't a brentry, just to delete it immediately afterwards. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b0471c2 commit b2bc58d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

net/bridge/br_vlan.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -679,16 +679,15 @@ static int br_vlan_add_existing(struct net_bridge *br,
679679
{
680680
int err;
681681

682+
/* Trying to change flags of non-existent bridge vlan */
683+
if (!br_vlan_is_brentry(vlan) && !(flags & BRIDGE_VLAN_INFO_BRENTRY))
684+
return -EINVAL;
685+
682686
err = br_switchdev_port_vlan_add(br->dev, vlan->vid, flags, extack);
683687
if (err && err != -EOPNOTSUPP)
684688
return err;
685689

686690
if (!br_vlan_is_brentry(vlan)) {
687-
/* Trying to change flags of non-existent bridge vlan */
688-
if (!(flags & BRIDGE_VLAN_INFO_BRENTRY)) {
689-
err = -EINVAL;
690-
goto err_flags;
691-
}
692691
/* It was only kept for port vlans, now make it real */
693692
err = br_fdb_add_local(br, NULL, br->dev->dev_addr, vlan->vid);
694693
if (err) {
@@ -709,7 +708,6 @@ static int br_vlan_add_existing(struct net_bridge *br,
709708
return 0;
710709

711710
err_fdb_insert:
712-
err_flags:
713711
br_switchdev_port_vlan_del(br->dev, vlan->vid);
714712
return err;
715713
}

0 commit comments

Comments
 (0)