IPv6 version of 3f2fb9a834cb ("net: l3mdev: address selection should only
consider devices in L3 domain"). IPv4's follow up commit, a17b693cdd876
("net: l3mdev: prefer VRF master for source address selection"), is not
relevant. For IPv6 the VRF device should not be preferred over the dst_dev
as it leads to unnecessary forwarding versus a direct hop.

Signed-off-by: David Ahern <d...@cumulusnetworks.com>
---
 net/ipv6/addrconf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index b12553905e42..d13813867460 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1577,7 +1577,14 @@ int ipv6_dev_get_saddr(struct net *net, const struct 
net_device *dst_dev,
                if (idev)
                        hiscore_idx = __ipv6_dev_get_saddr(net, &dst, idev, 
scores, hiscore_idx);
        } else {
+               int master_idx = l3mdev_master_ifindex_rcu(dst_dev);
+
                for_each_netdev_rcu(net, dev) {
+                       /* only consider addresses on devices in the
+                        * same L3 domain
+                        */
+                       if (l3mdev_master_ifindex_rcu(dev) != master_idx)
+                               continue;
                        idev = __in6_dev_get(dev);
                        if (!idev)
                                continue;
-- 
2.1.4

Reply via email to