cannot set TAP interface down with python API

Julien BERNARD jbernard at toulouse.viveris.fr
Tue Oct 8 07:04:30 EDT 2013


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 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.

I spent some time trying to find the problem but I cannot figure out 
where it comes from.

-- 
Julien BERNARD

-------------- next part --------------
A non-text attachment was scrubbed...
Name: set_state.patch
Type: text/x-patch
Size: 1252 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20131008/81a31b1e/attachment.bin>


More information about the libnl mailing list