Commit 59fe9b3f authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum: Sanitize port netdev upper devices

We currently only support the following upper devices for port netdevs:
1) Bridge
2) LAG (bond / team)
3) VLAN

Any other device is forbidden, so return an error.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 80bedf1a
...@@ -3034,6 +3034,10 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *dev, ...@@ -3034,6 +3034,10 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *dev,
switch (event) { switch (event) {
case NETDEV_PRECHANGEUPPER: case NETDEV_PRECHANGEUPPER:
upper_dev = info->upper_dev; upper_dev = info->upper_dev;
if (!is_vlan_dev(upper_dev) &&
!netif_is_lag_master(upper_dev) &&
!netif_is_bridge_master(upper_dev))
return -EINVAL;
if (!info->master || !info->linking) if (!info->master || !info->linking)
break; break;
/* HW limitation forbids to put ports to multiple bridges. */ /* HW limitation forbids to put ports to multiple bridges. */
...@@ -3070,6 +3074,9 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *dev, ...@@ -3070,6 +3074,9 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *dev,
else else
err = mlxsw_sp_port_lag_leave(mlxsw_sp_port, err = mlxsw_sp_port_lag_leave(mlxsw_sp_port,
upper_dev); upper_dev);
} else {
err = -EINVAL;
WARN_ON(1);
} }
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment