summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-netlink
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-02-21 16:25:02 +0100
committerLennart Poettering <lennart@poettering.net>2017-02-21 21:41:32 +0100
commit71994cff31f2507429dc91550f73fd8e35646147 (patch)
tree8685aae866e3511f0ff7446007aee750365a5dee /src/libsystemd/sd-netlink
parent94c4c6227957ef34b7f46daaab75bb5911062462 (diff)
sd-netlink: don't give up on netlink on ENOBUFS
If our netlink input buffer overruns the kernel will send us ENOBUFS on the next recvmsg(). Don't consider this a complete failure resulting in closing of the netlink socket. Instead, simply continue (after debug logging). Of course, ideally we'd have a better strategy for this, and would have a way to resync if this happens (as well as a scheme for cancelling all ongoing asynchronous transactions), but for now let's at least not choke fatally, and simply accept that we lost some messages and continue. Note that if we lose messages when synchronously waiting for an operation to complete, we'll still propagate the ENOBUFS up, to make the individual transaction fail. See: #5398 (This bug does not properly fix the issue, hence we should leave the bug open.)
Diffstat (limited to 'src/libsystemd/sd-netlink')
-rw-r--r--src/libsystemd/sd-netlink/netlink-socket.c4
-rw-r--r--src/libsystemd/sd-netlink/sd-netlink.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/libsystemd/sd-netlink/netlink-socket.c b/src/libsystemd/sd-netlink/netlink-socket.c
index a0fd8a3ac9..129bfd2d80 100644
--- a/src/libsystemd/sd-netlink/netlink-socket.c
+++ b/src/libsystemd/sd-netlink/netlink-socket.c
@@ -281,7 +281,7 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
else if (errno == EAGAIN)
log_debug("rtnl: no data in socket");
- return (errno == EAGAIN || errno == EINTR) ? 0 : -errno;
+ return IN_SET(errno, EAGAIN, EINTR) ? 0 : -errno;
}
if (sender.nl.nl_pid != 0) {
@@ -292,7 +292,7 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
/* drop the message */
r = recvmsg(fd, &msg, 0);
if (r < 0)
- return (errno == EAGAIN || errno == EINTR) ? 0 : -errno;
+ return IN_SET(errno, EAGAIN, EINTR) ? 0 : -errno;
}
return 0;
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
index 43114eb825..68435564de 100644
--- a/src/libsystemd/sd-netlink/sd-netlink.c
+++ b/src/libsystemd/sd-netlink/sd-netlink.c
@@ -276,6 +276,10 @@ static int dispatch_rqueue(sd_netlink *rtnl, sd_netlink_message **message) {
if (rtnl->rqueue_size <= 0) {
/* Try to read a new message */
r = socket_read_message(rtnl);
+ if (r == -ENOBUFS) { /* FIXME: ignore buffer overruns for now */
+ log_debug_errno(r, "Got ENOBUFS from netlink socket, ignoring.");
+ return 1;
+ }
if (r <= 0)
return r;
}