[lxc-devel] [patch] lxc-device add wlan

Stéphane Graber stgraber at ubuntu.com
Fri Feb 21 17:01:52 UTC 2014


On Fri, Feb 21, 2014 at 02:02:50PM +0100, Gregor Beck wrote:
> Hi,
> 
> with the attached patch lxc-device can move a wireless device into a 
> container. 
> 
> There was a related issue requesting this feature from lxc.conf 
> https://github.com/lxc/lxc/issues/52
> 
> Gregor

That's interesting, I didn't know the phy itself could be moved between
network namespaces. I'll have to do a few tests here to make sure this
covers all the cases we care about, but that seems like a bug step up
from the "can't do, kernel won't let us" conclusion I arrived at last
time!

> 
> 
> -- 
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de, mailto:kontakt at sernet.de

> From 2d6c9c692386a46b9401bf36fd3a9375de618506 Mon Sep 17 00:00:00 2001
> From: Gregor Beck <gbeck at sernet.de>
> Date: Fri, 21 Feb 2014 11:09:32 +0100
> Subject: [PATCH] support lxc-device add wlan
> 
> Signed-off-by: Gregor Beck <gbeck at sernet.de>
> ---
>  src/python-lxc/lxc/__init__.py |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/src/python-lxc/lxc/__init__.py b/src/python-lxc/lxc/__init__.py
> index 9eb27b6..0b982ab 100644
> --- a/src/python-lxc/lxc/__init__.py
> +++ b/src/python-lxc/lxc/__init__.py
> @@ -160,6 +160,23 @@ class Container(_lxc.Container):
>          if not self.running:
>              return False
>  
> +
> +        if os.path.exists("/sys/class/net/%s/phy80211/" % name):
> +            f = open("/sys/class/net/%s/phy80211/name" % name)
> +            phy = f.readline().strip()
> +            f.close()
> +            if subprocess.call(['iw', 'phy', phy, 'set', 'netns',
> +                                str(self.init_pid)]) != 0:
> +                return False
> +            if destname:
> +                # return subprocess.call(['ip', 'netns',
> +                #                         'exec', str(self.init_pid),
> +                #                         'ip', 'link', 'set',
> +                #                         'dev', name,
> +                #                         'name', destname]) == 0
> +                return destname == name
> +            return True
> +
>          if not destname:
>              destname = name
>  
> -- 
> 1.7.9.5
> 

> _______________________________________________
> 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/20140221/ea0c2d83/attachment.pgp>


More information about the lxc-devel mailing list