From: Asbjørn Sloth Tønnesen Date: Thu, 21 May 2026 12:43:35 +0000 (+0200) Subject: Netlink: Skip request payload in acknowledgements X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=127ab72e5a2dd689d4de8b2f6deea4c7a37a31e9;p=thirdparty%2Fbird.git Netlink: Skip request payload in acknowledgements 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 --- diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index 9c519adb6..68f075fc0 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -70,6 +70,14 @@ static linpool *nl_linpool; 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) { @@ -82,6 +90,8 @@ 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); } }