]> git.ipfire.org Git - thirdparty/systemd.git/commit
netlink-socket: ignore ECHRNG/EXFULL errors from recvmsg_safe() if we expect truncation 37165/head
authorLennart Poettering <lennart@poettering.net>
Thu, 17 Apr 2025 06:19:43 +0000 (08:19 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 17 Apr 2025 06:26:06 +0000 (08:26 +0200)
commit90755dac69dfb0c64e0e042aef0257c5dedb06c4
tree4d9c6f0198a07cd9d29b2fe458c5384eb7c185f6
parent6d88e4a4b43800ad2e5b6570052ef7e1c70b4d41
netlink-socket: ignore ECHRNG/EXFULL errors from recvmsg_safe() if we expect truncation

When we receive a netlink messages from userspace we need to drop it
from the queue. Hence we need call recvmsg() on the socket for it. We do
this with a zero-size socket read() buffer, so that the message would be
truncated when copied to userspace, and we do not have to allocate any
memory for it, but it's still dropped.

This was broken in ad501930d749e00f9686d29692b3142c36914f31, which
turned datagram truncation into an error (rightfully so I think – for
the common case). That broke this code here, because here we *expect*
truncation, and need to handle it gracefully.

Hence simply check for the two error codes for truncated payload or
cdata, and eat it up.
src/libsystemd/sd-netlink/netlink-socket.c