ipv6: Align behavior across nexthops during path selection
Subsystems (3)
Ido Schimmel
maintainerPATCH 1/1 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 4d0ab3a6885e ("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.
--- net/ipv6/route.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/ipv6/route.c +4 -4
@@ -470,10 +470,10 @@ void fib6_select_path(const struct net *net, struct fib6_result *res, goto out; hash = fl6->mp_hash; -if (hash <=atomic_read (&first->fib6_nh->fib_nh_upper_bound) && -rt6_score_route (first->fib6_nh, first->fib6_flags, oif, - strict) >=0 ) { - match = first; +if (hash <=atomic_read (&first->fib6_nh->fib_nh_upper_bound)) { +if (rt6_score_route (first->fib6_nh, first->fib6_flags, oif, + strict) >=0 ) + match = first; goto out; }
Signature · 1 line
2.49.0
Quoted 15 lines · Ido Schimmel
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
4d0ab3a6885e("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').
Quoted 8 lines
Align the behavior across all nexthops and fallback to 'match' when the first nexthop matches, but has a negative score.
Fixes 3d709f69a3e7 ("ipv6: Use hash-threshold instead of modulo-N")Fixes 4d0ab3a6885e ("ipv6: Start path selection from the first nexthop")Reported-by Willem de Bruijn <[email protected]>Signed-off-by Ido Schimmel <[email protected]>
Quoted 18 lines · Ido Schimmel
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
4d0ab3a6885e("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.
Quoted 9 lines
Fixes 3d709f69a3e7 ("ipv6: Use hash-threshold instead of modulo-N")Fixes 4d0ab3a6885e ("ipv6: Start path selection from the first nexthop")Reported-by Willem de Bruijn <[email protected]>Signed-off-by Ido Schimmel <[email protected]>--- net/ipv6/route.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 8 Apr 2025 11:43:16 +0300 you wrote:
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
4d0ab3a6885e("ipv6: Start path selection from the first nexthop") introduced an unintentional difference between the first nexthop and the rest when the score is negative.[...]
Here is the summary with links:
- [net] ipv6: Align behavior across nexthops during path selection
https://git.kernel.org/netdev/net/c/6933cd471486
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html