chiark / gitweb /
networkd: fix kernel rtnl receive buffer overrun error
authorAlin Rauta <alin.rauta@intel.com>
Thu, 27 Nov 2014 17:50:48 +0000 (18:50 +0100)
committerTom Gundersen <teg@jklm.no>
Thu, 27 Nov 2014 17:59:47 +0000 (18:59 +0100)
We got the following error when running systemd on a device  with many ports:

"rtnl: kernel receive buffer overrun
Event source 'rtnl-receive-message' returned error, disabling: No buffer space
available"

I think the kernel socket receive buffer queue should be increased. The default
value is taken from:
"/proc/sys/net/core/rmem_default", but we can overwrite it using SO_RCVBUF
socket option.

This is already done in networkd for other sockets.
For example, the bus socket (sd-bus/bus-socket.c) has a receive queue of 8MB.
In our case, the default is 208KB.

Increasing the buffer receive queue for manager socket to 512KB should be enough
to get rid of the above error.

[tomegun: bump the limit even higher to 8M]

src/libsystemd/sd-rtnl/sd-rtnl.c
src/network/networkd-manager.c
src/systemd/sd-rtnl.h

index 1af38f3667d5c50a4045963dbb7c6ca4f62d1dd9..abb011ea24c675252adab551c46eeea49cbb9f04 100644 (file)
@@ -140,6 +140,10 @@ int sd_rtnl_open(sd_rtnl **ret, unsigned n_groups, ...) {
         return 0;
 }
 
+int sd_rtnl_inc_rcvbuf(const sd_rtnl *const rtnl, const int size) {
+        return fd_inc_rcvbuf(rtnl->fd, size);
+}
+
 sd_rtnl *sd_rtnl_ref(sd_rtnl *rtnl) {
         assert_return(rtnl, NULL);
         assert_return(!rtnl_pid_changed(rtnl), NULL);
index 2c8a330d75c83c20cb9d0c90e696dd785faaf96b..6046dc7d62a696b8507615cc98747eab6292e59d 100644 (file)
@@ -36,6 +36,9 @@
 
 #include "sd-rtnl.h"
 
+/* use 8 MB for receive socket kernel queue. */
+#define RCVBUF_SIZE    (8*1024*1024)
+
 const char* const network_dirs[] = {
         "/etc/systemd/network",
         "/run/systemd/network",
@@ -98,6 +101,10 @@ int manager_new(Manager **ret) {
         if (r < 0)
                 return r;
 
+        r = sd_rtnl_inc_rcvbuf(m->rtnl, RCVBUF_SIZE);
+        if (r < 0)
+                return r;
+
         r = sd_bus_default_system(&m->bus);
         if (r < 0 && r != -ENOENT) /* TODO: drop when we can rely on kdbus */
                 return r;
index 0980de8e3fcb73aa397ccfb00b8bbabb69ddfcb5..95bdb1d3d6e6612339fb7baf77970c9203798d4b 100644 (file)
@@ -41,6 +41,7 @@ typedef int (*sd_rtnl_message_handler_t)(sd_rtnl *rtnl, sd_rtnl_message *m, void
 
 /* bus */
 int sd_rtnl_open(sd_rtnl **nl, unsigned n_groups, ...);
+int sd_rtnl_inc_rcvbuf(const sd_rtnl *const rtnl, const int size);
 
 sd_rtnl *sd_rtnl_ref(sd_rtnl *nl);
 sd_rtnl *sd_rtnl_unref(sd_rtnl *nl);