libnl issue with NETLINK_CONNECTOR and PROC_EVENTS on OpenWrt

Hrvoje Varga hrvoje.varga at sartura.hr
Tue Nov 15 08:45:11 PST 2016


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/files/)

Local Machine:
- Arch Linux
- Linux 4.8.7
- libnl 3.2.28 (downloaded from https://github.com/thom311/libnl/releases)

Thank you,
Hrvoje



More information about the libnl mailing list