From patchwork Tue Nov 19 10:31:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 11251699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2A8F138C for ; Tue, 19 Nov 2019 10:31:29 +0000 (UTC) Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8C9E620718 for ; Tue, 19 Nov 2019 10:31:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C9E620718 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=libteam-bounces@lists.fedorahosted.org Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id DCA7060478E2; Tue, 19 Nov 2019 10:31:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org DCA7060478E2 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id D17C65A552D2B; Tue, 19 Nov 2019 10:31:28 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 78537200A3071; Tue, 19 Nov 2019 10:31:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mailman01.phx2.fedoraproject.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=disabled version=3.4.0 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 A325359865F7D for ; Tue, 19 Nov 2019 10:31:20 +0000 (UTC) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (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 37751605D2E0 for ; Tue, 19 Nov 2019 10:31:20 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id q26so11933449pfn.11 for ; Tue, 19 Nov 2019 02:31:20 -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=gD2VMsjtUoqcMh2GMXQSGPY3j9jKWdFD/U7rWM6VDlw=; b=qh1IwSB0HUXZ3uIk7KHvfuQw5kgUDev3pWCElsymTOWezFyztptLmfEYsQCIP0qoE8 oml6rVS2ttiNoax7JJxOLIEJz3L06M6pYjg6ScMdQcyXIchNqFyQSJWfOUxozI9GCOUA GcsRwfwpaNFlWNUU+AjpBt0CgvqYeU8M7fdetaW/bqjhzF+hECwLhgLUCMix81QUzbQR MGBbwCz85u3n+1bRmykKa2aT5uPJM29pnGsHTynIvgsvU8rXCkdFGuUPqXsy55zCGUUk M63U13dPPAhHhJgcvj16SCHdA7pyiihlHzFYzvxkJW5Jpm6sA6MgFeulFeesc9QoAO5c 4vwQ== X-Gm-Message-State: APjAAAX6Ppyxn7A3uu8W7tpnnI1PsS3581Nki+esuqkrRQ6UMj5XbABE 09p/FEleOm7IwXD4W5xdDJYsL+OWjtJNyQ== X-Google-Smtp-Source: APXvYqz4N6GNvPKAgI3SlLX+K3mO4TQmS7ad/W4P27mLk17DGJsfI2JFYQ14hhJaIHpzP6fLpjYjbQ== X-Received: by 2002:a63:1f08:: with SMTP id f8mr1816206pgf.145.1574159478736; Tue, 19 Nov 2019 02:31:18 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id l21sm2750852pjt.28.2019.11.19.02.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2019 02:31:17 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [libteam PATCH] teamd: update ctx->hwaddr after setting ctx->ifindex to new hwaddr Date: Tue, 19 Nov 2019 18:31:00 +0800 Message-Id: <20191119103100.9687-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Message-ID-Hash: JI42VHTIXH5ER7IKH4R4AM6RVBRWOKVB X-Message-ID-Hash: JI42VHTIXH5ER7IKH4R4AM6RVBRWOKVB 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: Hangbin Liu , jiri@resnulli.us X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: When we add the first slave to team port, we will update ctx->ifindex with new hwaddr in function teamd_event_watch_port_added() - teamd_hwaddr_check_change(), But we didn't update the ctx->hwaddr, which will cause the first added slave set to team's init hwaddr again later. e.g. in the following functions lacp_port_set_mac() lb_event_watch_port_added() ab_hwaddr_policy_same_all_port_added(). The tdport's hwaddr will be reset based on ctx->hwaddr. Fix it by updating ctx->hwaddr when set ctx->ifindex to new hwaddr. Note: function teamd_set_hwaddr() is not considered as it will set ctx->hwaddr_explicit = true. Signed-off-by: Hangbin Liu --- teamd/teamd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/teamd/teamd.c b/teamd/teamd.c index 6c47312..9622da1 100644 --- a/teamd/teamd.c +++ b/teamd/teamd.c @@ -867,7 +867,7 @@ static int teamd_add_ports(struct teamd_context *ctx) static int teamd_hwaddr_check_change(struct teamd_context *ctx, struct teamd_port *tdport) { - const char *hwaddr; + char *hwaddr; unsigned char hwaddr_len; int err; @@ -885,6 +885,8 @@ static int teamd_hwaddr_check_change(struct teamd_context *ctx, teamd_log_err("Failed to set team device hardware address."); return err; } + ctx->hwaddr = hwaddr; + ctx->hwaddr_len = hwaddr_len; return 0; }