[lxc-devel] Problem when using same vlan.id for multiple vlan interfaces

Axel Neumann neumann at cgws.de
Mon Jul 9 12:58:16 UTC 2012


Hello,

First, thanks a lot for your good work!
We are using LXC in the CONFINE project (confine-project.eu) to provide 
researchers with a virtualized linux evironment in a distributed testbed.

We found a problem when a container config looks like this (uses the 
same vlan id for several type=vlan container interfaces):

lxc.network.type      = vlan
lxc.network.flags     = up
lxc.network.link      = eth1
lxc.network.vlan.id   = 3842
lxc.network.name      = iso0

lxc.network.type      = vlan
lxc.network.flags     = up
lxc.network.link      = eth2
lxc.network.vlan.id   = 3842
lxc.network.name      = iso1

Then, during the instantiation of the vlan interfaces an error occurs 
because the lxc code tries to assign the same name to both of them 
before it is bound into the container.

Maybe you can have a look at the  following patch which solves the problem
(see also here: 
https://github.com/axn/lxc/commit/32fb8a007a95ad4beb9d9d7dade032a50f5da0db  
)
and consider this or an alternative solution for your 0.8.0 branch.

Thanks a lot
/axel


neumann at sid:/usr/src/lxc/lxc.git$ git diff HEAD^
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index e8088bb..4f21464 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -1733,13 +1733,14 @@ static int instanciate_vlan(struct lxc_handler 
*handler, struct lxc_netdev *netd
  {
         char peer[IFNAMSIZ];
         int err;
+        static uint16_t vlan_cntr = 0;

         if (!netdev->link) {
                 ERROR("no link specified for vlan netdev");
                 return -1;
-       }
+        }

-       snprintf(peer, sizeof(peer), "vlan%d", netdev->priv.vlan_attr.vid);
+        snprintf(peer, sizeof (peer), "vlan%d-%d", 
netdev->priv.vlan_attr.vid, vlan_cntr++);

         err = lxc_vlan_create(netdev->link, peer, 
netdev->priv.vlan_attr.vid);
         if (err) {









More information about the lxc-devel mailing list