diff mbox series

[RFC,1/9] net: dsa: deny enslaving 802.1Q upper to VLAN-aware bridge from PRECHANGEUPPER

Message ID 20200920014727.2754928-2-vladimir.oltean@nxp.com
State RFC
Delegated to: David Miller
Headers show
Series DSA with VLAN filtering and offloading masters | expand

Commit Message

Vladimir Oltean Sept. 20, 2020, 1:47 a.m. UTC
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 <vladimir.oltean@nxp.com>
---
 net/dsa/slave.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Florian Fainelli Sept. 20, 2020, 2:33 a.m. UTC | #1
On 9/19/2020 6:47 PM, Vladimir Oltean wrote:
> 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 <vladimir.oltean@nxp.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index d6616c6f643d..a00275cda05f 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1946,9 +1946,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);
 	}