diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2016-06-17 01:24:26 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-06-18 06:25:29 +0200 |
commit | afbac6010aec514998214fb19a1f37732b7a1d77 (patch) | |
tree | 70ba765b4370e8f37a8b7859f054ec4e18727074 /include/net/l3mdev.h | |
parent | net: vrf: Implement get_saddr for IPv6 (diff) | |
download | linux-afbac6010aec514998214fb19a1f37732b7a1d77.tar.xz linux-afbac6010aec514998214fb19a1f37732b7a1d77.zip |
net: ipv6: Address selection needs to consider L3 domains
IPv6 version of 3f2fb9a834cb ("net: l3mdev: address selection should only
consider devices in L3 domain") and the follow up commit, a17b693cdd876
("net: l3mdev: prefer VRF master for source address selection").
That is, if outbound device is given then the address preference order
is an address from that device, an address from the master device if it
is enslaved, and then an address from a device in the same L3 domain.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/l3mdev.h')
-rw-r--r-- | include/net/l3mdev.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h index 818fd4f100fc..e90095091aa0 100644 --- a/include/net/l3mdev.h +++ b/include/net/l3mdev.h @@ -79,6 +79,31 @@ static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex) return rc; } +static inline +const struct net_device *l3mdev_master_dev_rcu(const struct net_device *_dev) +{ + /* netdev_master_upper_dev_get_rcu calls + * list_first_or_null_rcu to walk the upper dev list. + * list_first_or_null_rcu does not handle a const arg. We aren't + * making changes, just want the master device from that list so + * typecast to remove the const + */ + struct net_device *dev = (struct net_device *)_dev; + const struct net_device *master; + + if (!dev) + return NULL; + + if (netif_is_l3_master(dev)) + master = dev; + else if (netif_is_l3_slave(dev)) + master = netdev_master_upper_dev_get_rcu(dev); + else + master = NULL; + + return master; +} + /* get index of an interface to use for FIB lookups. For devices * enslaved to an L3 master device FIB lookups are based on the * master index @@ -190,6 +215,12 @@ static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex) return 0; } +static inline +const struct net_device *l3mdev_master_dev_rcu(const struct net_device *dev) +{ + return NULL; +} + static inline int l3mdev_fib_oif_rcu(struct net_device *dev) { return dev ? dev->ifindex : 0; |