cannot set TAP interface down with python API

Thomas Graf tgraf at suug.ch
Tue Oct 22 08:12:32 EDT 2013


On 10/08/13 at 01:04pm, Julien BERNARD wrote:
> Hi,
> 
> I am currently using the python api for routes (create/remove
> routes) and link management (change addresses, set state up/down).
> 
> I added some new functions in the netlink/route/capi.i (from
> include/netlink/route/route.h) for routes support and this works
> well.
> 
> For link management, I had to correct a bug in the flag setter but
> Arend seems to have corrected it now.
> However, I still have a problem with the python wrapper that does
> not occur with the C API, I cannot set a TAP interface down.
> Each time I call change() on the link I get an "Object busy" exception.
> 
> Here are the step I use to reproduce the problem:
> /$ sudo ip tuntap add dev tap0 mode tap
> $ sudo python
> import netlink.route.capi as capi
> import netlink.route.link as link
> import netlink.core as netlink
> sock = netlink.Socket()
> sock.connect(netlink.NETLINK_ROUTE)
> cache = link.LinkCache()
> cache.refill(sock)
> link = cache['tap0']
> link.flags = ['up']
> link.change()
> link.flags = ['-up']
> link.change()/
> /
> //Traceback (most recent call last)://
> //  File "<input>", line 1, in <module>//
> //  File "/usr/lib/python2.7/dist-packages/netlink/route/link.py",
> line 397, in change//
> //    raise netlink.KernelError(ret)//
> //KernelError: Kernel returned: Object busy/

I have no idea. Could someone with more python clues look into this?

> I only have this problem with a tap interface, not with any other
> interface, I even use a bridge and a tun interface.
> 
> I modified the nl-link-set.c file to be able to set the interface up
> or down. I joined the patch.
> With the new nl-link-set binary I can set the tap interface down.
> I am working with Ubuntu 12.04 LTS 64bits and the libnl and
> libnl-route packages built from libnl3-3.2.3 from ubuntu
> reprositories.

Patch applied, thanks!



More information about the libnl mailing list