From patchwork Fri Apr 17 18:32:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shirshov X-Patchwork-Id: 11495907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22C46174A for ; Fri, 17 Apr 2020 18:32:52 +0000 (UTC) Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DDA1520780 for ; Fri, 17 Apr 2020 18:32:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDA1520780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=libteam-bounces@lists.fedorahosted.org Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id 3F04264AE418; Fri, 17 Apr 2020 18:32:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 3F04264AE418 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 23F7A5DF46E5A; Fri, 17 Apr 2020 18:32:51 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 64C2E5DF466BA; Fri, 17 Apr 2020 18:32:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mailman01.phx2.fedoraproject.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=disabled version=3.4.0 Received: from smtp-mm-osuosl01.fedoraproject.org (smtp-mm-osuosl01.vpn.fedoraproject.org [192.168.1.23]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 832065DE9AD98 for ; Fri, 17 Apr 2020 18:32:46 +0000 (UTC) Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by smtp-mm-osuosl01.fedoraproject.org (Postfix) with ESMTPS id C30E298051 for ; Fri, 17 Apr 2020 18:32:45 +0000 (UTC) Received: by mail-pj1-x1041.google.com with SMTP id ng8so1479508pjb.2 for ; Fri, 17 Apr 2020 11:32:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QAom84PWraLmbO5+Fn199UCQ2+wOqjJ1gJRhTbMYB3U=; b=eFLd6k7ZEDfQPNSNnVn/heFJPjOQyx3zO+NghXMREemJ/txxd3esaLgucVsczgWRAE /MdaKXX44i5SmTzqMlxoIvxCO1QYn5LhHHxWCKk16JWbQPpNc2FENh5ouKROl9jx3tHO /IEZgVTkN5JpBQkJZOOx8SVcqvZADSe8b/ipr1P3xprwbcv3y2pG0M5Om5HVxQQJNCm0 YMtiSs8xdKRhhNGKEkfSRpxB2Q3OIwZ4klNS9fmZvABagdrlPcZjD1hKnbyo/4o0BBnS ZISWKA78elHy4JztRSDme0rZ1zNk1NaUWG73gS67pBoB/q1CqoIKMK8Wb9Zh7NHE4mRW osHA== X-Gm-Message-State: AGi0PuanS1+97XYcJJQ5eFn17RuhaPjEEYxDRDEt5xA8xQBeVcb/h21i d6+7/Lm32zwEkLIM6IBUTHezShon X-Google-Smtp-Source: APiQypJof/mR7alOMHFXY9jN8R3f79S1tdagSgmONqbG0eT9z3QJFP+w5Fq945wdqncqlqaCO5aRvw== X-Received: by 2002:a17:902:8f89:: with SMTP id z9mr4854394plo.2.1587148364949; Fri, 17 Apr 2020 11:32:44 -0700 (PDT) Received: from localhost.localdomain (50-47-139-32.evrt.wa.frontiernet.net. [50.47.139.32]) by smtp.gmail.com with ESMTPSA id r26sm15636329pfq.75.2020.04.17.11.32.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Apr 2020 11:32:44 -0700 (PDT) From: Pavel Shirshov To: libteam@lists.fedorahosted.org Subject: [PATCH] Make all netlink socket RCVBUF sizes configurable Date: Fri, 17 Apr 2020 11:32:35 -0700 Message-Id: <1587148355-603-1-git-send-email-pavel.contrib@gmail.com> X-Mailer: git-send-email 2.7.4 Message-ID-Hash: EH7NJDY7H4BY3AFHIEV7QNOW5CO4FAMA X-Message-ID-Hash: EH7NJDY7H4BY3AFHIEV7QNOW5CO4FAMA X-MailFrom: pavel.contrib@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: jiri@resnulli.us X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- libteam/libteam.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) 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.");