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@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@castiana:~# lxc-device -n lxc-dev add wlan2 wlan0
Added 'wlan2' to 'lxc-dev' as 'wlan0'.
root@castiana:~# lxc-attach -n lxc-dev
root@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@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:[email protected]
>
> > From 2d6c9c692386a46b9401bf36fd3a9375de618506 Mon Sep 17 00:00:00 2001
> > From: Gregor Beck <[email protected]>
> > Date: Fri, 21 Feb 2014 11:09:32 +0100
> > Subject: [PATCH] support lxc-device add wlan
> >
> > Signed-off-by: Gregor Beck <[email protected]>
> > ---
> > 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
> > [email protected]
> > http://lists.linuxcontainers.org/listinfo/lxc-devel
>
>
> --
> Stéphane Graber
> Ubuntu developer
> http://www.ubuntu.com
> _______________________________________________
> lxc-devel mailing list
> [email protected]
> http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
signature.asc
Description: Digital signature
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
