Skip to content

Commit 0afb500

Browse files
idoschNipaLocal
authored and
NipaLocal
committed
ipv6: Do not consider link down nexthops in path selection
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]> Signed-off-by: NipaLocal <nipa@local>
1 parent 494c64a commit 0afb500

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
@@ -442,6 +442,7 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,
442442
{
443443
struct fib6_info *first, *match = res->f6i;
444444
struct fib6_info *sibling;
445+
int hash;
445446

446447
if (!match->nh && (!match->fib6_nsiblings || have_oif_match))
447448
goto out;
@@ -468,7 +469,8 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,
468469
if (!first)
469470
goto out;
470471

471-
if (fl6->mp_hash <= atomic_read(&first->fib6_nh->fib_nh_upper_bound) &&
472+
hash = fl6->mp_hash;
473+
if (hash <= atomic_read(&first->fib6_nh->fib_nh_upper_bound) &&
472474
rt6_score_route(first->fib6_nh, first->fib6_flags, oif,
473475
strict) >= 0) {
474476
match = first;
@@ -481,7 +483,7 @@ void fib6_select_path(const struct net *net, struct fib6_result *res,
481483
int nh_upper_bound;
482484

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

0 commit comments

Comments
 (0)