Skip to content

Commit 852cfee

Browse files
idoschdavem330
authored andcommitted
mlxsw: spectrum_switchdev: Release multicast groups during fini
Each multicast group (MID) stores a bitmap of ports to which a packet should be forwarded to in case an MDB entry associated with the MID is hit. Since the initial introduction of IGMP snooping in commit 3a49b4f ("mlxsw: Adding layer 2 multicast support") the driver didn't correctly free these multicast groups upon ungraceful situations such as the removal of the upper bridge device or module removal. The correct way to fix this is to associate each MID with the bridge ports member in it and then drop the reference in case the bridge port is destroyed, but this will result in a lot more code and will be fixed in net-next. For now, upon module removal, traverse the MID list and release each one. Fixes: 3a49b4f ("mlxsw: Adding layer 2 multicast support") 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>
1 parent 17b334a commit 852cfee

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,17 @@ static void mlxsw_sp_fdb_fini(struct mlxsw_sp *mlxsw_sp)
19741974

19751975
}
19761976

1977+
static void mlxsw_sp_mids_fini(struct mlxsw_sp *mlxsw_sp)
1978+
{
1979+
struct mlxsw_sp_mid *mid, *tmp;
1980+
1981+
list_for_each_entry_safe(mid, tmp, &mlxsw_sp->bridge->mids_list, list) {
1982+
list_del(&mid->list);
1983+
clear_bit(mid->mid, mlxsw_sp->bridge->mids_bitmap);
1984+
kfree(mid);
1985+
}
1986+
}
1987+
19771988
int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp)
19781989
{
19791990
struct mlxsw_sp_bridge *bridge;
@@ -1996,7 +2007,7 @@ int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp)
19962007
void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp)
19972008
{
19982009
mlxsw_sp_fdb_fini(mlxsw_sp);
1999-
WARN_ON(!list_empty(&mlxsw_sp->bridge->mids_list));
2010+
mlxsw_sp_mids_fini(mlxsw_sp);
20002011
WARN_ON(!list_empty(&mlxsw_sp->bridge->bridges_list));
20012012
kfree(mlxsw_sp->bridge);
20022013
}

0 commit comments

Comments
 (0)