From patchwork Thu Mar 7 02:47:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 10842193 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 5427E14DE for ; Thu, 7 Mar 2019 02:48:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CF172E82D for ; Thu, 7 Mar 2019 02:48:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20CBF2EC85; Thu, 7 Mar 2019 02:48:08 +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 B0FE32E82D for ; Thu, 7 Mar 2019 02:48:07 +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 DCBC26076F63; Thu, 7 Mar 2019 02:48:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org DCBC26076F63 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id D28074EB97FE9; Thu, 7 Mar 2019 02:48:06 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 0E2194EB97FE9; Thu, 7 Mar 2019 02:48: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 CE1644EB97FD3 for ; Thu, 7 Mar 2019 02:48:01 +0000 (UTC) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (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 59537605D2D8 for ; Thu, 7 Mar 2019 02:48:01 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id g6so10208865pfh.13 for ; Wed, 06 Mar 2019 18:48: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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jsRyLZLSKQKJvmoRwWc2BghYLCpdMtW1TxLFKQN4ayI=; b=r6jDzFPONyAVDPFw4GYBV3SmbFf+aBeNbBd0LshkA08usNuRDdTdinn9cw279Wkc6Q 8kefSdqQQhsRLhWcwXbkCiIFo+BZVpQ+673VL3pQ1pvcZVdxH82jGcDzRRDIgrSuCKMy EAx18HmIOYpewemk06PHO+y5mD0CysVtKW+mTLxdeFC+IwHzBoyNJglwqS3UUlCrsLhH c3gAgUWqanvoY/zh3zcHZdSd1jH91YTjWpV7bQpJWsKl679XycGWpwqKowuOGMHZQYl5 hVcrO77+VlEizR71gJlyLxkum6hShCjuuXG2rtSJ0pevGPzsRgv7DwEE5njrJHFBN6tr SCwA== X-Gm-Message-State: APjAAAWqIBli0jXnAMhjinL7XyPMDKox74lANwedLuoit42Da2oVVnqc od5UW2aPY0c22E/sPjbNGe7XlbYN X-Google-Smtp-Source: APXvYqxNh7sTIxlZx94CjCfjzwSHKxWpQSaqkMTOMbyXEEbKwa5khtg/dDYE6Pmea7PdtJIcrWSF+g== X-Received: by 2002:a17:902:7d84:: with SMTP id a4mr10552706plm.76.1551926880170; Wed, 06 Mar 2019 18:48:00 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id k74sm5397355pfb.172.2019.03.06.18.47.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Mar 2019 18:47:59 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [patchv2 libteam] teamd: lacp: update port state according to partner's sync bit Date: Thu, 7 Mar 2019 10:47:43 +0800 Message-Id: <20190307024743.7836-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190130100213.28960-1-liuhangbin@gmail.com> References: <20190130100213.28960-1-liuhangbin@gmail.com> MIME-Version: 1.0 Message-ID-Hash: 5IIY3IL6JIIDZXQQ6FR75KPHMRRUDJU2 X-Message-ID-Hash: 5IIY3IL6JIIDZXQQ6FR75KPHMRRUDJU2 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 According to 6.4.15 of IEEE 802.1AX-2014, Figure 6-22, the state that the port is selected moves MUX state from DETACHED to ATTACHED. But ATTACHED sate does not mean that the port can send and receive user frames. COLLECTING_DISTRIBUTION state is the sate that the port can send and receive user frames. To move MUX state from ATTACHED to COLLECTING_DISTRIBUTION, the partner state should be sync as well as the port selected. In function lacp_port_actor_update(), only INFO_STATE_SYNCHRONIZATION should be set to the actor.state when the port is selected. INFO_STATE_COLLECTING and INFO_STATE_DISTRIBUTING should be set to false with ATTACHED mode and set to true when INFO_STATE_SYNCHRONIZATION of partner.state is set. In function lacp_port_should_be_{enabled, disabled}(), we also need to check the INFO_STATE_SYNCHRONIZATION bit of partner.state. Reported-by: Cisco Systems Signed-off-by: Hangbin Liu --- teamd/teamd_runner_lacp.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c index 7b8f0a7..4de30f3 100644 --- a/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c @@ -333,7 +333,8 @@ static int lacp_port_should_be_enabled(struct lacp_port *lacp_port) struct lacp *lacp = lacp_port->lacp; if (lacp_port_selected(lacp_port) && - lacp_port->agg_lead == lacp->selected_agg_lead) + lacp_port->agg_lead == lacp->selected_agg_lead && + lacp_port->partner.state & INFO_STATE_SYNCHRONIZATION) return true; return false; } @@ -343,7 +344,8 @@ static int lacp_port_should_be_disabled(struct lacp_port *lacp_port) struct lacp *lacp = lacp_port->lacp; if (!lacp_port_selected(lacp_port) || - lacp_port->agg_lead != lacp->selected_agg_lead) + lacp_port->agg_lead != lacp->selected_agg_lead || + !(lacp_port->partner.state & INFO_STATE_SYNCHRONIZATION)) return true; return false; } @@ -914,9 +916,13 @@ static void lacp_port_actor_update(struct lacp_port *lacp_port) if (lacp_port->lacp->cfg.fast_rate) state |= INFO_STATE_LACP_TIMEOUT; if (lacp_port_selected(lacp_port) && - lacp_port_agg_selected(lacp_port)) - state |= INFO_STATE_SYNCHRONIZATION | - INFO_STATE_COLLECTING | INFO_STATE_DISTRIBUTING; + lacp_port_agg_selected(lacp_port)) { + state |= INFO_STATE_SYNCHRONIZATION; + state &= ~(INFO_STATE_COLLECTING | INFO_STATE_DISTRIBUTING); + if (lacp_port->partner.state & INFO_STATE_SYNCHRONIZATION) + state |= INFO_STATE_COLLECTING | + INFO_STATE_DISTRIBUTING; + } if (lacp_port->state == PORT_STATE_EXPIRED) state |= INFO_STATE_EXPIRED; if (lacp_port->state == PORT_STATE_DEFAULTED)