[Devel] [PATCH rh7 2/4] net: ip_vti: skip per net init in ve
Vladimir Davydov
vdavydov at virtuozzo.com
Thu Jun 23 01:57:03 PDT 2016
ip_vti devices lack NETIF_F_VIRTUAL, so they can't be created inside a
container. Problem is a device of this kind is created on net ns init if
the module is loaded, as a result a container start fails with EPERM.
We could allow ip_vti inside container (as well as other net devices,
which I would really like to do), but this is insecure and might break
migration, so let's keep it disabled and fix the issue by silently
skipping ip_vti per net init if running inside a ve.
https://jira.sw.ru/browse/PSBM-48698
Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
net/ipv4/ip_vti.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index ce80a9a1be9d..3158100646ed 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -58,6 +58,9 @@ static int vti_input(struct sk_buff *skb, int nexthdr, __be32 spi,
struct net *net = dev_net(skb->dev);
struct ip_tunnel_net *itn = net_generic(net, vti_net_id);
+ if (itn == NULL)
+ return -EINVAL;
+
tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY,
iph->saddr, iph->daddr, 0);
if (tunnel != NULL) {
@@ -256,6 +259,9 @@ static int vti4_err(struct sk_buff *skb, u32 info)
int protocol = iph->protocol;
struct ip_tunnel_net *itn = net_generic(net, vti_net_id);
+ if (itn == NULL)
+ return -1;
+
tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY,
iph->daddr, iph->saddr, 0);
if (!tunnel)
@@ -413,6 +419,9 @@ static int __net_init vti_init_net(struct net *net)
int err;
struct ip_tunnel_net *itn;
+ if (!ve_is_super(net->owner_ve))
+ return net_assign_generic(net, vti_net_id, NULL);
+
err = ip_tunnel_init_net(net, vti_net_id, &vti_link_ops, "ip_vti0");
if (err)
return err;
@@ -424,6 +433,9 @@ static int __net_init vti_init_net(struct net *net)
static void __net_exit vti_exit_net(struct net *net)
{
struct ip_tunnel_net *itn = net_generic(net, vti_net_id);
+
+ if (itn == NULL)
+ return;
ip_tunnel_delete_net(itn, &vti_link_ops);
}
@@ -473,6 +485,9 @@ static int vti_newlink(struct net *src_net, struct net_device *dev,
{
struct ip_tunnel_parm parms;
+ if (net_generic(dev_net(dev), vti_net_id) == NULL)
+ return -EACCES;
+
vti_netlink_parms(data, &parms);
return ip_tunnel_newlink(dev, tb, &parms);
}
--
2.1.4
More information about the Devel
mailing list