From patchwork Tue Jul 2 11:33:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 11027707 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 8DF051510 for ; Tue, 2 Jul 2019 11:34:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 791A9284AA for ; Tue, 2 Jul 2019 11:34:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DA86288D7; Tue, 2 Jul 2019 11:34:12 +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 0D02B288D4 for ; Tue, 2 Jul 2019 11:34:11 +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 DB43C625AB18; Tue, 2 Jul 2019 11:34:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org DB43C625AB18 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id D5C3B581D769B; Tue, 2 Jul 2019 11:34:09 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id B63C4581CE660; Tue, 2 Jul 2019 11:34:06 +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 36C39581B293E for ; Tue, 2 Jul 2019 11:34:06 +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 CC467605D2E1 for ; Tue, 2 Jul 2019 11:34:05 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id 81so8104116pfy.13 for ; Tue, 02 Jul 2019 04:34:05 -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=nX++v02IqQbdIpDP/QDn4d7W7SQBm4BIXw2zK+vb50I=; b=rOb/myOxJ8WoBJB2KmKM+WRQsaYthbGnP8JyvJAxf3OKmHwJHYu9H3vF+NiTOYdFou EgRFBCRueYDHEt+83tFDvmUexnssueA4GGTXDmkKPbX4KUuQdYTQOEEblRtNjJQ+CQdy WpMj6BrM8/hcqIs4yje7QsJoEnCuzBx1NugVf5qeOFbcgZaK9nbNQfZCWk7QJsLRWbaH SNyMTUcY+JjBs5cl5YgdeGZZ1bs96ONB08Jy7zBLNY9JFQzzgcxLeCFWPnKInfdubUFa w5VFbHVbE67ITjn9rZ/q+bBqj+3ei049utOc5+HWQmq+2SF6Bl4ZqnLKQ2ekP9llZwAl 2xKg== X-Gm-Message-State: APjAAAWiPmt9b0AOizTOKrS1usRozCT7VpqN5Gnzy2haKIdpYVxrNE5k aM3sFvKmNFCfAARngdEl67w4fdPA X-Google-Smtp-Source: APXvYqys1RTt5Fv53w7N3lLPIr+Dx0vFBMohesve7hLe+X5cDfwur0AO8l32q172+ghIyMGHwLX20A== X-Received: by 2002:a17:90a:de02:: with SMTP id m2mr5115433pjv.18.1562067244248; Tue, 02 Jul 2019 04:34:04 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id f7sm13706341pfd.43.2019.07.02.04.34.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jul 2019 04:34:03 -0700 (PDT) From: Xin Long To: libteam@lists.fedorahosted.org Subject: [PATCH] teamd: improve the error output for non-integer port prio Date: Tue, 2 Jul 2019 19:33:56 +0800 Message-Id: <56d8b977834692b0b4829fd0727acdbd7a0a1dd2.1562067236.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 Message-ID-Hash: 73A656SJNLSPPJWQCO5AEUORKKGTMAVU X-Message-ID-Hash: 73A656SJNLSPPJWQCO5AEUORKKGTMAVU 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: Jiri Pirko 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 This patch is to improve the error log when users pass a non-integer value to set port's prio. After that, we can remove the error output for teamd_config_port_set failure from teamd_config_port_update. Signed-off-by: Xin Long --- teamd/teamd_config.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/teamd/teamd_config.c b/teamd/teamd_config.c index 1bf85ac..610ad5f 100644 --- a/teamd/teamd_config.c +++ b/teamd/teamd_config.c @@ -167,17 +167,19 @@ static int teamd_config_port_set(struct teamd_context *ctx, const char *port_nam return 0; config = json_object_get(port_obj, "prio"); - if (json_is_integer(config)) { - tmp = json_integer_value(config); - err = team_set_port_priority(ctx->th, tdport->ifindex, tmp); - if (err) { - teamd_log_err("%s: Failed to set \"priority\".", - tdport->ifname); - return err; - } + if (!json_is_integer(config)) { + teamd_log_err("%s: Failed to get integer for \"priority\".", + tdport->ifname); + return -ENOENT; } - return 0; + tmp = json_integer_value(config); + err = team_set_port_priority(ctx->th, tdport->ifindex, tmp); + if (err) + teamd_log_err("%s: Failed to update \"priority\" to kernel", + tdport->ifname); + + return err; } int teamd_config_port_update(struct teamd_context *ctx, const char *port_name, @@ -206,16 +208,14 @@ int teamd_config_port_update(struct teamd_context *ctx, const char *port_name, /* replace existing object content */ json_object_clear(port_obj); err = json_object_update(port_obj, port_new_obj); - if (err) + if (err) { teamd_log_err("%s: Failed to update existing config " "port object", port_name); - else { - err = teamd_config_port_set(ctx, port_name, port_new_obj); - if (err) - teamd_log_err("%s: Failed to update config to kernel", - port_name); + goto new_port_decref; } + err = teamd_config_port_set(ctx, port_name, port_new_obj); + new_port_decref: json_decref(port_new_obj); return err;