Make all netlink socket RCVBUF sizes configurable
diff mbox series

Message ID 1587148355-603-1-git-send-email-pavel.contrib@gmail.com
State New
Headers show
Series
  • Make all netlink socket RCVBUF sizes configurable
Related show

Commit Message

Pavel Shirshov April 17, 2020, 6:32 p.m. UTC
libteam often losses netlink messages on linux devices
with multiple network ports.

Read custom RCVBUF size from environment variable
TEAM_EVENT_BUFSIZE for all netlink sockets used by
libteam.

Signed-off-by: Pavel Shirshov <pavel.contrib@gmail.com>
---
 libteam/libteam.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

Comments

Jiri Pirko April 25, 2020, 7:30 a.m. UTC | #1
Fri, Apr 17, 2020 at 08:32:35PM CEST, pavel.contrib@gmail.com wrote:
>libteam often losses netlink messages on linux devices
>with multiple network ports.
>
>Read custom RCVBUF size from environment variable
>TEAM_EVENT_BUFSIZE for all netlink sockets used by
>libteam.
>
>Signed-off-by: Pavel Shirshov <pavel.contrib@gmail.com>

applied.

Patch
diff mbox series

diff --git a/libteam/libteam.c b/libteam/libteam.c
index 9c9c93a..2a9053b 100644
--- a/libteam/libteam.c
+++ b/libteam/libteam.c
@@ -600,12 +600,24 @@  int team_init(struct team_handle *th, uint32_t ifindex)
 		return -errno;
 	}
 
-	err = nl_socket_set_buffer_size(th->nl_sock, NETLINK_RCVBUF, 0);
+	env = getenv("TEAM_EVENT_BUFSIZE");
+	if (env) {
+		eventbufsize = strtol(env, NULL, 10);
+		/* ignore other errors, libnl forces minimum 32k and
+		 * too large values are truncated to system rmem_max
+		 */
+		if (eventbufsize < 0)
+			eventbufsize = 0;
+	} else {
+		eventbufsize = NETLINK_RCVBUF;
+	}
+
+	err = nl_socket_set_buffer_size(th->nl_sock, eventbufsize, 0);
 	if (err) {
 		err(th, "Failed to set buffer size of netlink sock.");
 		return -nl2syserr(err);
 	}
-	err = nl_socket_set_buffer_size(th->nl_sock_event, NETLINK_RCVBUF, 0);
+	err = nl_socket_set_buffer_size(th->nl_sock_event, eventbufsize, 0);
 	if (err) {
 		err(th, "Failed to set buffer size of netlink event sock.");
 		return -nl2syserr(err);
@@ -640,18 +652,6 @@  int team_init(struct team_handle *th, uint32_t ifindex)
 	nl_cli_connect(th->nl_cli.sock_event, NETLINK_ROUTE);
 	nl_socket_set_nonblocking(th->nl_cli.sock_event);
 
-	env = getenv("TEAM_EVENT_BUFSIZE");
-	if (env) {
-		eventbufsize = strtol(env, NULL, 10);
-		/* ignore other errors, libnl forces minimum 32k and
-		 * too large values are truncated to system rmem_max
-		 */
-		if (eventbufsize < 0)
-			eventbufsize = 0;
-	} else {
-		eventbufsize = NETLINK_RCVBUF;
-	}
-
 	err = nl_socket_set_buffer_size(th->nl_cli.sock_event, eventbufsize, 0);
 	if (err) {
 		err(th, "Failed to set cli event socket buffer size.");