Blocking unicast calls

Thomas Graf tgraf at
Thu Oct 28 19:22:21 EDT 2010

On Tue, Oct 26, 2010 at 02:42:27PM +0200, Yves Langisch wrote:
> I have a kernel module that acts as a Generic Netlink server. In the
> user space I have a daemon which receives Netlink unicast messages
> from the kernel module using the libnl library.
> What I'd like to know is if it's possible to send a Netlink message
> in a blocking manner and to get a direct result back from the
> daemon? As far as I understand the Netlink concept it is a bus-like
> system and thus I'm not sure if it's possible at all.
> Currently my call to send the message to the user space is as follows:
> ...
> rc = genlmsg_unicast(skb, daemon_pid);
> ...

There is no built-in way to do that as it doesn't make sense in most
cases. Sending a netlink message means writing the message buffer to
the socket buffer and waking the other side up. The sender is free
to proceed after having left behind the message in the socket buffer.

It's not difficult to block using a wait_queue thoug. Send the message,
put yourself in the waitqueue and go to sleep. Have the receiving
function wake you up when the answer arrives.

More information about the libnl mailing list