From: Vladimir Oltean Date: Mon, 21 Sep 2020 00:10:23 +0000 (+0300) Subject: net: dsa: deny enslaving 802.1Q upper to VLAN-aware bridge from PRECHANGEUPPER X-Git-Tag: Ubuntu-5.10.0-12.13~1666^2~195^2~8 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=8350129930d2d74426b03d2d59d121156c204531;p=mirror_ubuntu-hirsute-kernel.git net: dsa: deny enslaving 802.1Q upper to VLAN-aware bridge from PRECHANGEUPPER There doesn't seem to be any strong technical reason for doing it this way, but we'll be adding more checks for invalid upper device configurations, and it will be easier to have them all grouped under PRECHANGEUPPER. Tested that it still works: ip link set br0 type bridge vlan_filtering 1 ip link add link swp2 name swp2.100 type vlan id 100 ip link set swp2.100 master br0 [ 20.321312] br0: port 5(swp2.100) entered blocking state [ 20.326711] br0: port 5(swp2.100) entered disabled state Error: dsa_core: Cannot enslave VLAN device into VLAN aware bridge. [ 20.346549] br0: port 5(swp2.100) entered blocking state [ 20.351957] br0: port 5(swp2.100) entered disabled state Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller --- diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 66a5268398a5..e29899431e07 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1932,9 +1932,14 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb, { struct net_device *dev = netdev_notifier_info_to_dev(ptr); - if (event == NETDEV_CHANGEUPPER) { + switch (event) { + case NETDEV_PRECHANGEUPPER: if (!dsa_slave_dev_check(dev)) return dsa_slave_upper_vlan_check(dev, ptr); + break; + case NETDEV_CHANGEUPPER: + if (!dsa_slave_dev_check(dev)) + return NOTIFY_DONE; return dsa_slave_changeupper(dev, ptr); }