From: Nicolas Dichtel Date: Wed, 10 Jul 2024 08:14:29 +0000 (+0200) Subject: ipv6: take care of scope when choosing the src addr X-Git-Tag: v6.11-rc1~163^2~4^2~3^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=abb9a68d2c64dd9b128ae1f2e635e4d805e7ce64;p=thirdparty%2Fkernel%2Flinux.git ipv6: take care of scope when choosing the src addr When the source address is selected, the scope must be checked. For example, if a loopback address is assigned to the vrf device, it must not be chosen for packets sent outside. CC: stable@vger.kernel.org Fixes: afbac6010aec ("net: ipv6: Address selection needs to consider L3 domains") Signed-off-by: Nicolas Dichtel Reviewed-by: David Ahern Link: https://patch.msgid.link/20240710081521.3809742-4-nicolas.dichtel@6wind.com Signed-off-by: Jakub Kicinski --- diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 5c424a0e7232f..4f2c5cc31015e 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -1873,7 +1873,8 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev, master, &dst, scores, hiscore_idx); - if (scores[hiscore_idx].ifa) + if (scores[hiscore_idx].ifa && + scores[hiscore_idx].scopedist >= 0) goto out; }