]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ipv4: Refactor nhc evaluation in fib_table_lookup
authorDavid Ahern <dsahern@gmail.com>
Tue, 26 May 2020 18:56:17 +0000 (12:56 -0600)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 May 2020 23:06:07 +0000 (16:06 -0700)
commitaf7888ad9edbd8ba7f6449d1c27ce281ad4b26fd
treedfbee9452e5f2673a01f531dc4332bfcbc68770f
parent0b5e2e39739e861fa5fc84ab27a35dbe62a15330
ipv4: Refactor nhc evaluation in fib_table_lookup

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: 430a049190de ("nexthop: Add support for nexthop groups")
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip_fib.h
include/net/nexthop.h
net/ipv4/fib_trie.c