ip6tnl: add x-netns support
This patch allows to switch the netns when packet is encapsulated or decapsulated. In other word, the encapsulated packet is received in a netns, where the lookup is done to find the tunnel. Once the tunnel is found, the packet is decapsulated and injecting into the corresponding interface which stands to another netns. When one of the two netns is removed, the tunnel is destroyed. Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
6c742e714d
commit
0bd8762824
@@ -335,6 +335,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
|
||||
dev->rtnl_link_ops = &ip6gre_link_ops;
|
||||
|
||||
nt->dev = dev;
|
||||
nt->net = dev_net(dev);
|
||||
ip6gre_tnl_link_config(nt, 1);
|
||||
|
||||
if (register_netdevice(dev) < 0)
|
||||
@@ -1255,6 +1256,7 @@ static int ip6gre_tunnel_init(struct net_device *dev)
|
||||
tunnel = netdev_priv(dev);
|
||||
|
||||
tunnel->dev = dev;
|
||||
tunnel->net = dev_net(dev);
|
||||
strcpy(tunnel->parms.name, dev->name);
|
||||
|
||||
memcpy(dev->dev_addr, &tunnel->parms.laddr, sizeof(struct in6_addr));
|
||||
@@ -1275,6 +1277,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
|
||||
struct ip6_tnl *tunnel = netdev_priv(dev);
|
||||
|
||||
tunnel->dev = dev;
|
||||
tunnel->net = dev_net(dev);
|
||||
strcpy(tunnel->parms.name, dev->name);
|
||||
|
||||
tunnel->hlen = sizeof(struct ipv6hdr) + 4;
|
||||
@@ -1450,6 +1453,7 @@ static int ip6gre_tap_init(struct net_device *dev)
|
||||
tunnel = netdev_priv(dev);
|
||||
|
||||
tunnel->dev = dev;
|
||||
tunnel->net = dev_net(dev);
|
||||
strcpy(tunnel->parms.name, dev->name);
|
||||
|
||||
ip6gre_tnl_link_config(tunnel, 1);
|
||||
@@ -1501,6 +1505,7 @@ static int ip6gre_newlink(struct net *src_net, struct net_device *dev,
|
||||
eth_hw_addr_random(dev);
|
||||
|
||||
nt->dev = dev;
|
||||
nt->net = dev_net(dev);
|
||||
ip6gre_tnl_link_config(nt, !tb[IFLA_MTU]);
|
||||
|
||||
/* Can use a lockless transmit, unless we generate output sequences */
|
||||
|
Reference in New Issue
Block a user