Skip to content

Commit abbba52

Browse files
eqvinoxNipaLocal
authored andcommitted
net/ipv6: fix lookup for ::/0 (non-)subtree route
Assume a scenario with something like the following routes: default via fe80::1 dev dummy0 2001:db8:1::/48 via fe80::10 dev dummy0 2001:db8:1::/48 from 2001:db8:1:2::/64 via fe80::12 dev dummy0 Now if a lookup happens for 2001:db8:1::2345, but with a source address *not* covered by the third route, the expectation is to hit the second one. Unfortunately, this was broken since the code, on failing the lookup in the subtree, didn't consider the node itself which the subtree is attached to, i.e. route kernel-patches#2 above. The fix is simple, check if the subtree is attached to a node that is itself a valid route before backtracking to less specific destination prefixes. This case is somewhat rare for several reasons. To begin with, subtree routes are most commonly attached to the default destination. Additionally, in the rare cases where a non-default destination prefix is host to subtree routes, the fallback on not hitting any subtree route is commonly a default route (or a subtree route on that). (Note that this was working for the "::/0 from ::/0" case since the root node is special-cased. The issue was discovered during RFC 6724 rule 5.5 testing, trying to find edge cases.) Signed-off-by: David Lamparter <equinox@diac24.net> Cc: Lorenzo Colitti <lorenzo@google.com> Cc: Patrick Rohr <prohr@google.com> Cc: Maciej Żenczykowski <maze@google.com> Signed-off-by: NipaLocal <nipa@local>
1 parent 8f9e33e commit abbba52

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/ipv6/ip6_fib.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,8 +1650,11 @@ static struct fib6_node *fib6_node_lookup_1(struct fib6_node *root,
16501650
struct fib6_node *sfn;
16511651
sfn = fib6_node_lookup_1(subtree,
16521652
args + 1);
1653-
if (!sfn)
1653+
if (!sfn) {
1654+
if (fn->fn_flags & RTN_RTINFO)
1655+
return fn;
16541656
goto backtrack;
1657+
}
16551658
fn = sfn;
16561659
}
16571660
#endif

0 commit comments

Comments
 (0)