]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Netlink: Skip request payload in acknowledgements
authorAsbjørn Sloth Tønnesen <ast@2e8.dk>
Thu, 21 May 2026 12:43:35 +0000 (14:43 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Wed, 27 May 2026 04:26:58 +0000 (06:26 +0200)
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

sysdep/linux/netlink.c

index 9c519adb629556e3df569686ae0c0f1d5ef705ae..68f075fc0b355c27a6309a68be03685518166952 100644 (file)
@@ -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);
     }
 }