From patchwork Wed Apr 17 10:52:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 10905239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79A0F13B5 for ; Wed, 17 Apr 2019 10:52:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6145A28A92 for ; Wed, 17 Apr 2019 10:52:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 551AF28AC2; Wed, 17 Apr 2019 10:52:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AAE7228A92 for ; Wed, 17 Apr 2019 10:52:37 +0000 (UTC) Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id C88526076A1C; Wed, 17 Apr 2019 10:52:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org C88526076A1C Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id C13624EFCF661; Wed, 17 Apr 2019 10:52:36 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id E32104EFCF65E; Wed, 17 Apr 2019 10:52:32 +0000 (UTC) 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 D5FB74EFCF649 for ; Wed, 17 Apr 2019 10:52:31 +0000 (UTC) Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) (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 9C08298074 for ; Wed, 17 Apr 2019 10:52:31 +0000 (UTC) Received: by mail-pg1-x532.google.com with SMTP id d31so11834255pgl.7 for ; Wed, 17 Apr 2019 03:52:31 -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=MsOy6FyLHHQtaF3EWYfMlGTnzqzQVKfs4HdRO2EIf2o=; b=nVSem2DXc2gSUo3H3Z1QaUPwVrtusYpLubJBMlBl8wfpF8q2nBoHa3Ur53dPow8+3C SJhdBNfOMi0XYzb+fYIWJrl2QZfb1b6DmMz0oNqwFaF7DEajVxcOKD2vmUL6a55P5VsO d81CfrP9luGZdwhZ18IxLU53POqS3PNGeHWPfxwu0p4CaQj2H23qfInFGV7TtFn6JBxG aptTauCmCx+nrBBAnTP82LrNtNFH+HnoS65Xxg+eVdhqQRPRQ/Y43IRKVROLWSG4rAQS uxw2Hf4+9wFKGsNWzqlq4YzXE1zY2/0CE00TdtQWBJXrAPa0t0HVUzRt9JFCLlu4sbX5 /djg== X-Gm-Message-State: APjAAAXb9szydH5vvwv0j4OYJii7XE+6Qn7dL+OzrOEXOi+BcajZFbY+ MCOxdKKgHSY3fQTY1+T/qAroDxwN X-Google-Smtp-Source: APXvYqzHKWrrX+2MF4NZThuGA8CyElyyP7an/wNGOARNhWk3crvFDkfMEz435PZe701w7kCAKap6pg== X-Received: by 2002:a62:e501:: with SMTP id n1mr66242995pff.17.1555498350404; Wed, 17 Apr 2019 03:52:30 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id w189sm107201598pfw.147.2019.04.17.03.52.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 03:52:29 -0700 (PDT) From: Xin Long To: libteam@lists.fedorahosted.org Subject: [PATCHv3] teamd: add a default value 1000 for link_watch.interval Date: Wed, 17 Apr 2019 18:52:22 +0800 Message-Id: X-Mailer: git-send-email 2.1.0 Message-ID-Hash: OAUGUNCODBHCRFMM6OYTJVGMHFCWDFMT X-Message-ID-Hash: OAUGUNCODBHCRFMM6OYTJVGMHFCWDFMT X-MailFrom: lucien.xin@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: Hangbin Liu , Jiri Pirko , Jamie Bainbridge 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 X-Virus-Scanned: ClamAV using ClamSMTP From: Hangbin Liu As we don't have a default value for link_watch.interval. If a user forgets to set this parameter, teamd will fail to init ports' priv and exit in the end. e.g. teamd -g -c '{"runner":{"name":"activebackup"}, "link_watch":{"name":"arp_ping","target_host":"198.51.100.1"}}' teamdctl team0 port add p5p1 teamdctl team0 port add p5p2 teamd debug log shows: p5p2: Got link watch from global config. p5p2: Using sticky "0". Failed to get "interval" link-watch option. Failed to load options. Failed to init port priv. Callback named "lw_periodic" not found. Callback named "lw_socket" not found. Loop callback failed with: Invalid argument Failed loop callback: libteam_events, 0x5624c28b9410 select() failed. Exiting... Removed loop callback: usock_acc_conn, 0x5624c28bab60 Removed loop callback: usock, 0x5624c28b9410 Removed loop callback: workq, 0x5624c28b9410 Removed loop callback: libteam_events, 0x5624c28b9410 Removed loop callback: daemon, 0x5624c28b9410 Failed: Bad file descriptor Fix it by adding a default value for link_watch.interval. v2: update default value to 1000, as Jamie Bainbridge suggested. v3: fix the changelog to pass checkpatch.pl. Reported-by: LiLiang Reviewed-by: Jamie Bainbridge Signed-off-by: Hangbin Liu --- man/teamd.conf.5 | 10 ++++++++++ teamd/teamd_lw_psr.c | 11 ++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/man/teamd.conf.5 b/man/teamd.conf.5 index 5b0f3e9..9090b4a 100644 --- a/man/teamd.conf.5 +++ b/man/teamd.conf.5 @@ -308,6 +308,11 @@ Default: .TP .BR "link_watch.interval "| " ports.PORTIFNAME.link_watch.interval " (int) Value is a positive number in milliseconds. It is the interval between ARP requests being sent. +.RS 7 +.PP +Default: +.BR "1000" +.RE .TP .BR "link_watch.init_wait "| " ports.PORTIFNAME.link_watch.init_wait " (int) Value is a positive number in milliseconds. It is the delay between link watch initialization and the first ARP request being sent. @@ -371,6 +376,11 @@ Default: .TP .BR "link_watch.interval "| " ports.PORTIFNAME.link_watch.interval " (int) Value is a positive number in milliseconds. It is the interval between sending NS packets. +.RS 7 +.PP +Default: +.BR "1000" +.RE .TP .BR "link_watch.init_wait "| " ports.PORTIFNAME.link_watch.init_wait " (int) Value is a positive number in milliseconds. It is the delay between link watch initialization and the first NS packet being sent. diff --git a/teamd/teamd_lw_psr.c b/teamd/teamd_lw_psr.c index c0772db..ad6e56b 100644 --- a/teamd/teamd_lw_psr.c +++ b/teamd/teamd_lw_psr.c @@ -28,6 +28,7 @@ */ static const struct timespec lw_psr_default_init_wait = { 0, 1 }; +#define LW_PSR_DEFAULT_INTERVAL 1000 #define LW_PSR_DEFAULT_MISSED_MAX 3 #define LW_PERIODIC_CB_NAME "lw_periodic" @@ -77,9 +78,13 @@ static int lw_psr_load_options(struct teamd_context *ctx, int tmp; err = teamd_config_int_get(ctx, &tmp, "@.interval", cpcookie); - if (err) { - teamd_log_err("Failed to get \"interval\" link-watch option."); - return -EINVAL; + if (!err) { + if (tmp < 0) { + teamd_log_err("\"interval\" must not be negative number."); + return -EINVAL; + } + } else { + tmp = LW_PSR_DEFAULT_INTERVAL; } teamd_log_dbg("interval \"%d\".", tmp); ms_to_timespec(&psr_ppriv->interval, tmp);