[lxc-devel] [patch] lxc-device add wlan
Stéphane Graber
stgraber at ubuntu.com
Tue Feb 25 20:50:12 UTC 2014
On Fri, Feb 21, 2014 at 12:01:52PM -0500, Stéphane Graber wrote:
> 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!
Ok, so I have played with this a bit and I've got a slightly different
version of your change which I'll send for review now, with it I can do
the following succesfuly!
root at castiana:~# ifconfig wlan2
wlan2 Link encap:Ethernet HWaddr 00:c0:ca:4b:21:0d
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
root at castiana:~# lxc-device -n lxc-dev add wlan2 wlan0
Added 'wlan2' to 'lxc-dev' as 'wlan0'.
root at castiana:~# lxc-attach -n lxc-dev
root at lxc-dev:~# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:c0:ca:4b:21:0d
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
root at lxc-dev:~#
>
> >
> >
> > --
> > 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
> _______________________________________________
> 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/20140225/448f92a7/attachment.pgp>
More information about the lxc-devel
mailing list