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

Axel Neumann neumann at cgws.de
Wed Jan 21 12:23:53 UTC 2015


On 10.07.2012 00:41, Serge Hallyn wrote:
> Quoting Axel Neumann (neumann at cgws.de):
>> 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
> 
> Acked-by: Serge E. Hallyn <serge at hallyn.com>
> 
> Looks reasonable.  Thanks

Could you have a look on this problem again. It's still valid.

I created a new patch based on recent lxc/master branch which could be
pulled here: https://github.com/lxc/lxc/pull/397

Thanks
/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) {
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and 
>> threat landscape has changed and how IT managers can respond. Discussions 
>> will include endpoint security, mobile security and the latest in malware 
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Lxc-devel mailing list
>> Lxc-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/lxc-devel
> 
> 



More information about the lxc-devel mailing list