[lxc-devel] Problem in adding network interface to a container

Stéphane Graber stgraber at ubuntu.com
Sat Jul 5 13:11:10 UTC 2014


On Sat, Jul 05, 2014 at 04:56:16PM +0530, Ajith Adapa wrote:
> Hi,
> 
> I am trying to write a sample application in C to add and delete a
> network interface into a container. My code is as shown below and it
> fails.
> 
> #define DEVICE "/sys/class/net/eth2"
> #define NAME   "eth1"
> 
>   if (!c->add_device_node(c, DEVICE, NAME)) {
>     fprintf(stderr, "Adding %s to the container (%s) failed...\n",
> DEVICE, NAME);
>     goto out;
>   }
> 
> Is there anything wrong in the way I am using the add API  ?

Yes, network interfaces are special, they aren't character or block
devices, they just are network interfaces so that won't work with
add_device_node.

The python3 module does support it (which is why lxc-device supports it
too) by using the namespace capabilities of the ip command. It'd
probably be nice to re-implement that in C with netlink as add_interface
and remove_interface so that it's available to all API users (patches
are welcome!).

> 
> Regards,
> Ajith
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140705/5f73b273/attachment.sig>


More information about the lxc-devel mailing list