mlxsw: spectrum_switchdev: Add error path in mlxsw_sp_port_mc_disabled_set()
authorAmit Cohen <amcohen@nvidia.com>
Tue, 21 Jun 2022 08:33:37 +0000 (11:33 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Jun 2022 11:56:57 +0000 (12:56 +0100)
The above mentioned function just returns an error in case that
mlxsw_sp_bridge_ports_flood_table_set() fails. That means that the previous
configurations are not cleaned.

Fix it by adding error path to clean the configurations in case of error.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

index 303909b..127ebd1 100644 (file)
@@ -900,6 +900,7 @@ static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port,
                                         struct net_device *orig_dev,
                                         bool mc_disabled)
 {
+       enum mlxsw_sp_flood_type packet_type = MLXSW_SP_FLOOD_TYPE_MC;
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
        struct mlxsw_sp_bridge_device *bridge_device;
        struct mlxsw_sp_bridge_port *bridge_port;
@@ -919,17 +920,29 @@ static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port,
        mlxsw_sp_bridge_mdb_mc_enable_sync(mlxsw_sp, bridge_device);
 
        list_for_each_entry(bridge_port, &bridge_device->ports_list, list) {
-               enum mlxsw_sp_flood_type packet_type = MLXSW_SP_FLOOD_TYPE_MC;
                bool member = mlxsw_sp_mc_flood(bridge_port);
 
                err = mlxsw_sp_bridge_ports_flood_table_set(bridge_port,
                                                            packet_type,
                                                            member);
                if (err)
-                       return err;
+                       goto err_flood_table_set;
        }
 
        return 0;
+
+err_flood_table_set:
+       list_for_each_entry_continue_reverse(bridge_port,
+                                            &bridge_device->ports_list, list) {
+               bool member = mlxsw_sp_mc_flood(bridge_port);
+
+               mlxsw_sp_bridge_ports_flood_table_set(bridge_port, packet_type,
+                                                     !member);
+       }
+
+       bridge_device->multicast_enabled = mc_disabled;
+       mlxsw_sp_bridge_mdb_mc_enable_sync(mlxsw_sp, bridge_device);
+       return err;
 }
 
 static int mlxsw_sp_smid_router_port_set(struct mlxsw_sp *mlxsw_sp,