net: l3mdev: Allow the l3mdev to be a loopback

Allow an L3 master device to act as the loopback for that L3 domain.
For IPv4 the device can also have the address 127.0.0.1.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David Ahern
2016-09-10 12:09:54 -07:00
committed by David S. Miller
parent a8e3e1a9f0
commit 5f02ce24c2
3 changed files with 19 additions and 7 deletions

View File

@@ -2558,8 +2558,16 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
{
u32 tb_id;
struct net *net = dev_net(idev->dev);
struct rt6_info *rt = ip6_dst_alloc(net, net->loopback_dev,
DST_NOCOUNT);
struct net_device *dev = net->loopback_dev;
struct rt6_info *rt;
/* use L3 Master device as loopback for host routes if device
* is enslaved and address is not link local or multicast
*/
if (!rt6_need_strict(addr))
dev = l3mdev_master_dev_rcu(idev->dev) ? : dev;
rt = ip6_dst_alloc(net, dev, DST_NOCOUNT);
if (!rt)
return ERR_PTR(-ENOMEM);