OSDN Git Service

mlxsw: spectrum_router: Allocate discard adjacency entry when needed
authorIdo Schimmel <idosch@mellanox.com>
Thu, 14 Nov 2019 09:54:19 +0000 (11:54 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Nov 2019 20:24:54 +0000 (12:24 -0800)
commit983db6198f0d0ee406f365069901387e7834c3c0
treeb66694a0ba07e92f3eb031f4c54969dd21f13d88
parentd6649d788e1a40b9bf2064bee4d7960fe85bd81e
mlxsw: spectrum_router: Allocate discard adjacency entry when needed

Commit 0c3cbbf96def ("mlxsw: Add specific trap for packets routed via
invalid nexthops") allocated an adjacency entry during driver
initialization whose purpose is to discard packets hitting the route
pointing to it.

These adjacency entries are allocated from a resource called KVD linear
(KVDL). There are situations in which the user can decide to set the
size of this resource (via devlink-resource) to 0, in which case the
driver will not be able to load.

Therefore, instead of pre-allocating this adjacency entry, simply
allocate it only when needed. A variable indicating the validity of the
entry is added and is used to ensure it is only allocated and written
once and that it is freed after all the routes were flushed.

Fixes: 0c3cbbf96def ("mlxsw: Add specific trap for packets routed via invalid nexthops")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c