]> git.baikalelectronics.ru Git - kernel.git/commit
net/mlx5e: Protect encap route dev from concurrent release
authorVlad Buslov <vladbu@nvidia.com>
Mon, 31 Aug 2020 13:17:29 +0000 (16:17 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Thu, 5 Nov 2020 20:17:05 +0000 (12:17 -0800)
commit4cfbdf4fb1df3385ef5817cbae6f7ccff61f82c5
treedc75b4406c800eb11ff1e55bb1821e419a0ceb72
parent18c1ff7a674e0cbfbeb1e181fbc5fe23399d0685
net/mlx5e: Protect encap route dev from concurrent release

In functions mlx5e_route_lookup_ipv{4|6}() route_dev can be arbitrary net
device and not necessary mlx5 eswitch port representor. As such, in order
to ensure that route_dev is not destroyed concurrent the code needs either
explicitly take reference to the device before releasing reference to
rtable instance or ensure that caller holds rtnl lock. First approach is
chosen as a fix since rtnl lock dependency was intentionally removed from
mlx5 TC layer.

To prevent unprotected usage of route_dev in encap code take a reference to
the device before releasing rt. Don't save direct pointer to the device in
mlx5_encap_entry structure and use ifindex instead. Modify users of
route_dev pointer to properly obtain the net device instance from its
ifindex.

Fixes: 3b5494b5d81a ("net/mlx5e: Protect encap hash table with mutex")
Fixes: 0616c258ffd3 ("net/mlx5e: Update hw flows when encap source mac changed")
Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h