]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
mlxsw: spectrum: Don't assume upper device's type
authorIdo Schimmel <idosch@mellanox.com>
Fri, 10 Mar 2017 07:53:35 +0000 (08:53 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 10 Mar 2017 17:36:06 +0000 (09:36 -0800)
When an upper device is configured on top of a vPort we make sure it's a
bridge master during PRECHANGEUPPER and fail otherwise. Therefore, when
CHANGEUPPER is later received we don't bother checking the upper's type.

Make the code more extendable in preparation for VRF uppers, by checking
the upper's type.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c

index c27c8f83f7ace3b2e1cc347c2cba5ec3733601c8..b8238ed9ae7354f388e643c9295ed7543e7f8e3f 100644 (file)
@@ -4818,6 +4818,8 @@ static int mlxsw_sp_netdevice_vport_event(struct net_device *dev,
        int err = 0;
 
        mlxsw_sp_vport = mlxsw_sp_port_vport_find(mlxsw_sp_port, vid);
+       if (!mlxsw_sp_vport)
+               return 0;
 
        switch (event) {
        case NETDEV_PRECHANGEUPPER:
@@ -4835,16 +4837,17 @@ static int mlxsw_sp_netdevice_vport_event(struct net_device *dev,
                break;
        case NETDEV_CHANGEUPPER:
                upper_dev = info->upper_dev;
-               if (info->linking) {
-                       if (WARN_ON(!mlxsw_sp_vport))
-                               return -EINVAL;
-                       err = mlxsw_sp_vport_bridge_join(mlxsw_sp_vport,
-                                                        upper_dev);
+               if (netif_is_bridge_master(upper_dev)) {
+                       if (info->linking)
+                               err = mlxsw_sp_vport_bridge_join(mlxsw_sp_vport,
+                                                                upper_dev);
+                       else
+                               mlxsw_sp_vport_bridge_leave(mlxsw_sp_vport);
                } else {
-                       if (!mlxsw_sp_vport)
-                               return 0;
-                       mlxsw_sp_vport_bridge_leave(mlxsw_sp_vport);
+                       err = -EINVAL;
+                       WARN_ON(1);
                }
+               break;
        }
 
        return err;