From patchwork Wed Feb 27 08:37:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitin Katiyar X-Patchwork-Id: 1048754 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="doTetsNP"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="A/sPpck4"; 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 448TrV64bcz9s1b for ; Wed, 27 Feb 2019 19:49:30 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3892785F3; Wed, 27 Feb 2019 08:49:00 +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 E79F484C9 for ; Wed, 27 Feb 2019 08:37:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sesbmg22.ericsson.net (sesbmg22.ericsson.net [193.180.251.48]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B6A318A for ; Wed, 27 Feb 2019 08:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1551256670; x=1553848670; 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=tQ8qjyAG9pT345xz6MKRgfa0Al0I6dEzCLWGDmqNI1k=; b=doTetsNPMpS1GWQvXxO9rl2newJFqpW1vi7Yai9ji6ImGD0GIK0guGAaDKGU0bbp f55AGl3f8+AgGl1tZRV6JPdif3HlBP90sEcPpoGOKxJdMsUyFPh8SK0dJXcbr2CV DLTsmHseYelmquu5LCEnUybXqfHInZgvmecj7KilSCo=; X-AuditID: c1b4fb30-41b3a9e00000355c-c0-5c764c5e1ada Received: from ESESBMB505.ericsson.se (Unknown_Domain [153.88.183.118]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id 6E.5B.13660.E5C467C5; Wed, 27 Feb 2019 09:37:50 +0100 (CET) Received: from ESESSMR501.ericsson.se (153.88.183.108) by ESESBMB505.ericsson.se (153.88.183.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 27 Feb 2019 09:37:39 +0100 Received: from ESESBMB501.ericsson.se (153.88.183.168) by ESESSMR501.ericsson.se (153.88.183.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 27 Feb 2019 09:37:39 +0100 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB501.ericsson.se (153.88.183.168) 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; Wed, 27 Feb 2019 09:37:39 +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=tQ8qjyAG9pT345xz6MKRgfa0Al0I6dEzCLWGDmqNI1k=; b=A/sPpck4UiofufFPBurlg/4uqzuX+gu/XUctqkj4xWGvS+v0yQNodV5v89KlEUKz7iZXkKa1xJyGGRrvASUIkn0HH4LQciU572S3IQwZ6VPmwU60c8KsO9pEKIW2kGUdCL3zxBQfvFesALsQob7gvfth/NMxkwR7A9n/maZfC60= Received: from HE1PR0702MB3626.eurprd07.prod.outlook.com (52.133.6.24) by HE1PR0702MB3706.eurprd07.prod.outlook.com (52.133.6.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.12; Wed, 27 Feb 2019 08:37:37 +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.1665.012; Wed, 27 Feb 2019 08:37:36 +0000 From: Nitin Katiyar To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH 1/2] Avoid packet drop on LACP bond after link up Thread-Index: AQHUznex34ZjdngCaUWTL/DkKKrM7w== Date: Wed, 27 Feb 2019 08:37:36 +0000 Message-ID: <1551285539-31225-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: PN1PR0101CA0026.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::12) 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: 69943bb5-0b4b-4ab2-5aa0-08d69c8ed33f 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:HE1PR0702MB3706; x-ms-traffictypediagnostic: HE1PR0702MB3706: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; HE1PR0702MB3706; 23:aOOWvJyh5yPfWUR7opvZfnh2IkdjXHOygzizs?= =?iso-8859-1?q?wR9Q8f8IRPvD+i1LGloHhMm6y?= =?iso-8859-1?q?K0lY3MMXMBcm8O6tabEmHYTUAD0Htu0bbPSpESamTdw0axNEgfk?= =?iso-8859-1?q?tQVGgMcQHR9682KFW3gBT3OmpyvWYj8XAvNsNNWuPrdiPEbcEuK?= =?iso-8859-1?q?rjtFwoBwLEZIu7oPFIow2bDqvr8IHoPhDV/by78O+YfaD26QYbl?= =?iso-8859-1?q?hwZoQuZysTa6/iNhgAeN3eCDb37CV6wvZeB/6FwOf7vAsRntIlv?= =?iso-8859-1?q?GN4g7CycmVHJ/UQ5LblhlQVj8NVup8ylkpEHZR3sNSKpdMNpnuz?= =?iso-8859-1?q?hTINTgRxBp4guXM779ViQ45HCzPgOtS9ZKRxiXk0f78AFoNve65?= =?iso-8859-1?q?/yghijTd6eWFGgCnCELRFf62abFG0ezOh84e6jq/PohhLw7+Ytr?= =?iso-8859-1?q?JK3L1Wqw6Sy9z6XAXr6JfYd4pw0mNe3NonATdKZspxEIqPpEVBi?= =?iso-8859-1?q?dMQlaGH5gA+Uju3HZAbQANVr3ZI+16g/MYid+Ee8X0mw8+efFZF?= =?iso-8859-1?q?kb2imYCCPRhH3b/fFF66yNnY5C/rDTT1LDH5DfIKtWlbIP4VzIB?= =?iso-8859-1?q?dHlN9KTF6Btfou+80jwCXCEcRcEGvN2KPP6m2k0Qi4MllDh5XU8?= =?iso-8859-1?q?IoU0b8wKuI85DvfQmKTbYGfI1VKD1aOyY4Iiq7aA6AVe18mPEdC?= =?iso-8859-1?q?FBkQH8tU7PXvangzROg52khLvocSKt3nua0C5f7T0HY5Og5h8B9?= =?iso-8859-1?q?D/u/mCdazPdodYj3EwryRKJ1/Dvv0Uz4+4o966dvYOd24C6gVr2?= =?iso-8859-1?q?cGZneWehqVPOGoN02dXteKJxxVLc1GiXdei0dADUvXvVnBQ4x8I?= =?iso-8859-1?q?ajPi4fJOT4sC02VKTL6EJlPTLC3VaRG9wOfOrvEu46zK3666Ao8?= =?iso-8859-1?q?zkAPeOUMIn/xIcjRgBL53ydLkDxoQwD1p4psYZERPmQvDWloqAO?= =?iso-8859-1?q?87WoiBC0X8JGX23jY/5xVNTqONm7UP2x7Eg/1EDVK9dFrXT3Uvo?= =?iso-8859-1?q?3pKIJsNIM1pxmgo74lb5MDRNYWKa0wMxSZyWrNQLZb/OkdCsHbP?= =?iso-8859-1?q?Sslx+NX+/belqCWToG7BVh35tAuwDTFNIIKNXWMBXG5+nBt0Ju1?= =?iso-8859-1?q?HhSQlDm1YADxC61s3X4Fey935Tb4IrIAXE09WLPpGhZ1Cb/kz7/?= =?iso-8859-1?q?rALgxdG90ChMVTWjFhkk4A0lsWCQsCnBLzPqathE4NTcadmClQp?= =?iso-8859-1?q?eUTNpf1Bw7j/7mzkrA9x2HVhRCtkKWGGw+XqcPjBlvLZ+JYtfc7?= =?iso-8859-1?q?QDhVVWqgs8Q2SDVAcAp9IMfM=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0961DF5286 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(346002)(136003)(39860400002)(376002)(199004)(189003)(8676002)(2351001)(81166006)(6486002)(81156014)(6116002)(3846002)(2616005)(186003)(44832011)(36756003)(486006)(305945005)(7736002)(476003)(105586002)(106356001)(26005)(14454004)(5640700003)(4326008)(6916009)(25786009)(256004)(14444005)(6512007)(50226002)(478600001)(8936002)(97736004)(386003)(102836004)(66066001)(71190400001)(71200400001)(6436002)(316002)(86362001)(68736007)(5660300002)(99286004)(6506007)(55236004)(52116002)(2906002)(54906003)(53936002)(2501003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0702MB3706; 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: /J/zorUeu2AlK7QDXHtqs6Zgi//hyxC7yUDWkILAZ+s5vKUaJBe8Ycj6rQ3uVeBVk6re+BW45qdfvbsK0QNOngN5KMyKPQOoLmTsDdrDs9vNgUdgUOa1XMZAYnZ8hYcBGEaCN7giKUEwtX/BSUQInHpjI6NKBdknsUnVyCxkm8t9JNx/3kenD1ziCrSXAlzU0b7HmpS7TzrESPQ37PuY88wp4QhQJel2KkF94ocOjxGtjb2UYO10iS7blomG1kPM3vyVrx4nYEblvz41LJKTuz9LNdPseqtEtBsOUBfpKTK5GQKYz+/JCsOUv9Oj69QWWmHlIry3kJROKcdcCA+maiACS2neQCd5GaQANRZGqB2j41g95WE1jX84q6Gf9QRsQ2IDnjclQgmlccuTYhq1vZoi96LJNDBwH1npK4bxOxU= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 69943bb5-0b4b-4ab2-5aa0-08d69c8ed33f X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2019 08:37:36.7661 (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: HE1PR0702MB3706 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplleLIzCtJLcpLzFFi42KZGbG9TDfOpyzGoHsyi8XTt48ZLeZ+es7o wOSxc9Zddo9nN/8zBjBFcdmkpOZklqUW6dslcGXc2DiTqeCwdcW9I/9ZGhjv6nQxcnJICJhI NK+8w9zFyMUhJHCEUeLQ9ImsIAkhgW+MEguXVEIkgOxLzxpYIJwlTBJfHj8Aa2ERmMAsMff9 R0aIlilMEr2v3SCqnjFKrJ51ng0kwSZgILH94iR2EFtEwFzixIdzYDazQKbEv1NrwJqFBRwl Lh5rgKpxk9jX/IQRwtaTmHZqK9hNLAKqEvvO7WcCsXkFvCReX5rNDGIzCohJfD+1hgliprjE rSfzmSCeE5BYsuc8M4QtKvHy8T9WCFtJ4uKaxewQtpzE4tWX2SDsGYwSf4+LQcyMlXj3+ClU vY7E2esQ90gIyEpcmt8NZftKLD0KCTwJgSeMEg131jHBNHTOXc8KkXjHK/Hl+h6obfkS6yc3 AW3jALJlJD70q05g1J+F5G4IW0/ixtQpbBC2tsSyha+ZZ4H9LChxcuYTlgWMLKsYRYtTi5Ny 042M9FKLMpOLi/Pz9PJSSzYxAhPHwS2/DXYwvnzueIhRgINRiYd3vWVZjBBrYllxZe4hRgkO ZiURXjkPoBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHeP0KCMUIC6YklqdmpqQWpRTBZJg5OqQZG nbN3//cHLzRauLf8xhafc9EtpxmVNtgLzl11WmWZ0cm10sc+ziuXEDcTOrpsdmRYpZyVVJ+B e96eyHkFFzY9V57MZZUWdvF8fqsJ/8YbwTuX+dw8JBJ15FXrszXiksuerr3MJtHSHa7PY8We +MyJp+bf8qKq633REswutof4Hq18z/E48uAPJZbijERDLeai4kQAW6P4XxgDAAA= 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 1/2] Avoid packet drop on LACP bond after link up 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: ======== During port DOWN->UP of link (slave) in a LACP bond, after receiving the LACPDU with SYNC set for both actor and partner, the bond-slave remains "disabled" until OVS main thread runs LACP state machine and eventually "enables" the bond-slave. With this, we have observed delays in the order of 350ms and packets are dropped in OVS due to bond-admissibility check (packets received on slave in "disabled" state are dropped). Fix: ==== When a LACPDU is received, evaluate whether LACP slave can be enabled (slave_may_enable()) and set LACP slave's may_enable from the datapath thread itself. When may_enable = TRUE, it means L1 state is UP and LACP-SYNC is done and it is waiting for the main thread to enable the slave. Relax the check in bond_check_admissibility() to check for both "enable" and "may_enable" of the LACP slave. This would avoid dropping of packets until the main thread enables the slave from bundle_run(). Signed-off-by: Nitin Katiyar Signed-off-by: Manohar Krishnappa Chidambaraswamy Co-authored-by: Manohar Krishnappa Chidambaraswamy --- lib/lacp.c | 12 ++++++++++-- lib/lacp.h | 3 ++- ofproto/bond.c | 16 +++++++++++++--- ofproto/ofproto-dpif-xlate.c | 11 ++++++++++- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/lacp.c b/lib/lacp.c index d6b36aa..7ac85f9 100644 --- a/lib/lacp.c +++ b/lib/lacp.c @@ -154,6 +154,7 @@ static struct slave *slave_lookup(const struct lacp *, const void *slave) OVS_REQUIRES(mutex); static bool info_tx_equal(struct lacp_info *, struct lacp_info *) OVS_REQUIRES(mutex); +static bool slave_may_enable__(struct slave *slave) OVS_REQUIRES(mutex); static unixctl_cb_func lacp_unixctl_show; static unixctl_cb_func lacp_unixctl_show_stats; @@ -324,8 +325,8 @@ lacp_is_active(const struct lacp *lacp) OVS_EXCLUDED(mutex) /* Processes 'packet' which was received on 'slave_'. This function should be * called on all packets received on 'slave_' with Ethernet Type ETH_TYPE_LACP. */ -void -lacp_process_packet(struct lacp *lacp, const void *slave_, +bool +lacp_process_packet(struct lacp *lacp, const void *bond, const void *slave_, const struct dp_packet *packet) OVS_EXCLUDED(mutex) { @@ -333,6 +334,7 @@ lacp_process_packet(struct lacp *lacp, const void *slave_, const struct lacp_pdu *pdu; long long int tx_rate; struct slave *slave; + bool lacp_may_enable = false; lacp_lock(); slave = slave_lookup(lacp, slave_); @@ -362,8 +364,14 @@ lacp_process_packet(struct lacp *lacp, const void *slave_, slave->partner = pdu->actor; } + /* Evaluate may_enable here to avoid dropping of packets till main thread + * sets may_enable to true. */ + lacp_may_enable = slave_may_enable__(slave); + out: lacp_unlock(); + + return lacp_may_enable; } /* Returns the lacp_status of the given 'lacp' object (which may be NULL). */ diff --git a/lib/lacp.h b/lib/lacp.h index f35cff5..1505c2c 100644 --- a/lib/lacp.h +++ b/lib/lacp.h @@ -46,7 +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 *); -void lacp_process_packet(struct lacp *, const void *slave, +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 *); diff --git a/ofproto/bond.c b/ofproto/bond.c index d2a8b1f..cd6fd33 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -794,6 +794,7 @@ bond_check_admissibility(struct bond *bond, const void *slave_, { enum bond_verdict verdict = BV_DROP; struct bond_slave *slave; + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); ovs_rwlock_rdlock(&rwlock); slave = bond_slave_lookup(bond, slave_); @@ -811,7 +812,11 @@ bond_check_admissibility(struct bond *bond, const void *slave_, * drop all incoming traffic except if lacp_fallback_ab is enabled. */ switch (bond->lacp_status) { case LACP_NEGOTIATED: - verdict = slave->enabled ? BV_ACCEPT : BV_DROP; + /* To reduce packet-drops due to delay in enabling of slave (post + * LACP-SYNC), from main thread, check for may_enable as well. + * When may_enable is TRUE, it means LACP is UP and waiting for the + * main thread to run LACP state machine and enable the slave. */ + verdict = (slave->enabled || slave->may_enable) ? BV_ACCEPT : BV_DROP; goto out; case LACP_CONFIGURED: if (!bond->lacp_fallback_ab) { @@ -847,8 +852,6 @@ bond_check_admissibility(struct bond *bond, const void *slave_, /* Drop all packets which arrive on backup slaves. This is similar to * how Linux bonding handles active-backup bonds. */ if (bond->active_slave != slave) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_DBG_RL(&rl, "active-backup bond received packet on backup" " slave (%s) destined for " ETH_ADDR_FMT, slave->name, ETH_ADDR_ARGS(eth_dst)); @@ -870,6 +873,13 @@ bond_check_admissibility(struct bond *bond, const void *slave_, OVS_NOT_REACHED(); out: + if (slave && (verdict != BV_ACCEPT)) { + VLOG_DBG_RL(&rl, "slave= %s actv-slave= %d may_enable %d enable %d " + "LACP %d verdict(A/D/M=0/1/2) %d\n", slave->name, + (bond->active_slave == slave), slave->may_enable, + slave->enabled, bond->lacp_status, verdict); + } + ovs_rwlock_unlock(&rwlock); return verdict; diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index acd4817..a4a3a2b 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -3288,6 +3288,7 @@ process_special(struct xlate_ctx *ctx, const struct xport *xport) const struct xbridge *xbridge = ctx->xbridge; const struct dp_packet *packet = ctx->xin->packet; enum slow_path_reason slow; + bool lacp_may_enable; if (!xport) { slow = 0; @@ -3308,7 +3309,15 @@ process_special(struct xlate_ctx *ctx, const struct xport *xport) } else if (xport->xbundle && xport->xbundle->lacp && flow->dl_type == htons(ETH_TYPE_LACP)) { if (packet) { - lacp_process_packet(xport->xbundle->lacp, xport->ofport, 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. */ + if (xport->xbundle->bond && lacp_may_enable) { + bond_slave_set_may_enable(xport->xbundle->bond, xport->ofport, + lacp_may_enable); + } } slow = SLOW_LACP; } else if ((xbridge->stp || xbridge->rstp) && From patchwork Wed Feb 27 08:37:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitin Katiyar X-Patchwork-Id: 1048753 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="MfN5O8r2"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="eQUyCTu8"; 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 448Tr12Mxpz9s1b for ; Wed, 27 Feb 2019 19:49:04 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 63466855B; Wed, 27 Feb 2019 08:48:59 +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 BB6A284C9 for ; Wed, 27 Feb 2019 08:37:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sessmg23.ericsson.net (sessmg23.ericsson.net [193.180.251.45]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5062A2D4 for ; Wed, 27 Feb 2019 08:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1551256666; x=1553848666; 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=yfk6zCksb0swlkc7iJMY4oG1gGbyWUhdBED4v/w0kXw=; b=MfN5O8r2CM8ebWJGT6Zzxg9UzRDbaxkBme3C1KjJ1oBMZmGhtBzV8AegjTk2kHO6 /MmM23yvqiyJHmY3eWEIov11hOhmQauTCY3uw2eiRZWpfSVDkEmSgHPGWRg4dgHF aIEG5Pgqwn3tSVu6ymeUhhH1U9/sswdWYoiLBdd8rLw=; X-AuditID: c1b4fb2d-2198b9e00000062f-c6-5c764c5ac03c Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id 01.79.01583.A5C467C5; Wed, 27 Feb 2019 09:37:46 +0100 (CET) Received: from ESESBMB503.ericsson.se (153.88.183.170) 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; Wed, 27 Feb 2019 09:37:45 +0100 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB503.ericsson.se (153.88.183.170) 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; Wed, 27 Feb 2019 09:37:44 +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=yfk6zCksb0swlkc7iJMY4oG1gGbyWUhdBED4v/w0kXw=; b=eQUyCTu8l6IT/GkZlODbeDyUSwuf4D2dkV5MW9RGePcLm4c8tb7LBvXNnRrXLc9EQ7BFYsTm8JJi/Y94BxY5dy2XYxw3tIjuwi4IFY/iF++PeRsm94dQAyvnN2b8MIUgntd6XWoBiIV2jb5NMc9anIZwnwA+EAH/dOH3UTLg9ls= Received: from HE1PR0702MB3626.eurprd07.prod.outlook.com (52.133.6.24) by HE1PR0702MB3706.eurprd07.prod.outlook.com (52.133.6.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.12; Wed, 27 Feb 2019 08:37:43 +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.1665.012; Wed, 27 Feb 2019 08:37:43 +0000 From: Nitin Katiyar To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH 2/2] Avoid packet drop on LACP bond after link up Thread-Index: AQHUzne1GLsvA6dlLk274+6kMS/f+w== Date: Wed, 27 Feb 2019 08:37:43 +0000 Message-ID: <1551285539-31225-2-git-send-email-nitin.katiyar@ericsson.com> References: <1551285539-31225-1-git-send-email-nitin.katiyar@ericsson.com> In-Reply-To: <1551285539-31225-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: PN1PR0101CA0026.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::12) 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: 86467a33-4144-4df8-699f-08d69c8ed73c 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:HE1PR0702MB3706; x-ms-traffictypediagnostic: HE1PR0702MB3706: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; HE1PR0702MB3706; 23:wpJNwy5Rc2R7JNEWilKZqSe5Kf0Ev5m/2719z?= =?iso-8859-1?q?9bLjQQD6Q8Ybekd3vvYjAcLvU?= =?iso-8859-1?q?YXGfuRI82QwvLTvcsSouCBrGOWikC9a+U4Pz48VCgig/l8Xo2Sf?= =?iso-8859-1?q?fTnh5f/xmMSrG2+8rIPPn4UFBTe3sQZLaacdEhqr8yq2qrWsOdp?= =?iso-8859-1?q?ZSNs4NQ9sIjRUfvmPH9JKaFtf0QqKvWdn9l9LqCLKCHGunHlkua?= =?iso-8859-1?q?XVOkOmw5Bo4ynunPYrOLBdSPHgfghChUmqPS/BPm0e6QmP3gJxS?= =?iso-8859-1?q?X/iuvxvXEMsg97kUmdoYIXpclRxna+KvL8CDPwlePE8wFbkE8Ua?= =?iso-8859-1?q?4QbBAQPUKcwBPalC0lmKvbDfmtrJvAjx3BZJREte2vlJhI+5rUu?= =?iso-8859-1?q?n0vhyHkBaFsInkKI2DBi3fbHLd02xz1Iw+3zGLM05dFQqVdIiE/?= =?iso-8859-1?q?cCgTPJtJzxwXzRl1eT7o8vYAUUb6luQy//cje6q/eZs0PHFAlGe?= =?iso-8859-1?q?fC4fFFuTTfO/XaW10GHbTCcCJ+bCH1A8ix70phxd5VMiLIbySot?= =?iso-8859-1?q?6NhDcG89fQ4uv9of+LLMqUIgoMosZIg+j/2DCk8U4OLMuPhF/99?= =?iso-8859-1?q?b/uDaN1zT1zks1VsU0KlXGUUo/W6GnjmPh5Rjy+TQ3oqyw9Hbnq?= =?iso-8859-1?q?gdpYHiHTwXGnWJGb2+sk4Gd3xWCHj/UL77vKcyUBO05G0IMPQ4g?= =?iso-8859-1?q?dw+zGsbKKY+czDAoGgiue2bxGJ1TrXK7LOah0kpsbQJyVEupUCO?= =?iso-8859-1?q?+Yjp/J0GAFv4MCoGJW5etF+MOWLCW8AfVgsI0sv9GDH8HGwyRb/?= =?iso-8859-1?q?yVY3R9J574PCJ93tVSX+phAIe6bXQeP0CVw2+oQIsvVrZ9y2Kjx?= =?iso-8859-1?q?w496ljge67jQoiGCYrCfKKPS8Sh8d/By/7rXFWEtyBhLAVcDwKK?= =?iso-8859-1?q?+7ULvaC7Sp2+MQ+OQ2bE5H7zqwPUcvgmcs0qvGmzEXkpWHk/hXC?= =?iso-8859-1?q?mExUEp8PU3BtF/GnSZpnpl6NsS+bgp66BNmO4YOUUHZYvKd3NEJ?= =?iso-8859-1?q?IEkvNXeBBzUb3OxvN8fmsGnpzWMmLFpsU2UAwKRfhNPm6S59eHF?= =?iso-8859-1?q?nPfNGMIuoE/DvGaZJjnWmi3jCrY80JBQ2uXsC7E9yOosU3cjUxv?= =?iso-8859-1?q?XRpojmjV9bKX7v0DRdVn7J1bU9+5oRDZVOGyFWLaRXGyn4nf6v6?= =?iso-8859-1?q?YgFSalHorI++hodrURztwQXvmPefffJFNDqcLMgH01jyFqqcl8P?= =?iso-8859-1?q?mhLkKfW0/vui8IXofaGe2hOCXm0j6d/g5BCkJEZhjqG22RqjpHa?= =?iso-8859-1?q?YKqLL3j+hDNIwhZVxsFHaB45We+SOM7ybbXUHjFhqye2nwVD7ET?= =?iso-8859-1?q?eoRUL/W1y1dCyC7iMSDkLpdRM8Z/ug+Lwxy/s=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0961DF5286 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(346002)(136003)(39860400002)(376002)(199004)(189003)(8676002)(2351001)(81166006)(6486002)(446003)(81156014)(6116002)(3846002)(2616005)(186003)(44832011)(36756003)(486006)(305945005)(7736002)(476003)(11346002)(105586002)(106356001)(26005)(14454004)(5640700003)(4326008)(6916009)(25786009)(256004)(14444005)(6512007)(50226002)(478600001)(8936002)(97736004)(386003)(102836004)(66066001)(71190400001)(71200400001)(6436002)(316002)(86362001)(68736007)(5660300002)(76176011)(99286004)(6506007)(55236004)(52116002)(2906002)(54906003)(53936002)(2501003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0702MB3706; 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: hyb2dFkEIY8wBk3G0yZciaIsQEg28dDDB8v+PoODs8N1IflRgjkkzXX5txTKbpbltlpuToNA61NBkHWQDnlQW2H5zGU5M+TozpYaiMFQf/fu4t2D6f2eeqnkJ1R6nymfO942VLdN801LuNwnl2IXE/dTGmhB++Ip5Ux7EcQpwc9KK+MnJQ9yNeeUH+Tf+fGVVP3HpYBA8GnET8/TUZtBwJE8s2/A5XZk4uDlTYIow52eGiTfuX8rsWgGY+8CvOkbkbPoS4GR8IjjbTp+efcZP4R5BGMS+vaIF74WZL2gnWmFkRvRFcy4EntYYPJaq/xPq4LDk01xhb/mrK0oTx8aIGmSMiSta0SxtyhFCcAuddvSFnN4Fp+WgBzWfdVWRbmAGXFxc6fDbgsHLqpkNBKIgp+asE3OfEd4RFSPMkj5tL0= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 86467a33-4144-4df8-699f-08d69c8ed73c X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2019 08:37:43.4687 (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: HE1PR0702MB3706 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA03SbUhTURgH8M69e7kuJ9f59qAoNIxScy0XpBKSEmYvhl+EkIUNvepSp91r KytwIAiakIqaLmSWppErQxwW+sVppSuXb2RJEuqciZqWObVM03sn9O13zvN/nnM4HAKXFPF9 CbUmj6I1qiypQMSrvdRxIzTpglYp1w0eCp9ZnEbhdT9n0Sks7pV+Qhhn/7yNErAk0clUKkut peijUVdEGT1jH/m5kwk3K4ocmA5Zo0oQQQB5HMZrCkqQiJCQvQie1c7yuYUDwf2mZSG3aMRg ztLMVnhkGQ6/iyZwrlKJQWm9wRmzI7BZx3glyIUQkHLoGKoQ7tqTPAF9y1bWOKmGLYsR7dqD jIb291OIy8SCte8Fn7MMekeb2Tk88iCsPJ5kM2LyHCxUF7IZyY6ffNMLdu1CnofO7lI2j0hv WLMYMe4sHxi3GVgDSUJj1wecsxfMTW/xOUthyNgg5BwADS0jAs41CP6+9eZmXobv0zPO/BEY GLMhzv4wbLjrdDwMjprYJwLShkD35Tm211Bc1+osmN2g0/Ta2ZEDxasmVIbk+v8uy1kGn6oq BZxDoOnhPK5nH8Ad+mttvHrEe4q8GIphstPDFDKKVqcwTI5GpqHy2tDO7+hu/xP6ErXMR5sR SSCpq9gYoVVK+Cotk59tRkDgUk9xQNzOljhVlX+LonOS6etZFGNGfgRP6iPelLgrJWS6Ko/K pKhcit6rYoSLrw4Vtx0WDDdlbpyl/eTBhT0xmu3kq1/fbSksaWX2CK+W9ZUzeuG+jIHqWFhd oJeUgb73uoYDve88WiuPT1k64PB3q0+R7A+quabI/hVpSNycjHlgSZPGLnpsMuaO8sSqiwr7 VGt/RViQsJBax2//iHzj6Op2NbWNJIcEFWycxjqlPCZDdSwYpxnVP8XzWhgZAwAA 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] Avoid packet drop on LACP bond after link up 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: Nitin Katiyar Signed-off-by: Manohar Krishnappa Chidambaraswamy Co-authored-by: Manohar Krishnappa Chidambaraswamy --- lib/lacp.c | 40 +++++++++++++++++++++++++++++++++------- lib/lacp.h | 4 ++-- ofproto/bond.c | 30 ++++++++++++++++++++++++++++++ ofproto/bond.h | 3 +++ ofproto/ofproto-dpif.c | 10 +++++++--- tests/ofproto-dpif.at | 3 +++ 6 files changed, 78 insertions(+), 12 deletions(-) diff --git a/lib/lacp.c b/lib/lacp.c index 7ac85f9..359b6ce 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); @@ -334,6 +335,7 @@ lacp_process_packet(struct lacp *lacp, const void *bond, const void *slave_, 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,21 @@ lacp_process_packet(struct lacp *lacp, const void *bond, 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 LACPDU and + * trigger re-checking of L1 state. + */ + carrier_up = bond_slave_get_carrier(bond, slave_); + if (!carrier_up) { + seq_change(connectivity_seq_get()); + + VLOG_INFO_RL(&rl, "carrier still DOWN - conn seq changed for %s, " + "dropping packet\n", slave->name); + + 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 +546,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 +577,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 +606,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 +836,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 1505c2c..9a302c9 100644 --- a/lib/lacp.h +++ b/lib/lacp.h @@ -68,8 +68,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 cd6fd33..68c3acb 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((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.c b/ofproto/ofproto-dpif.c index 50c959b..a589392 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; } diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index ded2ef0..12d0349 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -6581,6 +6581,9 @@ OVS_VSWITCHD_START([dnl other_config:lacp-port-priority=222 \ other_config:lacp-aggregation-key=3333 ]) +ovs-appctl netdev-dummy/set-admin-state p1 up +ovs-appctl netdev-dummy/set-admin-state p2 up + on_exit 'kill `cat test-sflow.pid`' AT_CHECK([ovstest test-sflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > sflow.log], [0], [], [ignore]) AT_CAPTURE_FILE([sflow.log])