nl_send_sync returns without consuming ack message

Christophe Gouault christophe.gouault at 6wind.com
Fri Jan 20 11:37:31 PST 2017


Hi,

I am trying to use the nl_send_sync() with auto-ack enabled, to
retrieve the response to an XFRM_MSG_GETAE request.

In case of error (e.g. IPsec SA does not exist), the kernel sends a
single NLMSG_ERROR netlink message (error message). nl_send_sync()
returns a error value and the NLMSG_ERROR message is consumed (OK).

However, in case of success (IPsec SA found), the kernel sends 2
distinct netlink messages (with same sequence number but not MULTIPART
flag): an XFRM_MSG_NEWAE (response) + an NLMSG_ERROR (ack message) but
nl_send_sync() only processes the first one.

The NL_CB_INVALID callback is properly invoked to process the
XFRM_MSG_NEWAE message, but the ack message is not read.
nl_send_sync() returns 0 without consuming the ack, which remains in
the socket buffer. It will be read next time someone reads the socket,
instead of reading a response to a new request.

I expected nl_send_sync() to process all messages until an error or
ack is read. Am I missing something?

Regards,
Christophe



More information about the libnl mailing list