@@ -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.");
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(-)