]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-netlink: res_id is 16bit but serial is 32bit
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 1 Nov 2023 09:47:36 +0000 (18:47 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 1 Nov 2023 14:02:49 +0000 (14:02 +0000)
The explicit value here is not so important.
Let's chop off the higher bits.

Fixes the issue reported at
https://github.com/systemd/systemd/pull/29802#issuecomment-1788637950.

src/libsystemd/sd-netlink/netlink-message-nfnl.c

index ff7f7c3480a1f805cf3a95597676773dfae0eedd..fd3055d879fcdb27a7da2cf86c4e5c5baa6cc27c 100644 (file)
@@ -149,9 +149,9 @@ int sd_nfnl_send_batch(
                 if (serials)
                         serials[i] = message_get_serial(messages[i]);
 
-                /* It seems that the kernel accepts an arbitrary number. Let's set the serial of the
-                 * first message. */
-                nfnl_message_set_res_id(messages[i], message_get_serial(batch_begin));
+                /* It seems that the kernel accepts an arbitrary number. Let's set the lower 16 bits of the
+                 * serial of the first message. */
+                nfnl_message_set_res_id(messages[i], (uint16_t) (message_get_serial(batch_begin) & UINT16_MAX));
 
                 iovs[c++] = IOVEC_MAKE(messages[i]->hdr, messages[i]->hdr->nlmsg_len);
         }