[PATCH 2/8] python: rework netlink callback handling

Arend van Spriel arend at broadcom.com
Fri Nov 1 13:37:25 EDT 2013


On 11/01/2013 05:12 PM, Jeroen Roovers wrote:
> On Thu, 5 Sep 2013 14:11:26 +0200
> "Arend van Spriel" <arend at broadcom.com> wrote:
>
>> --- a/python/netlink/capi.i
>> +++ b/python/netlink/capi.i
> [...]
>> +struct pynl_cbinfo {
>> +	struct nl_cb *cb;
>> +	struct pynl_callback cbtype[NL_CB_TYPE_MAX+1];
>> +	struct pynl_callback cberr;
>> +	struct list_head list;
>> +};
>> +
>> +LIST_HEAD(callback_list);
>
> Where is LIST_HEAD defined? There is an NL_LIST_HEAD in
> include/netlink/list.h and glibc defines an (incompatible)
> implementation in <sys/queue.h>.

I was blissfully unaware and Thomas probably missed that. I added 
python/netlink/utils.h holding those definitions.

Regards,
Arend

> # python ./setup.py build
> running build
> running build_py
> creating build
> creating build/lib.linux-x86_64-3.2
> creating build/lib.linux-x86_64-3.2/netlink
> copying netlink/__init__.py -> build/lib.linux-x86_64-3.2/netlink
> copying netlink/core.py -> build/lib.linux-x86_64-3.2/netlink
> copying netlink/util.py -> build/lib.linux-x86_64-3.2/netlink
> creating build/lib.linux-x86_64-3.2/netlink/genl
> copying netlink/genl/__init__.py ->
> build/lib.linux-x86_64-3.2/netlink/genl creating
> build/lib.linux-x86_64-3.2/netlink/route copying
> netlink/route/__init__.py -> build/lib.linux-x86_64-3.2/netlink/route
> copying netlink/route/address.py ->
> build/lib.linux-x86_64-3.2/netlink/route copying netlink/route/link.py
> -> build/lib.linux-x86_64-3.2/netlink/route copying netlink/route/tc.py
> -> build/lib.linux-x86_64-3.2/netlink/route creating
> build/lib.linux-x86_64-3.2/netlink/route/links copying
> netlink/route/links/dummy.py ->
> build/lib.linux-x86_64-3.2/netlink/route/links copying
> netlink/route/links/__init__.py ->
> build/lib.linux-x86_64-3.2/netlink/route/links copying
> netlink/route/links/vlan.py ->
> build/lib.linux-x86_64-3.2/netlink/route/links copying
> netlink/route/links/inet.py ->
> build/lib.linux-x86_64-3.2/netlink/route/links creating
> build/lib.linux-x86_64-3.2/netlink/route/qdisc copying
> netlink/route/qdisc/__init__.py ->
> build/lib.linux-x86_64-3.2/netlink/route/qdisc copying
> netlink/route/qdisc/htb.py ->
> build/lib.linux-x86_64-3.2/netlink/route/qdisc running build_ext
> building 'netlink/_capi' extension swigging netlink/capi.i to
> netlink/capi_wrap.c swig -python -O -nodefaultctor -o
> netlink/capi_wrap.c netlink/capi.i creating build/temp.linux-x86_64-3.2
> creating build/temp.linux-x86_64-3.2/netlink x86_64-pc-linux-gnu-gcc
> -pthread -fPIC -I../include -I/usr/include/python3.2 -c
> netlink/capi_wrap.c -o build/temp.linux-x86_64-3.2/n
> etlink/capi_wrap.o
> netlink/capi_wrap.c:3519:19: error: field ‘list’ has incomplete type
> netlink/capi_wrap.c:3522:1: warning: data definition has no type or
> storage class [enabled by default] netlink/capi_wrap.c:3522:1: warning:
> parameter names (without types) in function declaration [enabled by
> default] netlink/capi_wrap.c: In function ‘pynl_find_cbinfo’:
> netlink/capi_wrap.c:3529:33: error: ‘callback_list’ undeclared (first
> use in this function) netlink/capi_wrap.c:3529:33: note: each
> undeclared identifier is reported only once for each function it
> appears in netlink/capi_wrap.c:3529:48: error: expected ‘;’ before ‘{’
> token netlink/capi_wrap.c: In function ‘pynl_get_cbinfo’:
> netlink/capi_wrap.c:3556:25: error: ‘callback_list’ undeclared (first
> use in this function) error: command 'x86_64-pc-linux-gnu-gcc' failed
> with exit status 1
>
> With:
>   -LIST_HEAD(callback_list);
>   +NL_LIST_HEAD(callback_list);
>
> I get:
> # python ./setup.py build
> running build
> running build_py
> copying netlink/capi.py -> build/lib.linux-x86_64-3.2/netlink
> running build_ext
> building 'netlink/_capi' extension
> swigging netlink/capi.i to netlink/capi_wrap.c
> swig -python -O -nodefaultctor -o netlink/capi_wrap.c netlink/capi.i
> x86_64-pc-linux-gnu-gcc -pthread -fPIC -I../include
> -I/usr/include/python3.2 -c netlink/capi_wrap.c -o
> build/temp.linux-x86_64-3.2/netlink/capi_wrap.o
> netlink/capi_wrap.c:3519:19: error: field ‘list’ has incomplete type
> netlink/capi_wrap.c: In function ‘pynl_find_cbinfo’:
> netlink/capi_wrap.c:3529:48: error: expected ‘;’ before ‘{’ token
> error: command 'x86_64-pc-linux-gnu-gcc' failed with exit status 1
>
> After replacing list_head with nl_list_head, I still get:
>
> # python ./setup.py build
> running build
> running build_py
> copying netlink/capi.py -> build/lib.linux-x86_64-3.2/netlink
> running build_ext
> building 'netlink/_capi' extension
> swigging netlink/capi.i to netlink/capi_wrap.c
> swig -python -O -nodefaultctor -o netlink/capi_wrap.c netlink/capi.i
> x86_64-pc-linux-gnu-gcc -pthread -fPIC -I../include
> -I/usr/include/python3.2 -c netlink/capi_wrap.c -o
> build/temp.linux-x86_64-3.2/netlink/capi_wrap.o netlink/capi_wrap.c: In
> function ‘pynl_find_cbinfo’: netlink/capi_wrap.c:3529:48: error:
> expected ‘;’ before ‘{’ token error: command 'x86_64-pc-linux-gnu-gcc'
> failed with exit status 1
>
>
>       jer
>





More information about the libnl mailing list