]> git.baikalelectronics.ru Git - kernel.git/commit
mlxsw: spectrum_router: Add trap adjacency entry upon first nexthop group
authorIdo Schimmel <idosch@nvidia.com>
Wed, 22 Sep 2021 07:36:41 +0000 (10:36 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Sep 2021 13:35:01 +0000 (14:35 +0100)
commit37eac584832472c986fdb5b20eb0d011182f6a8d
treeee3fabf58b63ecd9e770c3ac80ae289fffda293a
parent4a8ff6b6cbfb32b7129aab1cd10945c1b9b1cac3
mlxsw: spectrum_router: Add trap adjacency entry upon first nexthop group

In commit 09188581dfb4 ("mlxsw: Add specific trap for packets routed via
invalid nexthops"), mlxsw started allocating a new adjacency entry
during driver initialization, to trap packets routed via invalid
nexthops.

This behavior was later altered in commit 1760d6d05cac ("mlxsw:
spectrum_router: Allocate discard adjacency entry when needed") to only
allocate the entry upon the first route that requires it. The motivation
for the change is explained in the commit message.

The problem with the current behavior is that the entry shows up as a
"leak" in a new BPF resource monitoring tool [1]. This is caused by the
asymmetry of the allocation/free scheme. While the entry is allocated
upon the first route that requires it, it is only freed during
de-initialization of the driver.

Instead, track the number of active nexthop groups and allocate the
adjacency entry upon the creation of the first group. Free it when the
number of active groups reaches zero.

The next patch will convert mlxsw to start using the new entry and
remove the old one.

[1] https://github.com/Mellanox/mlxsw/tree/master/Debugging/libbpf-tools/resmon

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