From patchwork Sun Jun 9 14:18:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitin Katiyar X-Patchwork-Id: 1112642 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="XNbJ9vd0"; 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 45MJK31Skwz9s9y for ; Mon, 10 Jun 2019 00:18:31 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0B0CAC74; Sun, 9 Jun 2019 14:18:16 +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 5B41CC6A for ; Sun, 9 Jun 2019 14:18:14 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60084.outbound.protection.outlook.com [40.107.6.84]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 28F1B7F8 for ; Sun, 9 Jun 2019 14:18:13 +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=fMlY3t936rwselGrjpUK5wVo7si4TgFHArINB6uDdzQ=; b=XNbJ9vd08zWjCUfYSB++i7NpP1SMF5Su3phRoDGUBjdSJvY8YWiYnzbCHBbFvASrscNun62oQ4uLDuI1JBZggfzpn+ACA4mUjKpMJElGda2hy0WCWzca5h/if9f5TkfvA/Hr3WwUxkWfoTdIwTLNJ0g3VCLDuGdbPee4qtfSBM8= Received: from HE1PR0702MB3626.eurprd07.prod.outlook.com (52.133.6.24) by HE1SPR01MB022.eurprd07.prod.outlook.com (10.170.245.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.3; Sun, 9 Jun 2019 14:18:11 +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.1987.010; Sun, 9 Jun 2019 14:18:11 +0000 From: Nitin Katiyar To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v3 2/2] Don't send or receive LACP PDUs when carrier state of slave is down Thread-Index: AQHVHs4qyNZjJu3CoEm0OR2OUa3pUg== Date: Sun, 9 Jun 2019 14:18:10 +0000 Message-ID: <1560118772-28225-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: BMXPR01CA0038.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::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: 5f0d596d-4cd4-4f75-6b93-08d6ece54d2c x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:HE1SPR01MB022; x-ms-traffictypediagnostic: HE1SPR01MB022: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:751; x-forefront-prvs: 006339698F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(366004)(396003)(346002)(39860400002)(136003)(199004)(189003)(3846002)(5640700003)(6436002)(316002)(2906002)(6116002)(5660300002)(6512007)(2501003)(50226002)(6486002)(2351001)(71200400001)(8936002)(68736007)(71190400001)(52116002)(81166006)(81156014)(66946007)(64756008)(66556008)(256004)(73956011)(26005)(14444005)(5024004)(54906003)(66446008)(99286004)(8676002)(86362001)(478600001)(4326008)(66476007)(386003)(305945005)(7736002)(25786009)(66066001)(55236004)(6916009)(53936002)(186003)(102836004)(14454004)(6506007)(36756003)(476003)(486006)(44832011)(2616005); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1SPR01MB022; 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: g5hyAHdz88UWw2msvgIu+kXhNdS4c8cM7L0JphELZBMZBaVC1MaQWbFK48rSI+FOcINhmTZTmCQwUh6RFa2NrH00+ffBahcz41WKKE5xPI0JeaggUOJMC4ax1tC0FYFAcee5HtmL+xBKN7yvnM+8beT0frz6FWTtq0pYNWMyr2fk/FnyA5j4GM0X7QzG6Cq2rS2Ttz4YNvwd62tGod6IRWAFTJwBhEYS70SeCiTK2i0m0tRii2t4FEnbPNGG5gC91SFhOHyAkZmLhb5iZ2op/9ORqDXINU9QcYKtYwa7yaV1V9KP74JSrP2gzOX+t3wZ18OuQn160TWtVL9ZR8LBvcevMrXm584SpGyGEPv31ofWE78vIz2S82OunUNW0PvWfrgBcKR0F4E8Dhyamxjndk42Oi32OYnEHLuMIuuv5rg= MIME-Version: 1.0 X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f0d596d-4cd4-4f75-6b93-08d6ece54d2c X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jun 2019 14:18:10.9984 (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: HE1SPR01MB022 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 v3 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 Fortville NICs (or their drivers) can get into an inconsistent state, in which the NIC can actually transmit and receive packets even though they report "PHY down". In such a state, OVS can exchange and process LACP messages and enable a LACP slave. However, further packet exchange over the slave fails because OVS sees that the PHY is down. This commit fixes the problem by making OVS ignore received LACP PDUs and suppress transmitting LACP PDUs when carrier is down. In addition, when a LACP PDU is received with carrier down, this commit triggers rechecking the carrier status (by incrementing the connectivity sequence number) to ensure that it is updated as quickly 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);