]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ipv6: take care of scope when choosing the src addr
authorNicolas Dichtel <nicolas.dichtel@6wind.com>
Wed, 10 Jul 2024 08:14:29 +0000 (10:14 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sun, 14 Jul 2024 14:34:16 +0000 (07:34 -0700)
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 <nicolas.dichtel@6wind.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20240710081521.3809742-4-nicolas.dichtel@6wind.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv6/addrconf.c

index 5c424a0e7232faa854f5b661319b8f7f182a60b8..4f2c5cc31015e953f388b4f1c120facc48abff8d 100644 (file)
@@ -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;
                }