cannot set TUN interface up/down with Python API (wrapper)

Julien BERNARD jbernard at toulouse.viveris.fr
Wed Jun 17 07:31:18 PDT 2015


Hi Thomas,

Thanks for your answer.

I'm working the problem with David.

I tried with older versions. On Ubuntu 12.04 LTS the version was 3.2.3 
and this was the only version I could get to work.

The last working revision is 88940b71f81525b1080fcdd5a029537e9a85ca38, 
the revision just after the 3.2.3 release.
The next revision (ef75c4edf0930b4d745da695c5fe0075c7b3afdd) introduces 
a segfault in the script that is resolved in the 3.2.5 release (this 
should be the fix introduced by the revision 
4035e5b5e88529e6c7a12c41dcd8637ed69498d9).
Thus, I applied the fix on the revision 
ef75c4edf0930b4d745da695c5fe0075c7b3afdd and I can confirm that the 
problem was introduced by this revision.
However I'm not familiar enough with all of this to determine exactly 
what causes the bug.

Could you please help me to understand what really causes this error?

Regards,

-- 
Julien



Le 20/04/2015 15:26, Thomas Haller a écrit :
> On Fri, 2015-04-17 at 14:31 +0200, David Pradas wrote:
>> Hi,
>
> Hi David,
>
>
>> I'm having a problem when using the Pyhton API (wrapper) for link
>> management (change address, set state up/down). I am not able to set a
>> TUN interface up/down with the python wrapper. However, I am capable of
>> doing that with the "C" API.
>> This is the procedure I follow:
>>
>> 1. I first create the TUN interface "tun0":
>>
>> /sudo ip tuntap add dev tun0 mode tun/
>>
>> 2. Then, I execute my python script (test.py):
>>
>> /#!/usr/bin/env python2//
>> //import netlink.route.link as link//
>> //import netlink.core as netlink//
>> //import netlink.route.address as address//
>> //
>> //sock = netlink.Socket()//
>> //sock.connect(netlink.NETLINK_ROUTE)//
>> //cache = link.LinkCache()//
>> //cache.refill(sock)//
>> //iface = cache['tun0']//
>> //iface.flags = ['-up']//
>> /*/iface.change()/*/
> can you attach a small (working) reproducer? Where is this test.py
> script?
>
> You say it works via the "C" API. Did you write the same code in plain C
> and that was working?
>
>
>> 3. Finally, I obtain the following output when the file "test.py" has
>> been executed.
>>
>> I get an " Invalid input data or parameter" exception when I call the
>> "iface.change()" :
>>
>> //  nl_recvmsgs_report() returns error
>> //  Traceback (most recent call last):
>> //  File "./test.py", line 12, in <module>
>> //    iface.change()
>> //  File "/usr/local/lib/python2.7/dist-packages/netlink/route/link.py",
>> line 409, in change
>> //    raise netlink.KernelError(ret)
>> // netlink.core.KernelError: Kernel returned: Invalid input data or
>> parameter
>>
>> On the other hand, I am capable of setting up/down other interfaces
>> which are not tun/tap (such as "eth") following the same method.
>> However, even in that case, I obtain the following error:
>>
>> // File "./test.py", line 12, in <module>
>> //   iface.change()
>> //  File "/usr/local/lib/python2.7/dist-packages/netlink/route/link.py",
>> line 409, in change
>> //    raise netlink.KernelError(ret)
>> // netlink.core.KernelError: Kernel returned: Message sequence number
>> mismatch
>>
>> I can not figure out where the problem is. Any ideas please?
> Hm... I don't know. Try enabling debug logging for libnl via
>
> export NLDBG=100
>
>
>
>> I am running Ubuntu 14.04 LTS 64 bits and using the last release of
>> libnl 3.2.26 (I have also tried 3.2.25 with same results) . FYI: the
>> Python wrapper was correctly working with Ubuntu 12.04 LTS 64 bits, i.e.
>> I could set the TUN up/down without problems.
> you could try whether an older version works, and then finding the
> version that breaks your script (e.g. using git bisec).
>
>
> Thomas
>
>
> _______________________________________________
> libnl mailing list
> libnl at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libnl




More information about the libnl mailing list