Skip to content

Commit fa2f9fc

Browse files
idoschgregkh
authored andcommitted
ipv6: Do not consider link down nexthops in path selection
[ Upstream commit 8b8e0dd357165e0258d9f9cdab5366720ed2f619 ] Nexthops whose link is down are not supposed to be considered during path selection when the "ignore_routes_with_linkdown" sysctl is set. This is done by assigning them a negative region boundary. However, when comparing the computed hash (unsigned) with the region boundary (signed), the negative region boundary is treated as unsigned, resulting in incorrect nexthop selection. Fix by treating the computed hash as signed. Note that the computed hash is always in range of [0, 2^31 - 1]. Fixes: 3d709f6 ("ipv6: Use hash-threshold instead of modulo-N") Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 21f678f commit fa2f9fc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/ipv6/route.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,
444444
{
445445
struct fib6_info *first, *match = res->f6i;
446446
struct fib6_info *sibling;
447+
int hash;
447448

448449
if (!match->nh && (!match->fib6_nsiblings || have_oif_match))
449450
goto out;
@@ -470,7 +471,8 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,
470471
if (!first)
471472
goto out;
472473

473-
if (fl6->mp_hash <= atomic_read(&first->fib6_nh->fib_nh_upper_bound) &&
474+
hash = fl6->mp_hash;
475+
if (hash <= atomic_read(&first->fib6_nh->fib_nh_upper_bound) &&
474476
rt6_score_route(first->fib6_nh, first->fib6_flags, oif,
475477
strict) >= 0) {
476478
match = first;
@@ -483,7 +485,7 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,
483485
int nh_upper_bound;
484486

485487
nh_upper_bound = atomic_read(&nh->fib_nh_upper_bound);
486-
if (fl6->mp_hash > nh_upper_bound)
488+
if (hash > nh_upper_bound)
487489
continue;
488490
if (rt6_score_route(nh, sibling->fib6_flags, oif, strict) < 0)
489491
break;

0 commit comments

Comments
 (0)