From patchwork Tue Mar 5 03:41:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 10838901 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 4BBFE922 for ; Tue, 5 Mar 2019 03:42:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 383E22BC47 for ; Tue, 5 Mar 2019 03:42:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B3912BD62; Tue, 5 Mar 2019 03:42:17 +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 AFB0A2BC47 for ; Tue, 5 Mar 2019 03:42:16 +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 E12716074A6A; Tue, 5 Mar 2019 03:42:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org E12716074A6A Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id DCF064EB68C69; Tue, 5 Mar 2019 03:42:15 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id C2F0A4EB68C69; Tue, 5 Mar 2019 03:42:13 +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 337444EB68C67 for ; Tue, 5 Mar 2019 03:42:13 +0000 (UTC) Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (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 E318F98433 for ; Tue, 5 Mar 2019 03:42:12 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id q206so4609660pgq.4 for ; Mon, 04 Mar 2019 19:42:12 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=8isQLLQ1xMWimVG9695rZgouBb1RYWynRoT8KgBtaOs=; b=s5wqZKyB7AZZlBkVAywTzCP/zNyfHBLxEngm3EXHjPSFQw6JylDYxLuXPXp0abbWvz hNQKXl5cC+y7gWnF71mxgU/mSXaZuBehzL5pR/qSjD2W229AQGdmf5TkmXDcs4gJSEU0 tc9z9ev4PMFFWSkV94n666qffOTQAsaLHguzPxOwJ2zE6g0TRYboSPDuQFOhreEmXdIL VWQWj17lNOu34cexuRKbL3QDplNNmx0U1EIAiwZa4+CGHef68EztvcVvNYCGkLwZe7lp OEbHZvA6pGljk0C3UYMurNoSU45lufqml8xUsahR9x90/CWjXb2WVpnIijlA8pwbt4WD LTXg== X-Gm-Message-State: APjAAAVnxuxT2f7+pzDSxqiCowok2YTFRZNE8Tl6Wjq2H1eYGwHh9aQs G4znibc5cxO97Me4zz9vRTxuI/uYZmY= X-Google-Smtp-Source: APXvYqzk25wpsV+F8dANvYIWXbfIrMytXTVS6r66te8G/n2JxiTquxnyhTdSbh900BEnBiNsDfSqFQ== X-Received: by 2002:a17:902:7613:: with SMTP id k19mr18528315pll.207.1551757332261; Mon, 04 Mar 2019 19:42:12 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 63sm12112873pfy.110.2019.03.04.19.42.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Mar 2019 19:42:11 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [patchv2 libteam] teamd: add a default value 1000 for link_watch.interval Date: Tue, 5 Mar 2019 11:41:56 +0800 Message-Id: <20190305034156.7953-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190304063544.12297-1-liuhangbin@gmail.com> References: <20190304063544.12297-1-liuhangbin@gmail.com> MIME-Version: 1.0 Message-ID-Hash: LKQBGSAZFT63GQFF34WADFAI53EGCSUY X-Message-ID-Hash: LKQBGSAZFT63GQFF34WADFAI53EGCSUY X-MailFrom: liuhangbin@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: Jamie Bainbridge , Hangbin Liu X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-Virus-Scanned: ClamAV using ClamSMTP As we don't have a default value for link_watch.interval. If user forgot to set this parameter, teamd will failed to init port priv and exit at 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. Reported-by: LiLiang 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 9bdf46a..43b09aa 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);