From patchwork Mon Mar 4 06:35:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 10837383 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 57B931399 for ; Mon, 4 Mar 2019 06:36:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45C59289BC for ; Mon, 4 Mar 2019 06:36:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39F6C29D79; Mon, 4 Mar 2019 06:36:07 +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 24F5C289BC for ; Mon, 4 Mar 2019 06:36:06 +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 75E2B6077CC6; Mon, 4 Mar 2019 06:36:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 75E2B6077CC6 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 6C0E13240EC35; Mon, 4 Mar 2019 06:36:05 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 52C5F3240EC3F; Mon, 4 Mar 2019 06:36:03 +0000 (UTC) Received: from smtp-mm-ib01.fedoraproject.org (smtp-mm-ib01.vpn.fedoraproject.org [192.168.1.83]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 7B5663240EC35 for ; Mon, 4 Mar 2019 06:36:02 +0000 (UTC) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) (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-ib01.fedoraproject.org (Postfix) with ESMTPS id 03B10605D26B for ; Mon, 4 Mar 2019 06:36:02 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id g6so2244129pfh.13 for ; Sun, 03 Mar 2019 22:36:01 -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:mime-version :content-transfer-encoding; bh=vEjkiB1kuO8PdJAFWGvkTcGwFyURqbt57kvN6KCuvh4=; b=IClmKgX0dNNwlRnreJPB7gzzlC56kHL3/JwdzRI8ZADkesVyBqYTWhZArG2QFOm6Hb WKNsIoP9tAn2n4rHSaXuv7/ooUKCpGlmtGZ/b9zTGpabqAFRMemq+h7obVjsuqpIwq4e uP9xTiItsslKDHRA6R7gn4FOnxqJt6bQOROJgMcdE93AyMWlsMWDv9nb5z1dc8g9FuUD ZygaQokdfAEE6Y2fLRU2HRbFK5aDeg8G3nyU1VmSdhEY1I5kvBqjVD3OMtN0lUfpUZ68 9R6lVwk7QlubsomJ2paD88pnXnKxVXvmlVsVmY+Ays2EtriU3dX3oMW1vdEf00Fbgwjo S6Ow== X-Gm-Message-State: APjAAAXZIDyDyy/hX8T5ttw7S2T99wA6gZXbg8DzUJVPsNlIYm+UpknZ JVnEV/5F9eRSi6gPUXCeShkxttVS X-Google-Smtp-Source: APXvYqxkImht3eLgz6lEwL8aP5bT6aLDtO2thyU0zVBZIDoIBxnaL6cnH4X6hyZzwLOKuf5ooAVrhw== X-Received: by 2002:a65:6642:: with SMTP id z2mr17243030pgv.196.1551681360561; Sun, 03 Mar 2019 22:36:00 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id n10sm7114891pfa.139.2019.03.03.22.35.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Mar 2019 22:35:59 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [patch libteam] teamd: add a default value 100 for link_watch.interval Date: Mon, 4 Mar 2019 14:35:44 +0800 Message-Id: <20190304063544.12297-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Message-ID-Hash: KMBPCA2255KAIWE2OJNTQFKDYXTHN6G3 X-Message-ID-Hash: KMBPCA2255KAIWE2OJNTQFKDYXTHN6G3 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: Jiri Pirko , 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. 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..6d5374a 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 "100" +.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 "100" +.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..3ddf295 100644 --- a/teamd/teamd_lw_psr.c +++ b/teamd/teamd_lw_psr.c @@ -29,6 +29,7 @@ static const struct timespec lw_psr_default_init_wait = { 0, 1 }; #define LW_PSR_DEFAULT_MISSED_MAX 3 +#define LW_PSR_DEFAULT_INTERVAL 100 #define LW_PERIODIC_CB_NAME "lw_periodic" static int lw_psr_callback_periodic(struct teamd_context *ctx, int events, void *priv) @@ -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);