libnl issue with NETLINK_CONNECTOR and PROC_EVENTS on OpenWrt
Hrvoje Varga
hrvoje.varga at sartura.hr
Tue Dec 6 03:02:28 PST 2016
Hi Thomas,
thanks for your reply.
I am currently working on something else, so I will try your
suggestions as soon as I can. I never had the time to try 3.2.21 on
Arch so this is the first thing that I will try. If the issue can be
reproduced I will try to bisect libnl commits.
Best regards,
Hrvoje
On Fri, Dec 2, 2016 at 2:50 PM, Thomas Haller <thaller at redhat.com> wrote:
> On Tue, 2016-11-15 at 17:45 +0100, Hrvoje Varga wrote:
>> Hi all,
>>
>> I am experiencing an issue with an application that uses libnl to
>> subscribe and later on receive PROC_EVENTS messages from the kernel.
>> The application is built to work on OpenWrt platform but the initial
>> development was done using the Arch Linux on my own local machine.
>>
>> The problem is that I am not receiving any events from Linux in a
>> case
>> when the application is built for OpenWrt which is running on one of
>> our devices. If this application is built and ran on Arch Linux, the
>> application is behaving as expected; the PROC_EVENTS messages are
>> received and successfully processed.
>>
>> Note that I have built the OpenWrt with enabled CONNECTOR and
>> PROC_EVENTS kernel configuration parameters.
>>
>> Next is a non-compilable example code which I use to allocate a
>> socket, connect and subscribe to receive events about processes.
>>
>> struct nl_sock *nls = nl_socket_alloc();
>> if (nls == NULL) {
>> return -1;
>> }
>>
>> int rc = nl_connect(nls, NETLINK_CONNECTOR);
>> if (rc < 0) {
>> return -1;
>> }
>>
>> nl_socket_disable_seq_check(nls);
>> nl_socket_add_memberships(nls, CN_IDX_PROC, 0);
>> nl_socket_modify_cb(nls, NL_CB_MSG_IN, NL_CB_CUSTOM,
>> connector_proc_msg_recv_cb, NULL);
>> nl_socket_set_nonblocking(nls);
>>
>> Note here that I am calling nl_recvmsgs_default() function behind the
>> scenes. The connector_proc_msg_recv_cb() callback function is not
>> called in case of OpenWrt.
>>
>> Now, the reason that I consider that libnl has an issue is that I
>> tried to refactor my application to use the raw Linux NETLINK API
>> directly instead of using libnl. In this case, the application is
>> working as expected even on the OpenWrt.
>>
>> I'm hoping that someone here can tell me what's wrong and how I can
>> fix this. I'm willing to provide more info when necessary.
>>
>> Below is the environment that I use to run the application:
>>
>> Device:
>> - OpenWrt 15.05 (Chaos Calmer)
>> - Linux 3.18.36
>> - libnl 3.2.21 (downloaded from http://www.infradead.org/~tgr/libnl/f
>> iles/)
>>
>> Local Machine:
>> - Arch Linux
>> - Linux 4.8.7
>> - libnl 3.2.28 (downloaded from https://github.com/thom311/libnl/rele
>> ases)
>>
>
> Hi,
>
> what you describe doesn't look wrong, although not seeing the entire
> code. Also does your issue not ring a bell.
>
> Note that NL_CB_MSG_IN is the first hook and you should get events
> there.
>
> What happens if you enable debug logging via `export NLDBG=100`?
> Does strace help?
>
> As you are using different libnl versions, I would first check whether
> it's due to that... rebuilding libnl3 should be simple enough.
> Maybe try how 3.2.21 works on Arch, or how 3.2.28 works on OpenWrt.
> If that shows a difference, I would bisect libnl.
>
>
> Sorry for the late reply.
>
> Best,
> Thomas
More information about the libnl
mailing list