libnl
libnl copied to clipboard
Use recvmmsg() when available
On huge netlink traffic (like ULOG or NFLOG) receiving one message per syscall affect performance. Receiving multiple mesasges at once give preformance boost.
Note that since commit 55ea6e6b6cd805f441b410971c9dd7575e783ef4, we use recvmsg() with MSG_PEEK by default, which means that for each message two syscalls are required.
:( Did anyone test performance ?
Not tested, because correctness trumps performance.
To get the previous behavior, call nl_socket_disable_msg_peek()
(this also works against older versions of the library). Then it's up to you to ensure that the buffer size is large enough (it's not clear how to do that in the general case).
FWIW, systemd does MSG_PEEK too: https://github.com/systemd/systemd/blob/3099caf2b5bb9498b1d0227c40926435ca81f26f/src/libsystemd/sd-netlink/netlink-socket.c#L337