• Ido Schimmel's avatar
    mlxsw: spectrum_router: Add trap adjacency entry upon first nexthop group · 4bdf80bc
    Ido Schimmel authored
    In commit 0c3cbbf9 ("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 983db619 ("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/resmonSigned-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
    Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    4bdf80bc
spectrum_router.c 276 KB