1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-01 05:47:04 +03:00

sd-netlink: res_id is 16bit but serial is 32bit

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.

(cherry picked from commit 4314abf6d4e612e33c53909339931f2bd4cc0c29)
(cherry picked from commit 0175e2ea6e5fc44c7e2953f3f50775a12dbd6b58)
This commit is contained in:
Yu Watanabe 2023-11-01 18:47:36 +09:00 committed by Luca Boccassi
parent d387e5df1f
commit 225c0e6a79

View File

@ -150,9 +150,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);
}