net/mlx5e: Block entering switchdev mode with ns inconsistency
authorGavin Li <gavinl@nvidia.com>
Thu, 9 Feb 2023 10:48:52 +0000 (12:48 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Tue, 21 Mar 2023 21:06:31 +0000 (14:06 -0700)
commit662404b24a4c4d839839ed25e3097571f5938b9b
treeaab5a095b77cfbd83d2cb3d3b5e341dd1496406b
parentc83172b0639c8a005c0dd3b36252dc22ddd9f19c
net/mlx5e: Block entering switchdev mode with ns inconsistency

Upon entering switchdev mode, VF/SF representors are spawned in the
devlink instance's net namespace, whereas the PF net device transforms
into the uplink representor, remaining in the net namespace the PF net
device was in. Therefore, if a PF net device's namespace is different from
its parent devlink net namespace, entering switchdev mode can create an
illegal situation where all representors sharing the same core device
are NOT in the same net namespace.

To avoid this issue, block entering switchdev mode for devices whose child
netdev net namespace has diverged from the parent devlink's.

Fixes: 7768d1971de6 ("net/mlx5: E-Switch, Add control for encapsulation")
Signed-off-by: Gavin Li <gavinl@nvidia.com>
Reviewed-by: Gavi Teitz <gavi@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c