From patchwork Mon Jan 7 07:58:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 10750095 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 2866E13B4 for ; Mon, 7 Jan 2019 07:59:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19F381FF7F for ; Mon, 7 Jan 2019 07:59:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E49126861; Mon, 7 Jan 2019 07:59:15 +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 998E71FF7F for ; Mon, 7 Jan 2019 07:59:14 +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 E0D63606ED63; Mon, 7 Jan 2019 07:59:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org E0D63606ED63 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id DD9B03AC717E6; Mon, 7 Jan 2019 07:59:13 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 253D93AC717E8; Mon, 7 Jan 2019 07:59:10 +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 B5FCB3AC717E6 for ; Mon, 7 Jan 2019 07:59:09 +0000 (UTC) Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by smtp-mm-osuosl01.fedoraproject.org (Postfix) with ESMTPS id 71E3F98057 for ; Mon, 7 Jan 2019 07:59:09 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id a14so20480017plm.12 for ; Sun, 06 Jan 2019 23:59:09 -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=ns2xlg294XWBOllVthxy/Q1Nc3uE4IwGz4FnAW5VIAw=; b=NUCuZNmKC1j53ucPLzthjF0n+1hcq7MXDYBTM44a18exr80IOesNauq+g9jJ4zgJHz ZvA/QYRm9Cyny8OYASg+3yBkVeGykNfpMyfiCE3+1l2W7mK0EOemx/0hd0mL1MBZqLdN T67Q26ZQh7TTObECKoBdFAulquSX08b33hQSzGsbdICpjFQq4AzUbCNKuyJrNvHJ55rK /uExID0MX5m/5+306KCiJLO2ycYkPrIAu/Q2B3Y8ZcX0PR5Zj+XNGr4yPtzS2lM/vh8F LLeslEzUlOPCdvOjBiNkkRYkl4pOFgpbFnQHobKmYKtqxEmpIO2nGlpbrKzrkxlzcTzO LXMg== X-Gm-Message-State: AJcUukdPFP38tmcg4vgPv9fGPEgKV1UO4H2afg6vLD948cZvxjdN1/g1 oXAb2txiyEdG4a8f7KGM5sC6v3UZ X-Google-Smtp-Source: ALg8bN5XEyoJJ8tMJFmMWZdA+Lv7ECZFEjbsAuN8dRJVYioJgwYoxNagVM9XROHG2uUq76ZwMGV1rA== X-Received: by 2002:a17:902:7848:: with SMTP id e8mr61581307pln.100.1546847948746; Sun, 06 Jan 2019 23:59:08 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id d13sm100610180pfd.58.2019.01.06.23.59.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 06 Jan 2019 23:59:08 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [patch libteam] teamd: config: update local prio to kernel Date: Mon, 7 Jan 2019 15:58:49 +0800 Message-Id: <20190107075849.6509-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Message-ID-Hash: GTXRC7GG5UVCW7ULWSIVFS7M24IYFJI7 X-Message-ID-Hash: GTXRC7GG5UVCW7ULWSIVFS7M24IYFJI7 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 Team port's priority will affect the active port selection. Update the local config is not enough. We also need to update kernel configs. Reported-by: Liang Li Signed-off-by: Hangbin Liu --- teamd/teamd_config.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/teamd/teamd_config.c b/teamd/teamd_config.c index 94158ce..69b25de 100644 --- a/teamd/teamd_config.c +++ b/teamd/teamd_config.c @@ -155,6 +155,31 @@ errout: return err; } +static int teamd_config_port_set(struct teamd_context *ctx, const char *port_name, + json_t *port_obj) +{ + struct teamd_port *tdport; + json_t *config; + int tmp, err; + + tdport = teamd_get_port_by_ifname(ctx, port_name); + if (!tdport) + return -ENODEV; + + 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; + } + } + + return 0; +} + int teamd_config_port_update(struct teamd_context *ctx, const char *port_name, const char *json_port_cfg_str) { @@ -184,6 +209,13 @@ int teamd_config_port_update(struct teamd_context *ctx, const char *port_name, 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); + } + new_port_decref: json_decref(port_new_obj); return err;