From patchwork Sun Jun 2 16:14:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitin Katiyar X-Patchwork-Id: 1108957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ericsson.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="JZJAcx/z"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45H3DQ15NCz9s4Y for ; Mon, 3 Jun 2019 02:14:45 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 45881AAE; Sun, 2 Jun 2019 16:14:42 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 605CC3EE for ; Sun, 2 Jun 2019 16:14:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140053.outbound.protection.outlook.com [40.107.14.53]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0A5F719B for ; Sun, 2 Jun 2019 16:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FNNMwvgKe3hqaPJCd8ppBmDpm54yKVx1n3d98zbkiNM=; b=JZJAcx/z3pZtUh8FchxEJBkfpN1jgiD8R3GVYfXcXAQnLc8o4P+VX4T6lXn+U0T85/yJ/S6RBwgYhVN9CLK5jMjVTTf1+YF42t8Epyq1lzGJR/4PmpuDn+tkMjuA0fJvWJCwGpmyVmE39jRO8i3JhJ1+invoyWwjDRQbanGoNHk= Received: from HE1PR0702MB3626.eurprd07.prod.outlook.com (52.133.6.24) by HE1PR0702MB3834.eurprd07.prod.outlook.com (52.133.7.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1943.15; Sun, 2 Jun 2019 16:14:35 +0000 Received: from HE1PR0702MB3626.eurprd07.prod.outlook.com ([fe80::8df8:f2f9:c16c:dcc7]) by HE1PR0702MB3626.eurprd07.prod.outlook.com ([fe80::8df8:f2f9:c16c:dcc7%7]) with mapi id 15.20.1965.007; Sun, 2 Jun 2019 16:14:35 +0000 From: Nitin Katiyar To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v2 2/2] Don't send or receive LACP PDUs when carrier state of slave is down Thread-Index: AQHVGV5EMl0sLW0UlU27BCIsztgitw== Date: Sun, 2 Jun 2019 16:14:34 +0000 Message-ID: <1559520927-22879-1-git-send-email-nitin.katiyar@ericsson.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [125.16.213.150] x-mailer: git-send-email 1.9.1 x-clientproxiedby: BMXPR01CA0014.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::24) To HE1PR0702MB3626.eurprd07.prod.outlook.com (2603:10a6:7:8c::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=nitin.katiyar@ericsson.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c027df0b-f51d-451c-6bb2-08d6e7756719 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:HE1PR0702MB3834; x-ms-traffictypediagnostic: HE1PR0702MB3834: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 005671E15D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(136003)(346002)(366004)(396003)(199004)(189003)(66476007)(66946007)(73956011)(66556008)(66446008)(64756008)(66066001)(68736007)(54906003)(305945005)(52116002)(6486002)(6436002)(5640700003)(6512007)(5660300002)(2501003)(478600001)(476003)(44832011)(71200400001)(256004)(486006)(4326008)(14454004)(25786009)(86362001)(55236004)(6506007)(71190400001)(386003)(186003)(5024004)(14444005)(102836004)(99286004)(2616005)(2351001)(26005)(50226002)(8936002)(81156014)(36756003)(7736002)(53936002)(3846002)(6116002)(81166006)(316002)(6916009)(8676002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0702MB3834; H:HE1PR0702MB3626.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: d129D3t63h7YYKL+DSt3+ByIbWlKipsl5347Sc93eTtrDLLKgeY9JYK0DEiYAOXh8V3rD2Bk910gYC1/vFZgbhpFiaMUgTKUEdp9S1YrdA9AO3zdI5190mC++xftA57E7ZyhP5J07SFPY1eV9qnn5f5ZkQ8vElDZD0y4tr8OcAR/qaRI2L/Rn1NVTVpsFz7bVnORDoLlBAQZod1pgbFGZr0LGoNRyZw9XUR9pfKr3mPJU610hKlXa13/2pdkLvCNMuP8xjKALPKqCR7CWI5wt+ogs2T4MU492If2PwQ6DhBtOde0vZNfWuNYyY/Ci+T7urs4LLUI0OGDi2JrH0WtSuDpnYKqb+6AUgHoyPFgyKGDXAW6x4M3qTtE+TWqTlHktxcqVq1SNO7Gyi5jhGyANbQAZGXrklFinepYW0rvtNA= MIME-Version: 1.0 X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-Network-Message-Id: c027df0b-f51d-451c-6bb2-08d6e7756719 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jun 2019 16:14:34.9910 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nitin.katiyar@ericsson.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0702MB3834 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Manohar Krishnappa Chidambaraswamy , Nitin Katiyar Subject: [ovs-dev] [PATCH v2 2/2] Don't send or receive LACP PDUs when carrier state of slave is down X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Problem: ======== On certain Fortville NICs it has been observed that PHY UP detection can get delayed (sometimes up to 4-5 secs). When the driver fails to fetch PHY status as UP even though its actually UP, LACP packets can get exchanged and LACP slave brought UP. In such a case, the remote end would start sending traffic on that slave, but OVS drops it, as the bond-slave is not yet enabled due to PHY DOWN. Fix: ==== The main intention here is delay LACP negotiation until carrier (PHY) status is read as UP. 1. When carrier state is DOWN, do not send any LACP PDUs and drop any received LACP PDUs. 2. When LACP PDU is received, trigger re-checking of carrier-state (in port_run()) by incrementing the connectivity sequence number to find out the true carrier state as fast as possible. Signed-off-by: Manohar Krishnappa Chidambaraswamy Co-authored-by: Manohar Krishnappa Chidambaraswamy Signed-off-by: Nitin Katiyar --- lib/lacp.c | 35 ++++++++++++++++++++++++++++++----- lib/lacp.h | 3 ++- ofproto/ofproto-dpif.c | 14 +++++++------- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/lib/lacp.c b/lib/lacp.c index e768012..16c823b 100644 --- a/lib/lacp.c +++ b/lib/lacp.c @@ -122,6 +122,7 @@ struct slave { enum slave_status status; /* Slave status. */ bool attached; /* Attached. Traffic may flow. */ + bool carrier_up; /* Carrier state of link. */ struct lacp_info partner; /* Partner information. */ struct lacp_info ntt_actor; /* Used to decide if we Need To Transmit. */ struct timer tx; /* Next message transmission timer. */ @@ -350,6 +351,16 @@ lacp_process_packet(struct lacp *lacp, const void *slave_, goto out; } + /* On some NICs L1 state reporting is slow. In case LACP packets are + * received while carrier (L1) state is still down, drop the LACP PDU and + * trigger re-checking of L1 state. */ + if (!slave->carrier_up) { + VLOG_INFO_RL(&rl, "%s: carrier state is DOWN," + " dropping received LACP PDU.", slave->name); + seq_change(connectivity_seq_get()); + goto out; + } + slave->status = LACP_CURRENT; tx_rate = lacp->fast ? LACP_FAST_TIME_TX : LACP_SLOW_TIME_TX; timer_set_duration(&slave->rx, LACP_RX_MULTIPLIER * tx_rate); @@ -456,7 +467,8 @@ lacp_slave_unregister(struct lacp *lacp, const void *slave_) /* This function should be called whenever the carrier status of 'slave_' has * changed. If 'lacp' is null, this function has no effect.*/ void -lacp_slave_carrier_changed(const struct lacp *lacp, const void *slave_) +lacp_slave_carrier_changed(const struct lacp *lacp, const void *slave_, + bool carrier_up) OVS_EXCLUDED(mutex) { struct slave *slave; @@ -473,7 +485,11 @@ lacp_slave_carrier_changed(const struct lacp *lacp, const void *slave_) if (slave->status == LACP_CURRENT || slave->lacp->active) { slave_set_expired(slave); } - slave->count_carrier_changed++; + + if (slave->carrier_up != carrier_up) { + slave->carrier_up = carrier_up; + slave->count_carrier_changed++; + } out: lacp_unlock(); @@ -498,11 +514,18 @@ lacp_slave_may_enable(const struct lacp *lacp, const void *slave_) { if (lacp) { struct slave *slave; - bool ret; + bool ret = false; lacp_lock(); slave = slave_lookup(lacp, slave_); - ret = slave ? slave_may_enable__(slave) : false; + if (slave) { + /* It is only called when carrier is up. So, enable slave's + * carrier state if it is currently down. */ + if (!slave->carrier_up) { + slave->carrier_up = true; + } + ret = slave_may_enable__(slave); + } lacp_unlock(); return ret; } else { @@ -820,7 +843,9 @@ slave_get_priority(struct slave *slave, struct lacp_info *priority) static bool slave_may_tx(const struct slave *slave) OVS_REQUIRES(mutex) { - return slave->lacp->active || slave->status != LACP_DEFAULTED; + /* Check for L1 state as well as LACP state. */ + return (slave->carrier_up) && ((slave->lacp->active) || + (slave->status != LACP_DEFAULTED)); } static struct slave * diff --git a/lib/lacp.h b/lib/lacp.h index 0dfaef0..d731ae9 100644 --- a/lib/lacp.h +++ b/lib/lacp.h @@ -60,7 +60,8 @@ struct lacp_slave_settings { void lacp_slave_register(struct lacp *, void *slave_, const struct lacp_slave_settings *); void lacp_slave_unregister(struct lacp *, const void *slave); -void lacp_slave_carrier_changed(const struct lacp *, const void *slave); +void lacp_slave_carrier_changed(const struct lacp *, const void *slave, + bool carrier_up); bool lacp_slave_may_enable(const struct lacp *, const void *slave); bool lacp_slave_is_current(const struct lacp *, const void *slave_); diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index db461ac..cb6baf3 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -3606,11 +3606,6 @@ ofport_update_peer(struct ofport_dpif *ofport) static bool may_enable_port(struct ofport_dpif *ofport) { - /* Carrier must be up. */ - if (!netdev_get_carrier(ofport->up.netdev)) { - return false; - } - /* If CFM or BFD is enabled, then at least one of them must report that the * port is up. */ if ((ofport->bfd || ofport->cfm) @@ -3636,12 +3631,17 @@ port_run(struct ofport_dpif *ofport) { long long int carrier_seq = netdev_get_carrier_resets(ofport->up.netdev); bool carrier_changed = carrier_seq != ofport->carrier_seq; + bool enable = netdev_get_carrier(ofport->up.netdev); + ofport->carrier_seq = carrier_seq; if (carrier_changed && ofport->bundle) { - lacp_slave_carrier_changed(ofport->bundle->lacp, ofport); + lacp_slave_carrier_changed(ofport->bundle->lacp, ofport, enable); + } + + if (enable) { + enable = may_enable_port(ofport); } - bool enable = may_enable_port(ofport); if (ofport->up.may_enable != enable) { ofproto_port_set_enable(&ofport->up, enable);