From patchwork Mon Jul 1 07:05:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 11025141 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 6EA04138B for ; Mon, 1 Jul 2019 07:06:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B63428474 for ; Mon, 1 Jul 2019 07:06:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A6F0284ED; Mon, 1 Jul 2019 07:06:06 +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 C00DC28474 for ; Mon, 1 Jul 2019 07:06:05 +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 4B84A61518D1; Mon, 1 Jul 2019 07:06:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 4B84A61518D1 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 3ED11581C243A; Mon, 1 Jul 2019 07:06:04 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 7596B57B49531; Mon, 1 Jul 2019 07:06:01 +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 5D20F57B49531 for ; Mon, 1 Jul 2019 07:06:00 +0000 (UTC) Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (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 2E78098109 for ; Mon, 1 Jul 2019 07:06:00 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id p184so6077674pfp.7 for ; Mon, 01 Jul 2019 00:06:00 -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=dKTW9l5S5YqlXz/17RtEPWmq0jng29KdZ/Nf2RD8wYA=; b=NhXGVqAKFGYNZ8LCN51gxIZK8kXDrlQQtEUG2jdTaS/u9sPDDd87lIEF3mQxzQ26dQ ew+Hx2K7RkW6OVCFu3MxV4YIRVcSMGbgq20kba5HiOTIT0D5A+Emaw+WeejLn15rOqG3 9VmmMlcW4addCKcLkY8xPy1XqyuHpvg1Zl9fc2pl8F442lQekCnTWwoC85YX+4jUaKOo r3gaB1azH5C0OGCWiYVrGmEg5/Z9PKz3uclE77zqznzj4JXaEBJHekaaAPJZAZd04fME CQsjenCae9JinPc7FWEuGTVg1AZwuaqPqBxmoRbIgRCGDLFFUsitZiaM282XTn5lkB0t qKAA== X-Gm-Message-State: APjAAAVN9335VlNTzgyjTlt5EmZg/AOR+TysUDZhBHpT/U8GWbWGBvJM X+Y5Kg4sD5WKoyxRh6bBUg528FDq X-Google-Smtp-Source: APXvYqwSoMECrhLJtt6Dnv2NewOCLHbnN5KwSnbSP2iq9ZG4Rxiyi48FtTwiLx4599qjcu7R/p0hjg== X-Received: by 2002:a17:90b:f0f:: with SMTP id br15mr29771102pjb.101.1561964759109; Mon, 01 Jul 2019 00:05:59 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id d9sm8484077pgj.34.2019.07.01.00.05.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jul 2019 00:05:58 -0700 (PDT) From: Xin Long To: libteam@lists.fedorahosted.org Subject: [PATCH] teamd: return 0 if tdport doesn't exist in teamd_config_port_set Date: Mon, 1 Jul 2019 15:05:50 +0800 Message-Id: <29534b720f9317871ab4209978d1503bb261a473.1561964750.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 Message-ID-Hash: BBK5HY7YRXW7VPHREDUDTLRGNPGEGLF5 X-Message-ID-Hash: BBK5HY7YRXW7VPHREDUDTLRGNPGEGLF5 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 , Hangbin Liu 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 issue can be reproduced by doing: # ip link add dummy1 type dummy # teamd -t team0 -c '{"runner": {"name": "activebackup"}}' -d # teamdctl team0 port config update dummy1 '{"prio": -10}' # ip link set dummy0 master team0 and the error shows: libteamdctl: usock: Error message received: "ConfigUpdateFail" libteamdctl: usock: Error message content: "Failed to update config." command call failed (Invalid argument) It's a regression caused by Commit c8b356a3cd36 ("teamd: config: update local prio to kernel") where it requires the tdport has to exist when a tdport config is being updated. However teamd supports for the port config going first before the port being enslaved. This issue breaks how NM-team starts a team device. Here to fix it by returning 0 even if the tdport doesn't exist in teamd_config_port_set. While at it, also improve some error log and code type. Reported-by: Radek Vykydal Fixes: c8b356a3cd36 ("teamd: config: update local prio to kernel") Signed-off-by: Xin Long --- teamd/teamd_config.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/teamd/teamd_config.c b/teamd/teamd_config.c index 34fef1f..610ad5f 100644 --- a/teamd/teamd_config.c +++ b/teamd/teamd_config.c @@ -164,20 +164,22 @@ static int teamd_config_port_set(struct teamd_context *ctx, const char *port_nam tdport = teamd_get_port_by_ifname(ctx, port_name); if (!tdport) - return -ENODEV; + 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;