• David Ahern's avatar
    ipv4: Refactor nhc evaluation in fib_table_lookup · af7888ad
    David Ahern authored
    FIB lookups can return an entry that references an external nexthop.
    While walking the nexthop struct we do not want to make multiple calls
    into the nexthop code which can result in 2 different structs getting
    accessed - one returning the number of paths the rest of the loop
    seeing a different nh_grp struct. If the nexthop group shrunk, the
    result is an attempt to access a fib_nh_common that does not exist for
    the new nh_grp struct but did for the old one.
    
    To fix that move the device evaluation code to a helper that can be
    used for inline fib_nh path as well as external nexthops.
    
    Update the existing check for fi->nh in fib_table_lookup to call a
    new helper, nexthop_get_nhc_lookup, which walks the external nexthop
    with a single rcu dereference.
    
    Fixes: 430a0491 ("nexthop: Add support for nexthop groups")
    Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
    Acked-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    af7888ad
fib_trie.c 71.7 KB