Netdev List
 help / color / mirror / Atom feed
From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: vjardin@free.fr, David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH net 1/2] ipv6: check the scope of the best source address candidate in a VRF
Date: Tue, 24 Nov 2026 14:55:25 +0100	[thread overview]
Message-ID: <8f0c4cb5-8754-4636-abdd-ccec7ad5d932@6wind.com> (raw)
In-Reply-To: <20261123-for-upstream-ipv6-vrf-saddr-scope-v1-v1-1-f667ab150ade@free.fr>

Le 23/11/2026 à 15:30, Vincent Jardin via B4 Relay a écrit :
> From: Vincent Jardin <vjardin@free.fr>
> 
> When a packet is sent through a device of a VRF, ipv6_dev_get_saddr()
> first checks the addresses of that device and of the VRF device.
> It stops there when the best of them has a scope that fits the
> destination.
> 
> Since the commit abb9a68d2c64 ("ipv6: take care of scope when
> choosing the src addr"), that is what the scopedist of the best
> candidate is tested for.
> 
> scopedist is only written when the rule scope compares 2 candidates.
> With a single candidate, the rules stop at the first one, which only
> tells that there was no candidate yet, then scopedist is read without
> having been written.
> 
> It is 0 with CONFIG_INIT_STACK_ALL_ZERO, which passes the test:
> a device that only has an IPv6 link-local address sends to
> global destinations with that link-local address,
> although another device of the VRF has a global address.
> 
>   # ip link add site2 type vrf table 30
>   # ip link set site2 up
>   # ip link add dummy0 type dummy
>   # ip link set dummy0 master site2 up
>   # ip addr add fd00:91::1/64 dev dummy0 nodad
>   # ip link add dummy1 type dummy
>   # ip link set dummy1 master site2 up
>   # ip -6 route add fd00:93::/64 vrf site2 dev dummy1
>   # ip -6 route get fd00:93::1 vrf site2
>   fd00:93::1 dev dummy1 table 30 src fe80::5cb7:13ff:fe96:87ac metric 1024 pref medium
> 
> When the scope rule does run, scopedist is negative, whether the scope
> fits or not: the test fails, and the other devices of the VRF are
> checked too. One of their addresses can then win on a later rule,
> the longest matching prefix for instance, over the address of the VRF
> device, which the first lookup is meant to prefer.
> 
> So let's compare the scope of the best candidate with the scope of the
> destination instead.
> 
> This issue was found for a development of a UDP tunnel device with
> IPv6 addresses in a VRF selecting an IPv6 link-local source
> address for a global destination: then it was confirmed with the
> fib_tests.sh case of the next commit, whose first two checks fail without
> this fix on a CONFIG_INIT_STACK_ALL_ZERO=y kernel.
> 
> Fixes: abb9a68d2c64 ("ipv6: take care of scope when choosing the src addr")
> Cc: stable@vger.kernel.org
> Signed-off-by: Vincent Jardin <vjardin@free.fr>
Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

  reply	other threads:[~2026-11-24 13:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 14:30 [PATCH net 0/2] ipv6: fix IPv6 scope check of the source address in a VRF Vincent Jardin via B4 Relay
2026-11-23 14:30 ` [PATCH net 1/2] ipv6: check the scope of the best source address candidate " Vincent Jardin via B4 Relay
2026-11-24 13:55   ` Nicolas Dichtel [this message]
2026-11-23 14:30 ` [PATCH net 2/2] selftests: fib_tests: test IPv6 source address of " Vincent Jardin via B4 Relay
2026-11-24 14:11   ` Nicolas Dichtel

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=8f0c4cb5-8754-4636-abdd-ccec7ad5d932@6wind.com \
    --to=nicolas.dichtel@6wind.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vjardin@free.fr \
    --cc=willemb@google.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