Skip to content

Commit 6933cd4

Browse files
idoschkuba-moo
authored andcommitted
ipv6: Align behavior across nexthops during path selection
A nexthop is only chosen when the calculated multipath hash falls in the nexthop's hash region (i.e., the hash is smaller than the nexthop's hash threshold) and when the nexthop is assigned a non-negative score by rt6_score_route(). Commit 4d0ab3a ("ipv6: Start path selection from the first nexthop") introduced an unintentional difference between the first nexthop and the rest when the score is negative. When the first nexthop matches, but has a negative score, the code will currently evaluate subsequent nexthops until one is found with a non-negative score. On the other hand, when a different nexthop matches, but has a negative score, the code will fallback to the nexthop with which the selection started ('match'). Align the behavior across all nexthops and fallback to 'match' when the first nexthop matches, but has a negative score. Fixes: 3d709f6 ("ipv6: Use hash-threshold instead of modulo-N") Fixes: 4d0ab3a ("ipv6: Start path selection from the first nexthop") Reported-by: Willem de Bruijn <[email protected]> Closes: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fc75ea2 commit 6933cd4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/ipv6/route.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,10 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,
470470
goto out;
471471

472472
hash = fl6->mp_hash;
473-
if (hash <= atomic_read(&first->fib6_nh->fib_nh_upper_bound) &&
474-
rt6_score_route(first->fib6_nh, first->fib6_flags, oif,
475-
strict) >= 0) {
476-
match = first;
473+
if (hash <= atomic_read(&first->fib6_nh->fib_nh_upper_bound)) {
474+
if (rt6_score_route(first->fib6_nh, first->fib6_flags, oif,
475+
strict) >= 0)
476+
match = first;
477477
goto out;
478478
}
479479

0 commit comments

Comments
 (0)