mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Maximilian Moehl" <maximilian@moehl.eu>
To: "Maximilian Moehl" <maximilian@moehl.eu>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	"David Ahern" <dsahern@kernel.org>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Simon Horman" <horms@kernel.org>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net/ipv6: repeat route lookup with saddr set for ECMP
Date: Sat, 11 Apr 2026 10:18:07 +0200	[thread overview]
Message-ID: <DHQ6ESFTW2YO.2HOPJZ5CY05U1@moehl.eu> (raw)
In-Reply-To: <DHGZBEMZ25SW.3LE7U694ND0L0@moehl.eu>

On Tue Mar 31, 2026 at 2:50 PM CEST, Maximilian Moehl wrote:
> On Mon Mar 30, 2026 at 9:56 AM CEST, Paolo Abeni wrote:
>> On 3/29/26 11:12 AM, Maximilian Moehl wrote:
>>> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
>>> index 8e2a6b28cea7..465fce51d017 100644
>>> --- a/net/ipv6/ip6_output.c
>>> +++ b/net/ipv6/ip6_output.c
>>> @@ -1148,6 +1148,18 @@ static int ip6_dst_lookup_tail(struct net *net, const struct sock *sk,
>>>  			*dst = NULL;
>>>  		}
>>>  
>>> +		/* If ECMP was involved the initial hash was calculted
>>> +		 * with saddr=:: which can result in instability
>>> +		 * when it is later re-calculated with the selected
>>> +		 * saddr. Lookup the route again with the chosen
>>> +		 * saddr to get a stable result.
>>> +		 */
>>> +		if (fl6->mp_hash) {
>>> +			fl6->mp_hash = 0;
>>> +			dst_release(*dst);
>>> +			*dst = NULL;
>>> +		}
>>> +
>>>  		if (fl6->flowi6_oif)
>>>  			flags |= RT6_LOOKUP_F_IFACE;
>>>  	}
>>
>> This apparently breaks ipv6 fib tests (fib_tests.sh):
>>
>> # IPv6 multipath load balance test
>> #      TEST: IPv6 multipath loadbalance                          [FAIL]
>>
>> see
>> https://github.com/linux-netdev/nipa/wiki/How-to-run-netdev-selftests-CI-style
>> on how to reproduce the tests.
>>
>> Also this would deserve additional testcases.
>
> Thank you for the pointer, I will look into the tests.

I've investigated the test failure. The logic I introduced causes the
packet to leave interface 1 with the address of interface 3 and is
therefore not picked up by the TC counter causing the test failure.
IPv4 does not have this issue, neither does it have the issue I'm
trying to fix for IPv6.

>> Without diving much inside the code I have the feeling this change is
>> plugged into the wrong place: multipath selection logic should be
>> encapsulated by fib6_select_path().

I further looked into how IPv4 prevents this issue from occurring.
Initially I thought it was because it does more than one route lookup,
but if I got it right now, it's because of the scoring logic in
fib_select_multipath. It adds one point for a matching hash bucket and
two points for a matching source address. After initially selecting an
outgoing interface, and with that a source address, the flow stays
bound to the initially selected interface, no matter what the hash is
(unless there's a second interface with the same address where the
hash matches, but in that case switching interfaces is probably
fine?).

I will prepare a new patch that addresses this difference so that IPv6
also prefers the outgoing interface with a matching source address
over the hash bucket it would select otherwise.

--
Max

      reply	other threads:[~2026-04-11  8:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-29  9:12 Maximilian Moehl
2026-03-30  7:56 ` Paolo Abeni
2026-03-31 12:50   ` Maximilian Moehl
2026-04-11  8:18     ` Maximilian Moehl [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DHQ6ESFTW2YO.2HOPJZ5CY05U1@moehl.eu \
    --to=maximilian@moehl.eu \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®