Skip to content

Commit 34fe5a1

Browse files
dsaherndavem330
authored andcommitted
ipv6: fib6_select_path can not use out path for nexthop objects
Brian reported a crash in IPv6 code when using rpfilter with a setup running FRR and external nexthop objects. The root cause of the crash is fib6_select_path setting fib6_nh in the result to NULL because of an improper check for nexthop objects. More specifically, rpfilter invokes ip6_route_lookup with flowi6_oif set causing fib6_select_path to be called with have_oif_match set. fib6_select_path has early check on have_oif_match and jumps to the out label which presumes a builtin fib6_nh. This path is invalid for nexthop objects; for external nexthops fib6_select_path needs to just return if the fib6_nh has already been set in the result otherwise it returns after the call to nexthop_path_fib6_result. Update the check on have_oif_match to not bail on external nexthops. Update selftests for this problem. Fixes: f88d8ea ("ipv6: Plumb support for nexthop object in a fib6_info") Reported-by: Brian Rak <[email protected]> Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent eadede5 commit 34fe5a1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

net/ipv6/route.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,12 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,
431431
struct fib6_info *sibling, *next_sibling;
432432
struct fib6_info *match = res->f6i;
433433

434-
if ((!match->fib6_nsiblings && !match->nh) || have_oif_match)
434+
if (!match->nh && (!match->fib6_nsiblings || have_oif_match))
435435
goto out;
436436

437+
if (match->nh && have_oif_match && res->nh)
438+
return;
439+
437440
/* We might have already computed the hash for ICMPv6 errors. In such
438441
* case it will always be non-zero. Otherwise now is the time to do it.
439442
*/

tools/testing/selftests/net/fib_nexthops.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,19 @@ ipv6_fcnal_runtime()
747747
run_cmd "$IP nexthop add id 86 via 2001:db8:91::2 dev veth1"
748748
run_cmd "$IP ro add 2001:db8:101::1/128 nhid 81"
749749

750+
# rpfilter and default route
751+
$IP nexthop flush >/dev/null 2>&1
752+
run_cmd "ip netns exec me ip6tables -t mangle -I PREROUTING 1 -m rpfilter --invert -j DROP"
753+
run_cmd "$IP nexthop add id 91 via 2001:db8:91::2 dev veth1"
754+
run_cmd "$IP nexthop add id 92 via 2001:db8:92::2 dev veth3"
755+
run_cmd "$IP nexthop add id 93 group 91/92"
756+
run_cmd "$IP -6 ro add default nhid 91"
757+
run_cmd "ip netns exec me ping -c1 -w1 2001:db8:101::1"
758+
log_test $? 0 "Nexthop with default route and rpfilter"
759+
run_cmd "$IP -6 ro replace default nhid 93"
760+
run_cmd "ip netns exec me ping -c1 -w1 2001:db8:101::1"
761+
log_test $? 0 "Nexthop with multipath default route and rpfilter"
762+
750763
# TO-DO:
751764
# existing route with old nexthop; append route with new nexthop
752765
# existing route with old nexthop; replace route with new

0 commit comments

Comments
 (0)