libnetlink: fix netlink buffer space handling
[project/ustp.git] / libnetlink.c
index 477e1a25126ee423bd0736cb64a79f8316ef7c50..5c5523da2613a80712b19a6e4321a06732c0f2fd 100644 (file)
@@ -27,7 +27,7 @@
 #include "libnetlink.h"
 
 #ifndef DEFAULT_RTNL_BUFSIZE
-#define DEFAULT_RTNL_BUFSIZE   256 * 1024
+#define DEFAULT_RTNL_BUFSIZE   4 * 1024 * 1024
 #endif
 
 #ifndef RTNL_SND_BUFSIZE
@@ -48,6 +48,7 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,
        socklen_t addr_len;
        int sndbuf = RTNL_SND_BUFSIZE;
        int rcvbuf = RTNL_RCV_BUFSIZE;
+       int yes = 1;
 
        memset(rth, 0, sizeof(*rth));
 
@@ -69,6 +70,9 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,
                return -1;
        }
 
+       if (setsockopt(rth->fd, SOL_NETLINK, NETLINK_NO_ENOBUFS, &yes, sizeof(yes)) < 0)
+               ERROR("NETLINK_NO_EBUFS");
+
        memset(&rth->local, 0, sizeof(rth->local));
        rth->local.nl_family = AF_NETLINK;
        rth->local.nl_groups = subscriptions;