Set NETLINK_CAP_ACK, as we don't need a full copy of the request
payload, so it's "rather wasteful"[1] to not set NETLINK_CAP_ACK.
We don't check the return value of setsockopt(), as any capped
message will have NLM_F_CAPPED set in nlmsg_flags.
NETLINK_CAP_ACK was introduced in Linux v4.3 commit
0a6a3a23ea6e
("netlink: add NETLINK_CAP_ACK socket option"), and so AFAICT it
doesn't need to be added to netlink-sys.h.
[1] https://docs.kernel.org/userspace-api/netlink/intro.html
static struct nl_sock nl_scan = {.fd = -1}; /* Netlink socket for synchronous scan */
static struct nl_sock nl_req = {.fd = -1}; /* Netlink socket for requests */
+static void
+nl_set_cap_ack(struct nl_sock *nl UNUSED, int val UNUSED)
+{
+#ifdef SOL_NETLINK
+ setsockopt(nl->fd, SOL_NETLINK, NETLINK_CAP_ACK, &val, sizeof(val));
+#endif
+}
+
static void
nl_open_sock(struct nl_sock *nl)
{
nl->rx_buffer = xmalloc(NL_RX_SIZE);
nl->last_hdr = NULL;
nl->last_size = 0;
+
+ nl_set_cap_ack(nl, 1);
}
}