Skip to content

Commit cc1d5bd

Browse files
ffainellidavem330
authored andcommitted
net: dsa: Deny enslaving VLAN devices into VLAN aware bridge
VLAN devices on top of a DSA network device which is already part of a bridge and with said bridge being VLAN aware should not be allowed to be enslaved into that bridge. For one, this duplicates functionality offered by the VLAN aware bridge which supports tagged and untagged VLAN frames processing and it would make things needlessly complex to e.g.: propagate FDB/MDB accordingly. Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6d20fae commit cc1d5bd

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

net/dsa/slave.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,16 +1408,49 @@ static int dsa_slave_changeupper(struct net_device *dev,
14081408
return err;
14091409
}
14101410

1411+
static int dsa_slave_upper_vlan_check(struct net_device *dev,
1412+
struct netdev_notifier_changeupper_info *
1413+
info)
1414+
{
1415+
struct netlink_ext_ack *ext_ack;
1416+
struct net_device *slave;
1417+
struct dsa_port *dp;
1418+
1419+
ext_ack = netdev_notifier_info_to_extack(&info->info);
1420+
1421+
if (!is_vlan_dev(dev))
1422+
return NOTIFY_DONE;
1423+
1424+
slave = vlan_dev_real_dev(dev);
1425+
if (!dsa_slave_dev_check(slave))
1426+
return NOTIFY_DONE;
1427+
1428+
dp = dsa_slave_to_port(slave);
1429+
if (!dp->bridge_dev)
1430+
return NOTIFY_DONE;
1431+
1432+
/* Deny enslaving a VLAN device into a VLAN-aware bridge */
1433+
if (br_vlan_enabled(dp->bridge_dev) &&
1434+
netif_is_bridge_master(info->upper_dev) && info->linking) {
1435+
NL_SET_ERR_MSG_MOD(ext_ack,
1436+
"Cannot enslave VLAN device into VLAN aware bridge");
1437+
return notifier_from_errno(-EINVAL);
1438+
}
1439+
1440+
return NOTIFY_DONE;
1441+
}
1442+
14111443
static int dsa_slave_netdevice_event(struct notifier_block *nb,
14121444
unsigned long event, void *ptr)
14131445
{
14141446
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
14151447

1416-
if (!dsa_slave_dev_check(dev))
1417-
return NOTIFY_DONE;
1448+
if (event == NETDEV_CHANGEUPPER) {
1449+
if (!dsa_slave_dev_check(dev))
1450+
return dsa_slave_upper_vlan_check(dev, ptr);
14181451

1419-
if (event == NETDEV_CHANGEUPPER)
14201452
return dsa_slave_changeupper(dev, ptr);
1453+
}
14211454

14221455
return NOTIFY_DONE;
14231456
}

0 commit comments

Comments
 (0)