From patchwork Tue Mar 5 12:47:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitin Katiyar X-Patchwork-Id: 1051725 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="QeZY32+F"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="WH6D5ovb"; 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 44DH7y1N8fz9s3q for ; Wed, 6 Mar 2019 00:01:02 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CAA1DF5AA; Tue, 5 Mar 2019 13:00:04 +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 A1344F59B for ; Tue, 5 Mar 2019 12:47:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sessmg22.ericsson.net (sessmg22.ericsson.net [193.180.251.58]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 47B2E2D4 for ; Tue, 5 Mar 2019 12:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1551790039; x=1554382039; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZCSIYHMVd+PVZsjnRd0vFqghmCYqoeWgZhsViUV2zwY=; b=QeZY32+FdM+WkyaFfndvwgC0XydWfNlc40/QEXYqKmU3JXjCQxSVUN0QpBqdujms K99aoKSLNHeOPsDk70fZgsxFzBc9pJV/SC9sBo06ytLrfR4cAzQczZbivXoFVy0V wIEVHpre2l1AXpAHFUt/YP/sY4nWsutXBShsetKnDhk=; X-AuditID: c1b4fb3a-5c9c29e00000672c-2d-5c7e6fd79d1b Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id D9.F8.26412.7DF6E7C5; Tue, 5 Mar 2019 13:47:19 +0100 (CET) Received: from ESESSMB504.ericsson.se (153.88.183.165) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Tue, 5 Mar 2019 13:47:19 +0100 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB504.ericsson.se (153.88.183.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Tue, 5 Mar 2019 13:47:18 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZCSIYHMVd+PVZsjnRd0vFqghmCYqoeWgZhsViUV2zwY=; b=WH6D5ovbmx23Cd5bpEr6O//FeneuueHGwgKpArlil44nTWRGEIIXVXcdEn8bVoA0oilkRdibEQN98H0RI/htnq93Y1VvjSMrPSQ9BhUsSBiBSGhEq7cqJbIY5EAMdHT0ofPEKEzWIOpVSgaedj8KdbKJhYg88xK3REKLR5G9cps= Received: from HE1PR0702MB3626.eurprd07.prod.outlook.com (52.133.6.24) by HE1PR0702MB3756.eurprd07.prod.outlook.com (52.133.7.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.15; Tue, 5 Mar 2019 12:47:18 +0000 Received: from HE1PR0702MB3626.eurprd07.prod.outlook.com ([fe80::b049:e8c6:251c:5ed7]) by HE1PR0702MB3626.eurprd07.prod.outlook.com ([fe80::b049:e8c6:251c:5ed7%4]) with mapi id 15.20.1686.016; Tue, 5 Mar 2019 12:47:18 +0000 From: Nitin Katiyar To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH 2/2] Do not send or receive LACP PDUs when carrier state of slave is down Thread-Index: AQHU01GRKKh0m1r+xkeVSWOy3EeT9w== Date: Tue, 5 Mar 2019 12:47:18 +0000 Message-ID: <1551818911-10884-2-git-send-email-nitin.katiyar@ericsson.com> References: <1551818911-10884-1-git-send-email-nitin.katiyar@ericsson.com> In-Reply-To: <1551818911-10884-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: BMXPR01CA0006.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::16) To HE1PR0702MB3626.eurprd07.prod.outlook.com (2603:10a6:7:8c::24) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f377fb72-94bc-461e-79fe-08d6a168b368 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:HE1PR0702MB3756; x-ms-traffictypediagnostic: HE1PR0702MB3756: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; HE1PR0702MB3756; 23:mI3D/QB6TysvBIpGBUwtBw3l+wF8gCQT5DuiZ?= =?iso-8859-1?q?nY4Rtiwu242buz04hbdCy6+Qw?= =?iso-8859-1?q?q66Rtvf/S4cY8wV8V/frpKYRcI86UjFEnJXzbTMKidComM0qrl0?= =?iso-8859-1?q?lrlrbBmTqF+l52qtiIaVbz+ZAHch4KFxSPhvReeKSXtZ3D/qOWj?= =?iso-8859-1?q?JAgNCKaHQfCP959rn+AuQNKmkAO44B7oytUuUcFJhVnN7A/twdA?= =?iso-8859-1?q?pM8aVHRMrc5zwGlLX+tb5wGgIoWKdOPDBRF0d6MU3p8934882nd?= =?iso-8859-1?q?ejG1fMnTSDC+geO/c/CIBQ6j3z9q9c6tQHxcjfDB7PXRzTajgPg?= =?iso-8859-1?q?lXu5nNTRH8+UAfRwsv024t2FiiGlG4l5XOfEvtnPOOdw0eTNzvJ?= =?iso-8859-1?q?fnwxpNHLNWNpqcuwOINQcDE3rYID/rRSPWnaQTc46NThT5k+UVN?= =?iso-8859-1?q?m+RrGfhl/scnVAar4EfRMiG5y+tYaLN1NAheBtlMIyJ9awFMZs7?= =?iso-8859-1?q?tu7v2h6MhNIiP6R29aVOrmcQbY9JLnO5AGya5BM9hp3V/9JUNwH?= =?iso-8859-1?q?Ocissbg/Va6ssAvrMpmgT6/n/srWKwj3HlZaF3nq+UKwWOPSyTf?= =?iso-8859-1?q?uTMkGcOsCzyjGV/a2S9cdU6FUlDcjI9C+P1w0K35xQ10la5epRV?= =?iso-8859-1?q?LuQZPO2MRcNI7OJjE8rs6fw8XhmmFma14DHMe+AR8zKpsVXTVRN?= =?iso-8859-1?q?rHn9FuQ0Mout5OEGyXMInjEdYSdovgntdc1rbqHQXLUeXPYG8n2?= =?iso-8859-1?q?t0k+CXAGF387iRLjztPYxDW2cuZdX9rLAKHl7NbuFvHyJR/0JOt?= =?iso-8859-1?q?q2rr1UlSYHwESgo1lbSuwe6zgUmRPxorcKBnx7B3BWZLKtTRS0o?= =?iso-8859-1?q?WZ1RzJLKVYWq3sz462GsDYYmx+xkuWlxwDho2DwVg776YUW2GRk?= =?iso-8859-1?q?pnfKKHdd83c0e2Imo4S+ZzasRp+Piyw4LSMzbb7x21doJYlcOC0?= =?iso-8859-1?q?NVzF2/nPqCaK2x9syBGSnR9vaN4Vfb/2dG8b+36geFpJKwLQTRu?= =?iso-8859-1?q?JZicAJe0RTbw0fVpE8i9Lmkbhn7pf5j4IySva3kBnyFP548/fas?= =?iso-8859-1?q?+6dZja30u+V5yJVD/40pFszRZ97eXUPk008CmXgjnJ9qspDiU6t?= =?iso-8859-1?q?EX63hDC9c1oTZir7LtV/ouVWOB8Wjm+53GyX8+2f7ewivdXIboY?= =?iso-8859-1?q?vaMZniDRylU7e10MZwPbavbwiQsDC0xPQB3iQpNcX0hTjgrBabb?= =?iso-8859-1?q?YVYHdiRnx4H59n1dH2RQHtNRZvGUxgOYOpLp3E72dkVFxMLRzmD?= =?iso-8859-1?q?GAhE9+1k6YXWDi5ZbauKkNjXYH5sQIXxGgEtmMagOTDZcYa2N6T?= =?iso-8859-1?q?wW7ChykKNosb0jKeGMDnAsOd7sMoYZzEgfDpgIn9rg1sivBO1oO?= =?iso-8859-1?q?bpYZDuo?= x-microsoft-antispam-prvs: x-forefront-prvs: 0967749BC1 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(396003)(376002)(136003)(39860400002)(199004)(189003)(8936002)(86362001)(50226002)(186003)(25786009)(446003)(11346002)(2616005)(476003)(4326008)(7736002)(44832011)(6486002)(6436002)(6116002)(5640700003)(3846002)(53936002)(6512007)(71200400001)(71190400001)(14454004)(478600001)(486006)(305945005)(14444005)(55236004)(99286004)(54906003)(316002)(102836004)(6346003)(6506007)(386003)(26005)(52116002)(105586002)(66066001)(76176011)(68736007)(2351001)(106356001)(36756003)(8676002)(2906002)(6916009)(81156014)(81166006)(2501003)(97736004)(256004)(5660300002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0702MB3756; 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) authentication-results: spf=none (sender IP is ) smtp.mailfrom=nitin.katiyar@ericsson.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: h8WCcWUEzDZYpjlt0fEPRGtwmRs2BiYZNK7ajqrXpK+KM11vGJG5r26Ol+jgtv1YDSj8/ePoxTqd5b4dW/m06Gk4T8LuZgKEPRglAtmqK2KJXeVuHdhutjrOD5d4cyb8/qwc+9E6f6V41XiegbFrFvbuPMxLkOVtAg/NdH5EqVtosED4mXgXL3gU5BW8jEOnAxw5Iz0VzdH1sBPNb/uoldpVcPq5m9v1r2BgytyWNF1HH5AnnQSyOprTnHDf1gI5uswJ39wWtfdVdBcb/vhKEriuzHC0UdYDrVSpQ/4M0CEg9/TPFM1hZr5TeGH/hGechxJY89JLM4Rv7g04CgYCYSlX3jA7ePfh0/vA+3Toja1I68d+fJEIZMmIjH1qYotwxMdYCdnGSlcEQT5N2rDPs/JMKeUut43mToDttZ//rvY= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f377fb72-94bc-461e-79fe-08d6a168b368 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2019 12:47:18.0855 (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-Transport-CrossTenantHeadersStamped: HE1PR0702MB3756 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjleLIzCtJLcpLzFFi42KZGbG9XPd6fl2MQWO3usXTt48ZLeZ+es7o wOSxc9Zddo9nN/8zBjBFcdmkpOZklqUW6dslcGV0LPEo6I2s+PtoPVMD4ySXLkZODgkBE4n3 f1cwdzFycQgJHGGUOHzwDCuE85VRYteMdVCZxUwSbzf0MYI4LAITmCVWHbzEBpGZxCRxaclp dgjnKaNE16wl7CCT2QQMJLZfnARmiwiYS5z4cA7MZhbIlPh3ag0jiC0sEC2x89EBNoiaBImu GQ1Qtp7ExzOrmUBsFgEViR8/W1hBbF4BL4mjF4+xgNhCQPa3c4/A4pwC3hILpjUxg9iMAmIS 30+tYYLYJS5x68l8JohPBSSW7DnPDGGLSrx8/I8VwlaSuLhmMTuELSexePVlsM8kBKYxStye dYYRIqEjcfb6EyhbVuLS/G4o2xcYfJsYIRqeMErsnnKDGaZh5eHDTBCJK3wSKydfgFqXL9F/ 6CJQggPIlpF4/4V9AqPBLCTHQth6EjemTmGDsLUlli18zTwLHACCEidnPmFZwMiyilG0OLW4 ODfdyEgvtSgzubg4P08vL7VkEyMwdRzc8ttqB+PB546HGAU4GJV4eC/k1MUIsSaWFVfmHmKU 4GBWEuH9Iw4U4k1JrKxKLcqPLyrNSS0+xCjNwaIkzvtHSDBGSCA9sSQ1OzW1ILUIJsvEwSnV wOj7KGrm+ldaa9Zl/XUKORT6okKdf+Fvc70dAfsyczTORie6zLrSe6qFteGtZZzzO6ksZoNH jK8ubN0pl6/+76ZF/K5vJ5Ov6c9dLKwxQ22r9/P+h2yNTZVSModLwlVuW824EV23bDOfN+Mb wTNVUg9ink1KMeyLKf8b9e7e6vkzrzFXPWSwZVdiKc5INNRiLipOBAC1XZL0GQMAAA== X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED 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 2/2] Do not 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. In port_run()/bundle_run(), cache the carrier status in "struct ofport_dpif"/"struct bond_slave". 2. When carrier state is DOWN, do not send any LACPDUs and drop any received LACPDUs. 3. When LACP state changes or LACPDU 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 | 40 +++++++++++++++++++++++++++++++--------- lib/lacp.h | 8 ++++---- ofproto/bond.c | 30 ++++++++++++++++++++++++++++++ ofproto/bond.h | 3 +++ ofproto/ofproto-dpif-xlate.c | 1 + ofproto/ofproto-dpif.c | 10 +++++++--- 6 files changed, 76 insertions(+), 16 deletions(-) diff --git a/lib/lacp.c b/lib/lacp.c index e768012..0259098 100644 --- a/lib/lacp.c +++ b/lib/lacp.c @@ -33,6 +33,7 @@ #include "unixctl.h" #include "openvswitch/vlog.h" #include "util.h" +#include "ofproto/bond.h" VLOG_DEFINE_THIS_MODULE(lacp); @@ -148,7 +149,7 @@ static void slave_get_actor(struct slave *, struct lacp_info *actor) OVS_REQUIRES(mutex); static void slave_get_priority(struct slave *, struct lacp_info *priority) OVS_REQUIRES(mutex); -static bool slave_may_tx(const struct slave *) +static bool slave_may_tx(const void *bond, const struct slave *) OVS_REQUIRES(mutex); static struct slave *slave_lookup(const struct lacp *, const void *slave) OVS_REQUIRES(mutex); @@ -326,14 +327,15 @@ lacp_is_active(const struct lacp *lacp) OVS_EXCLUDED(mutex) * called on all packets received on 'slave_' with Ethernet Type ETH_TYPE_LACP. */ bool -lacp_process_packet(struct lacp *lacp, const void *slave_, - const struct dp_packet *packet) +lacp_process_packet(struct lacp *lacp, const void *bond, + const void *slave_, const struct dp_packet *packet) OVS_EXCLUDED(mutex) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); const struct lacp_pdu *pdu; long long int tx_rate; struct slave *slave; + bool carrier_up = false; bool lacp_may_enable = false; lacp_lock(); @@ -350,6 +352,17 @@ 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. */ + carrier_up = bond_slave_get_carrier(bond, slave->aux); + if (!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); @@ -529,7 +542,8 @@ lacp_slave_is_current(const struct lacp *lacp, const void *slave_) /* This function should be called periodically to update 'lacp'. */ void -lacp_run(struct lacp *lacp, lacp_send_pdu *send_pdu) OVS_EXCLUDED(mutex) +lacp_run(struct lacp *lacp, const void *bond, + lacp_send_pdu *send_pdu) OVS_EXCLUDED(mutex) { struct slave *slave; @@ -559,7 +573,7 @@ lacp_run(struct lacp *lacp, lacp_send_pdu *send_pdu) OVS_EXCLUDED(mutex) HMAP_FOR_EACH (slave, node, &lacp->slaves) { struct lacp_info actor; - if (!slave_may_tx(slave)) { + if (!slave_may_tx(bond, slave)) { continue; } @@ -588,13 +602,13 @@ lacp_run(struct lacp *lacp, lacp_send_pdu *send_pdu) OVS_EXCLUDED(mutex) /* Causes poll_block() to wake up when lacp_run() needs to be called again. */ void -lacp_wait(struct lacp *lacp) OVS_EXCLUDED(mutex) +lacp_wait(struct lacp *lacp, const void *bond) OVS_EXCLUDED(mutex) { struct slave *slave; lacp_lock(); HMAP_FOR_EACH (slave, node, &lacp->slaves) { - if (slave_may_tx(slave)) { + if (slave_may_tx(bond, slave)) { timer_wait(&slave->tx); } @@ -818,9 +832,17 @@ slave_get_priority(struct slave *slave, struct lacp_info *priority) } static bool -slave_may_tx(const struct slave *slave) OVS_REQUIRES(mutex) +slave_may_tx(const void *bond, const struct slave *slave) + OVS_REQUIRES(mutex) { - return slave->lacp->active || slave->status != LACP_DEFAULTED; + bool carrier_up = true; + + if (bond) { + carrier_up = bond_slave_get_carrier(bond, slave->aux); + } + + return carrier_up && + (slave->lacp->active || slave->status != LACP_DEFAULTED); } static struct slave * diff --git a/lib/lacp.h b/lib/lacp.h index 0dfaef0..808d671 100644 --- a/lib/lacp.h +++ b/lib/lacp.h @@ -46,8 +46,8 @@ struct lacp *lacp_ref(const struct lacp *); void lacp_configure(struct lacp *, const struct lacp_settings *); bool lacp_is_active(const struct lacp *); -bool lacp_process_packet(struct lacp *, const void *slave, - const struct dp_packet *packet); +bool lacp_process_packet(struct lacp *, const void *bond, + const void *slave, const struct dp_packet *packet); enum lacp_status lacp_status(const struct lacp *); struct lacp_slave_settings { @@ -67,8 +67,8 @@ bool lacp_slave_is_current(const struct lacp *, const void *slave_); /* Callback function for lacp_run() for sending a LACP PDU. */ typedef void lacp_send_pdu(void *slave, const void *pdu, size_t pdu_size); -void lacp_run(struct lacp *, lacp_send_pdu *); -void lacp_wait(struct lacp *); +void lacp_run(struct lacp *, const void *, lacp_send_pdu *); +void lacp_wait(struct lacp *, const void *); struct lacp_slave_stats { /* id */ diff --git a/ofproto/bond.c b/ofproto/bond.c index c5d5f2c..3d12aa0 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -93,6 +93,7 @@ struct bond_slave { /* Link status. */ bool enabled; /* May be chosen for flows? */ bool may_enable; /* Client considers this slave bondable. */ + bool carrier_up; /* Carrier state from NIC port */ long long delay_expires; /* Time after which 'enabled' may change. */ /* Rebalancing info. Used only by bond_rebalance(). */ @@ -634,6 +635,35 @@ bond_slave_set_may_enable(struct bond *bond, void *slave_, bool may_enable) ovs_rwlock_unlock(&rwlock); } +void +bond_slave_set_carrier(struct bond *bond, void *slave_, bool carrier_up) +{ + struct bond_slave *slave = NULL; + + ovs_rwlock_wrlock(&rwlock); + slave = bond_slave_lookup(bond, slave_); + if (slave) { + slave->carrier_up = carrier_up; + } + ovs_rwlock_unlock(&rwlock); +} + +bool +bond_slave_get_carrier(const struct bond *bond, void *slave_) +{ + bool carrier_up = false; + struct bond_slave *slave; + + ovs_rwlock_rdlock(&rwlock); + slave = bond_slave_lookup(CONST_CAST(struct bond *, bond), slave_); + if (slave) { + carrier_up = slave->carrier_up; + } + ovs_rwlock_unlock(&rwlock); + + return carrier_up; +} + /* Performs periodic maintenance on 'bond'. * * Returns true if the caller should revalidate its flows. diff --git a/ofproto/bond.h b/ofproto/bond.h index e7c3d9b..743e2b2 100644 --- a/ofproto/bond.h +++ b/ofproto/bond.h @@ -79,6 +79,9 @@ void bond_wait(struct bond *); void bond_slave_set_may_enable(struct bond *, void *slave_, bool may_enable); +void bond_slave_set_carrier(struct bond *bond, void *slave_, bool carrier_up); +bool bond_slave_get_carrier(const struct bond *bond, void *slave_); + /* Special MAC learning support for SLB bonding. */ bool bond_should_send_learning_packets(struct bond *); struct dp_packet *bond_compose_learning_packet(struct bond *, diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 8f44566..18fdb82 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -3329,6 +3329,7 @@ process_special(struct xlate_ctx *ctx, const struct xport *xport) && flow->dl_type == htons(ETH_TYPE_LACP)) { if (packet) { lacp_may_enable = lacp_process_packet(xport->xbundle->lacp, + xport->xbundle->bond, xport->ofport, packet); /* Update LACP status in bond-slave to avoid packet-drops until * LACP state machine is run by the main thread. */ diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 21dd54b..f494a36 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -137,6 +137,7 @@ struct ofport_dpif { struct cfm *cfm; /* Connectivity Fault Management, if any. */ struct bfd *bfd; /* BFD, if any. */ struct lldp *lldp; /* lldp, if any. */ + bool carrier_up; /* Carrier state from NIC */ bool is_tunnel; /* This port is a tunnel. */ long long int carrier_seq; /* Carrier status changes. */ struct ofport_dpif *peer; /* Peer if patch port. */ @@ -3324,12 +3325,13 @@ static void bundle_run(struct ofbundle *bundle) { if (bundle->lacp) { - lacp_run(bundle->lacp, send_pdu_cb); + lacp_run(bundle->lacp, bundle->bond, send_pdu_cb); } if (bundle->bond) { struct ofport_dpif *port; LIST_FOR_EACH (port, bundle_node, &bundle->ports) { + bond_slave_set_carrier(bundle->bond, port, port->carrier_up); bond_slave_set_may_enable(bundle->bond, port, port->up.may_enable); } @@ -3347,7 +3349,7 @@ static void bundle_wait(struct ofbundle *bundle) { if (bundle->lacp) { - lacp_wait(bundle->lacp); + lacp_wait(bundle->lacp, bundle->bond); } if (bundle->bond) { bond_wait(bundle->bond); @@ -3563,8 +3565,10 @@ ofport_update_peer(struct ofport_dpif *ofport) static bool may_enable_port(struct ofport_dpif *ofport) { + ofport->carrier_up = netdev_get_carrier(ofport->up.netdev); + /* Carrier must be up. */ - if (!netdev_get_carrier(ofport->up.netdev)) { + if (!ofport->carrier_up) { return false; }