Patchwork hostap: Ensure netlink recv buf size is large enough.

login
register
mail settings
Submitter Ben Greear
Date April 4, 2012, 5:06 a.m.
Message ID <1333516005-28168-1-git-send-email-greearb@candelatech.com>
Download mbox | patch
Permalink /patch/150596/
State Superseded
Headers show

Comments

Ben Greear - April 4, 2012, 5:06 a.m.
From: Ben Greear <greearb@candelatech.com>

I was getting this error on wpa_supplicant startup when configured
for 200+ stations:

1333514002.074458: netlink: recvfrom failed: No buffer space available

So, increase rcv buffer size to 1MB so we don't drop netlink
packets.

Signed-hostap: Ben Greear <greearb@candelatech.com>
Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 dd662f3... 930acc4... M	src/drivers/netlink.c
 src/drivers/netlink.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

Patch

diff --git a/src/drivers/netlink.c b/src/drivers/netlink.c
index dd662f3..930acc4 100644
--- a/src/drivers/netlink.c
+++ b/src/drivers/netlink.c
@@ -92,6 +92,7 @@  struct netlink_data * netlink_init(struct netlink_config *cfg)
 {
 	struct netlink_data *netlink;
 	struct sockaddr_nl local;
+	int rsize;
 
 	netlink = os_zalloc(sizeof(*netlink));
 	if (netlink == NULL)
@@ -118,6 +119,18 @@  struct netlink_data * netlink_init(struct netlink_config *cfg)
 		return NULL;
 	}
 
+	/* Set the rcv buffer large so we don't drop netlink messages
+	 * on heavily loaded systems.
+	 */
+	rsize = 1024 * 1024;
+	if (setsockopt(netlink->sock, SOL_SOCKET, SO_RCVBUF,
+		       (char *)&rsize, sizeof(rsize)) < 0) {
+		wpa_printf(MSG_ERROR,
+			   "netlink: Failed setting rcv buffer to: %i: %s\n",
+			   rsize, strerror(errno));
+		/* Not the end of the world..continue */
+	}
+
 	eloop_register_read_sock(netlink->sock, netlink_receive, netlink,
 				 NULL);