From patchwork Thu Feb 28 13:56:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitin Katiyar X-Patchwork-Id: 1049516 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="ReEHGt28"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="Q63fZlpT"; 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 449Dmh0Nttz9s1b for ; Fri, 1 Mar 2019 01:03:47 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4E829A2CC; Thu, 28 Feb 2019 14:03:44 +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 35938A2BE for ; Thu, 28 Feb 2019 13:56:08 +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 DDB7D76D for ; Thu, 28 Feb 2019 13:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1551362165; x=1553954165; 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=nb/MsMGKDC4pcMAgEMmszcSJecm07y5JnpsTsAp2UqI=; b=ReEHGt28/voC0RMae8UplcDrwWDBhvn9tDjFeQfanebkibm7SgK1A309ST/btsqn PG6Nh4WsJo9vgVTUqTDgPjOPYP9mB/KcRKTf7IQKCXiUUwzrqISxwJHWilBjdu2P LB9ZeA92RVhUUSkTw0V6XBzx0pklQYLccfBuCXJc7UI=; X-AuditID: c1b4fb30-41b3a9e00000355c-42-5c77e8751bdc Received: from ESESBMB502.ericsson.se (Unknown_Domain [153.88.183.115]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id 23.C9.13660.578E77C5; Thu, 28 Feb 2019 14:56:05 +0100 (CET) Received: from ESESSMR501.ericsson.se (153.88.183.108) by ESESBMB502.ericsson.se (153.88.183.115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 28 Feb 2019 14:56:04 +0100 Received: from ESESBMB502.ericsson.se (153.88.183.169) 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; Thu, 28 Feb 2019 14:56:04 +0100 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB502.ericsson.se (153.88.183.169) 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; Thu, 28 Feb 2019 14:56:04 +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=nb/MsMGKDC4pcMAgEMmszcSJecm07y5JnpsTsAp2UqI=; b=Q63fZlpTAw4d9c/Oy+hBH8uOs/PxicHF1jY1MtSJcJIEUnIT0yEV8NptWmdfXZrch8ca8kYk5GRcg6rq1ZPRJgv8p8pAi3sjAPO/+cyLjyxnp+JzM6/mjaP7A7DHSICkzKLQtvBcBy2DdypPrnEKf5kI4ixzoUAx5ffsm8JRo7A= Received: from HE1PR0702MB3626.eurprd07.prod.outlook.com (52.133.6.24) by HE1PR0702MB3609.eurprd07.prod.outlook.com (10.167.126.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.11; Thu, 28 Feb 2019 13:56:03 +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; Thu, 28 Feb 2019 13:56:03 +0000 From: Nitin Katiyar To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v4 1/2] Avoid packet drop on LACP bond after link up Thread-Index: AQHUz21XhIKWIYXld0eDmfudMkZM+w== Date: Thu, 28 Feb 2019 13:56:02 +0000 Message-ID: <1551391035-18844-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: BM1PR0101CA0036.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::22) 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: 1118bb85-2422-4e22-b2a0-08d69d8479df 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:HE1PR0702MB3609; x-ms-traffictypediagnostic: HE1PR0702MB3609: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; HE1PR0702MB3609; 23:cHrWmEtTP9nixlUWtAnyrq1r7rWnHhSSP0SDQ?= =?iso-8859-1?q?cdvKwHT2OTGdPHHVf4+QPRcde?= =?iso-8859-1?q?nvZV80uqu0+Udnl4x6fMYnR1SnqZ5PADE8Bo+YMgbMmBmje/m9n?= =?iso-8859-1?q?u6zEdT/+QY0Ap3qHb66UoMZe8zxo/9yf3WqVEHRQTTBnryJjEb4?= =?iso-8859-1?q?4QfJrvzNPZhSaMas7v6BcFdFai8711AL9N2dYs9ZtW9LemYkZ6f?= =?iso-8859-1?q?OWQv6Td/D5BSGtcdZ8S4uATGLOJ3SyaED75od974IhYKbev1zNA?= =?iso-8859-1?q?6F2MGWXc2Y629zBXJ3TzD4QnfDbrnP1rA7Eyj84sRitO0E26jnQ?= =?iso-8859-1?q?d0V2ylu3330iAPXJIPt4hoVSmBGcVRV9/08HQUn1fthYD86oyuf?= =?iso-8859-1?q?/wOhjy1EXNo6eIbwvnWNmT3YYhZ17qH4L2kXcLHHa0oCmEd6TOa?= =?iso-8859-1?q?JlA6qCR/Ln96aujiAjga+jHKcYdnS5PSWdo8ZRqAJm1MurZdlcr?= =?iso-8859-1?q?QiX9U4CbFNdgOffWbioEIwfhzJwdIqhRT8um1J27EYvugk6WbO7?= =?iso-8859-1?q?GIWNtM1mGlSGx/9Qm5L7uS8DR9PuDFIToZEXC5Ev6+AUBgHKArj?= =?iso-8859-1?q?G9nfxceasr2ZryATdFGfsSkdgjKED46An3kqkwe/PlimfWDpv0q?= =?iso-8859-1?q?CyUZ2XvWeKU8YLuO5OdsKCjthWra0uDwt5D+AVoUQO0u6GVC+XS?= =?iso-8859-1?q?BnDymrPAfT8IfUNM2cI0WRM7Dr3G/Mc5kP+p2jFQngqc7mFAz8W?= =?iso-8859-1?q?cccZNtSkakBbE/laXiRvu4GdLt57yFp6vhEN9jpdyqNttOIOauG?= =?iso-8859-1?q?GN8vzG0/CUlkFZL7rQE0VRKaY2Iw4QpOXROYvCPWHq5wVH7FQlP?= =?iso-8859-1?q?XSYO7dkCJqKOefvjBGuszt+UMOVD9hbcEhmyGEbw/e3Y8BVzu3y?= =?iso-8859-1?q?BlurkU84YRRZT/EuwCUJzhndgX78P92vZqaIRQG5HE4fcrtENlj?= =?iso-8859-1?q?ehKcB5Y/Uh2ctM1yEQj8Z1iAwYAGVhyuwIEOGC6ZGLNempEjUkk?= =?iso-8859-1?q?yeX939lLSyxnKSuO9DddE5n29adEb5Ffm1rqLvDCqnLJHEtngrp?= =?iso-8859-1?q?Z8lMkIxgxxCeTBJSmnJP2eXj+MCNdSkH1QiQww9c4zCz3NZXycn?= =?iso-8859-1?q?9wXeK/UxA4mZTtgF6zo0OnhxpgtwbNL9qM7lrRF7rvVdVItn5Nf?= =?iso-8859-1?q?bM1MUEmLXJXO49gQqHF0lRL6Od7Y2EKGCyvevQodLMOz9R19V0/?= =?iso-8859-1?q?LVUwe9u3qklpg8mRx54dPntFPm5oqXbiK33AMuq3iggH73xHdMh?= =?iso-8859-1?q?jcG84j97FfFBuOQfTuF6NvIo=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(136003)(396003)(366004)(346002)(199004)(189003)(105586002)(26005)(53936002)(5660300002)(71200400001)(71190400001)(66066001)(50226002)(97736004)(478600001)(8936002)(54906003)(102836004)(386003)(6512007)(55236004)(6506007)(2906002)(2501003)(316002)(99286004)(52116002)(86362001)(6436002)(68736007)(2616005)(186003)(476003)(486006)(81156014)(6486002)(44832011)(36756003)(305945005)(3846002)(81166006)(8676002)(6116002)(2351001)(7736002)(6916009)(4326008)(5640700003)(256004)(14444005)(25786009)(106356001)(14454004); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0702MB3609; 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: 4fQpf4dnTc9vsC8NQf3Mks6GoXCo2TkR0PY+9fxHpVAJUjG3K9xPn1/y+1DilTfCzOA+c4bC/PbZtz2NuEpDjMuCvWfdaprcc8fwxZnd97hrkKAaBwt8cWBx1I+onz7tuI5ya86OeqRwS+6oMrGwXOH9Ci9eelLpj2YvZFQ8DAKZUhWQIVyo+2Ve3DVDczsrSzFFIggDzACgoy+q+JJcYTSONzuSbMuz1dpMorY74S5eGjvMdgiUd2aYn2AC+p6SAlH4SnchLLnQ3HArG0mdR9URpEMICvDT3rHdPW6jwWBY3RPAU3ImxORDQRM3EXbIPnMrKrHgO9CO159FMXuFWzHhIlwcpkTjS5jUk6dCL1fMQoKQf7LxlEOFM6yK/s+fIcYhNZSpGvNinjPm4d7oJbh1FVmhbAkSfthcriYCXxA= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 1118bb85-2422-4e22-b2a0-08d69d8479df X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 13:56:02.9424 (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: HE1PR0702MB3609 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA02SbUiTURTHuXuebY/DwXU6PakJjfxQ6nyNjIZWhJggVBSaOHS1Jzec0/bM VyiXaYS9TETDiaXhklCpKEODiJp+KEHFzVIz0XDTRFu1D5ollu5a9O33P+f+DvdcLkNJrvKD Ga3eyBr0Kp1MIKItmb1cVPHn0uwY94ZvouvLHEq841lAh3ipz5unhanzk7/RcV6WSKFmddoS 1hCdlCvS3HKY6SLPgbIHsy6BCS1F1CKGAZwA5uUztUjESPAAAndfJyJhBcGifVr4L7wcN/FJ sPKgY+K2YCvQuI4C+8gVmnQaeTA1cHnbmUfgcIxRtciHEeAY6B2tF25xAN4Pb74Ne5nCWtgY 7EZb7I+Pwg9rM4+cOQYrVWM0YTk8sjZ5mcbhYP4+4nXFOA3Wr7V7GeFAWB3s5pGZQfDB2epl wBisL0YowlJYnNvgE5bBaDdxAYdBe5fDuw5gC4LVLgsiQ5XgnnNtC5EwNO5EhHeCvfX6NqdD 1UyVkMhOBNXPHELyrpEwPr6P1N1iqF/qp0m9EL52nSRuKNyv/kjVoejm/+5NWA4TjQ0CwhHQ cW+Javbu7AdvLU66DdGdSMqx3NmCvLg4OWvQnuO4Qr1czxqfoM3f8brnV0wfWlw4bEOYQTJf seh9abaEryrhygtsCBhKFiDO/LRZEqtV5RWsoTDHUKxjORsKYWhZkHhd4pctwXkqI5vPskWs 4W+Xx/gEmxA1NJHF7tK4+0MbQtYeDrxTjkbU3FWqX5mNU7HD6afjWxMF/j26yaR2T1uenZuw XQjJKgtTS8OUsh0JUdITGW01eecvrR1pfLwnIjwlvCnZNP3D4v7Zoui7iF1lFZUtuTnJ+U93 r1RqMtJOmWoDh2ctoXJFyk2F33K850bXzEEZzWlUsXspA6f6A/+AbF8ZAwAA 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 v4 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: Manohar Krishnappa Chidambaraswamy Co-authored-by: Manohar Krishnappa Chidambaraswamy Signed-off-by: Nitin Katiyar --- lib/lacp.c | 10 +++++++++- lib/lacp.h | 2 +- ofproto/bond.c | 16 +++++++++++++--- ofproto/ofproto-dpif-xlate.c | 10 +++++++++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/lib/lacp.c b/lib/lacp.c index d6b36aa..e768012 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,7 +325,7 @@ 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 +bool lacp_process_packet(struct lacp *lacp, 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..0dfaef0 100644 --- a/lib/lacp.h +++ b/lib/lacp.h @@ -46,7 +46,7 @@ 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 *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 c4014d7..8f44566 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -3307,6 +3307,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; @@ -3327,7 +3328,14 @@ 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->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 Thu Feb 28 13:56:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitin Katiyar X-Patchwork-Id: 1049517 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="aJuKyLpW"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="dPVGPi6c"; 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 449DnL4vHbz9s1b for ; Fri, 1 Mar 2019 01:04:22 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 2F8E1A2C1; Thu, 28 Feb 2019 14:03:45 +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 DAF75A2BE for ; Thu, 28 Feb 2019 13:56:25 +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 7B8B376D for ; Thu, 28 Feb 2019 13:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1551362182; x=1553954182; 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=B800WjtG81IRxKQJUhfByz+QLe/osdQYwjadSiOoTvA=; b=aJuKyLpWgvL0g0ZZKNRCbbMsFLG3lNigLw5Ynbpm6fm+5z0jkGgbyDe5xaFUwX1d L2RiQDYgi8JWR9kU1pc2LvZs7drC9iZovRyFPvYgQPKAdTXbkKaa7JoM2EHGrx8A HZKXXZLsWvAJCTWzC6cklb8k+fVWlyRUQJN/7ENNWJc=; X-AuditID: c1b4fb3a-167ff7000000672c-82-5c77e8861499 Received: from ESESBMB505.ericsson.se (Unknown_Domain [153.88.183.118]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id A8.A8.26412.688E77C5; Thu, 28 Feb 2019 14:56:22 +0100 (CET) Received: from ESESBMR503.ericsson.se (153.88.183.135) by ESESBMB505.ericsson.se (153.88.183.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 28 Feb 2019 14:56:22 +0100 Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESBMR503.ericsson.se (153.88.183.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 28 Feb 2019 14:56:22 +0100 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (153.88.183.157) 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 via Frontend Transport; Thu, 28 Feb 2019 14:56:22 +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=B800WjtG81IRxKQJUhfByz+QLe/osdQYwjadSiOoTvA=; b=dPVGPi6c4xZzgfDYWL7W04MaLIuSsJfkLq7Pcrrs5ab2CfxpKYvzlIHCOW9BpBh5vdFYRuxpXjJAp8wiQJvFJCZEuBZV2UixJnlWEi5GJrLa+NyOutEEOVCN0bfo9a1FjgTAUtDDZFMLfKSCtHcV8amady85Eq0L8G71v3EYqbM= Received: from HE1PR0702MB3626.eurprd07.prod.outlook.com (52.133.6.24) by HE1PR0702MB3708.eurprd07.prod.outlook.com (52.133.6.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.6; Thu, 28 Feb 2019 13:56:21 +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; Thu, 28 Feb 2019 13:56:21 +0000 From: Nitin Katiyar To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v4 2/2] Avoid packet drop on LACP bond after link up Thread-Index: AQHUz21iGGEOD1tCbU2KZ3gD23j0vw== Date: Thu, 28 Feb 2019 13:56:20 +0000 Message-ID: <1551391035-18844-2-git-send-email-nitin.katiyar@ericsson.com> References: <1551391035-18844-1-git-send-email-nitin.katiyar@ericsson.com> In-Reply-To: <1551391035-18844-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: BM1PR0101CA0036.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::22) 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: ab96bebc-5b76-4446-23e3-08d69d8484b5 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:HE1PR0702MB3708; x-ms-traffictypediagnostic: HE1PR0702MB3708: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; HE1PR0702MB3708; 23:yj7CQ1A0LYwAbOJw75T67e5DQg8wsu18S75KR?= =?iso-8859-1?q?UFJXPE/rJeuxO9YPlZCAjGAIx?= =?iso-8859-1?q?C7Wf3pT1xcM9hWHoyUZrIE9ZnlbNOzf623+Z43zQc2654fWyImi?= =?iso-8859-1?q?zHT0aaYMv65VpY/1IdgBXA24vuilr+N6AdOj87nPj+q9MyEm19e?= =?iso-8859-1?q?/+Hjp3XVnQK3c8FfKrfxH6B3m2lsgtlrJ/JtloQp/bsU4vxFbC0?= =?iso-8859-1?q?Mg3lu9MS0Dh1XGVMwlSs4+vrEKfeonuVS2+uFPml2NbwVQJGrz9?= =?iso-8859-1?q?WaSqa5L4lsBHXDlqz1SH/kencOQ1XZlqgELZHXIWBRU8G5+mn2u?= =?iso-8859-1?q?hjDw59pCPBcauWja/eWbA9AZPiCw+s5KM5vprPeahRwlE/LA3DS?= =?iso-8859-1?q?265r7LnoKPt/AYhUavwaebiHcwU9A7ShGZHi6pg8423XUufzqK5?= =?iso-8859-1?q?vbzPyoDfFvx3h+poS+cS/laGmv79Z2Et0fV8jPgkEeVxXqoRl30?= =?iso-8859-1?q?5LTRx+J9gYnacjcxFUP5h8ZAbimdgBOKDW+757RK428wGaFjWs8?= =?iso-8859-1?q?houBPt6nU43eVVQW4KM55DQSvk9KTGpvy4rKNWr1+AOCAET2NzR?= =?iso-8859-1?q?Lcm5epRm1OiCHj9ugbFgS38BYZQNulRtd/VL6dSFP01SzOQbPwk?= =?iso-8859-1?q?b3jS56BlT0XCsqw7bmN93lhY1tofDVduh1oxYbbgFv684wFRA+Y?= =?iso-8859-1?q?ZOLqpW13VK9GpFvO0CZ0FM+G4r8bBY1021vaiLXBpNlrj1kvOpL?= =?iso-8859-1?q?5r6w0dl4XFNk1cQf9xKmS7PTJMmXEzKxFW6ZcQGzyKYTeG+f0Ur?= =?iso-8859-1?q?1GCtHEnYGdYUkeejjTs2HFrLcTrZXOFRgD4yL3oeLVoTmj9CvPm?= =?iso-8859-1?q?PONE2KFhrA91Vao2SwDPkDiTULoVGLcpNMkxuyEOaPvpLY+oUbZ?= =?iso-8859-1?q?k0Vw6H8aOeic85xL3BTCbIu0OWsbyOwgrv65IwXy/y/rBMtExVp?= =?iso-8859-1?q?MhOB9cTghFYud9iTb4iYFZ1mKAegdtagf4pHpzTEZ0RjUb+qQHR?= =?iso-8859-1?q?gUH/ZQAeqkbNJhhmXrYRx59lDpaMKG4foNx0PekcMFiFaY6XwWF?= =?iso-8859-1?q?91SMZtV6MfbGZP/p9a+p2HmQZLvoGc4ibCBB9ZaytvSUNJV/fq5?= =?iso-8859-1?q?/NtxWkkEAMkIhLGz5SPjSh5LJdmC1GsmpVWpVeBUioNwDLtknIf?= =?iso-8859-1?q?SqTITBvlJ3ejWF/WwdP+S1JJvjV+CCJJjZLf0FimxAr0GzWzbLK?= =?iso-8859-1?q?sxU9UpWjfB1iYGPHQlYUuWiOW+5YK9s9i8//Nw1NtLR2zrnpi6D?= =?iso-8859-1?q?PJUfkE/3Wh9ImUAGEDkrv3m3BaV/LXM7r4tKJq7lHiYRoJ471+X?= =?iso-8859-1?q?ZNK9iT9rZW39gi2F0npz9lzBvq1gPPQbFCSqc=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(346002)(136003)(39860400002)(366004)(189003)(199004)(86362001)(6512007)(305945005)(7736002)(8676002)(81166006)(81156014)(478600001)(53936002)(50226002)(105586002)(106356001)(8936002)(14454004)(6436002)(5640700003)(68736007)(6486002)(54906003)(2906002)(4326008)(316002)(97736004)(2351001)(3846002)(6116002)(25786009)(2501003)(66066001)(256004)(14444005)(99286004)(2616005)(186003)(476003)(486006)(446003)(11346002)(5660300002)(44832011)(71200400001)(71190400001)(386003)(52116002)(6916009)(55236004)(76176011)(6506007)(26005)(36756003)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0702MB3708; H:HE1PR0702MB3626.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: 1BXEcsA8hy3aRxEkVqS3kcmfiuOi4Nn3dzB3ElLeREVL5ZTEj6/7HVTKp5Ioq45meyww9dZogj13lOqsFHA9BhrgTxAbRm4pnzco+UVasDLncd5XHAxD8fU+5WAi/wGXycpswcBZtKu8SXky9JdXe+hMJD9eAerCOF1gTpSvFQ8Ji4qX6ihJ1OfL+zo4zZBwjIXtbje/1CInNVqth9fYTioD+eC4/7+2lEg9661PMiUmcZai993tChnkHxCewOuaAWOyV2f0tYtPQZonLbWD18aR7WH6nyKr2kHAtzMWFxOZ9swNE7bDw5JR3wFvRn5I5teotDPCXsil8PQNBjLeFn83tlnOEEgDUBIxPu092ycQgK0/W/SvHmeBtmLcnd6R0S8XzZs3hHg5AuHs2L1z7FDAYqLmQlWaxEhsM1h6KJ0= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: ab96bebc-5b76-4446-23e3-08d69d8484b5 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 13:56:21.0033 (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: HE1PR0702MB3708 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgleLIzCtJLcpLzFFi42KZGbG9TLftRXmMwb8juhZP3z5mtJj76Tmj A5PHzll32T2e3fzPGMAUxWWTkpqTWZZapG+XwJXx8/kBtoLFkRX96+8yNzBOd+li5OSQEDCR 2LPrNGMXIxeHkMARRomGz60sEM43Roklz14xwzkHD3+DcpYwSTy40M0E4rAITGCWePz/AytE ZjKTxL+Fj6EGPGOUaOv/ygiyhk3AQGL7xUnsILaIgLnEiQ/nwGxmgUyJf6fWgNUIC7hInD/w iQmixlPi7ortrBC2nsTkB61sIDaLgKrE5GcfwGp4BbwkLk9fB2YLAdnT5p4Dqufg4BTwllhz MQ0kzCggJvH91BomiFXiEreezGeC+FpAYsme88wQtqjEy8f/WCFsJYmLaxazQ9hyEotXX2YD +UVCYCajxPfVMxkhhsZKvHv8FKpBR+Ls9SeMELasxKX53VC2r0Trn5tMEM1PGCXuds9kg2nY M+0C1NRDfBKvl/exT2A0nIXkQghbT+LG1ClsELa2xLKFr5lngT0tKHFy5hOWBYwsqxhFi1OL i3PTjYz0Uosyk4uL8/P08lJLNjEC08fBLb+tdjAefO54iFGAg1GJh1fqWnmMEGtiWXFl7iFG CQ5mJRHeiIdAId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rx/hARjhATSE0tSs1NTC1KLYLJMHJxS DYy26R/1tFes6fCw0U24rPT4RL7+pUm2LbqcmeF2rQukTP/dVK14cJkzjm3R0s1ioSffz/aY m6S4Vcd+/d3z8hplYR98zxzPz962kPXfyTnnmvZ29ZX/+tNTZLlZLvuQQ13o7vs2k+5pVHTf 3nho0/uzDw3kj+l/bXjx1vMf29/a/cfb9dNEi98rsRRnJBpqMRcVJwIAz0+VnxsDAAA= 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 v4 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: Manohar Krishnappa Chidambaraswamy Co-authored-by: Manohar Krishnappa Chidambaraswamy Signed-off-by: Nitin Katiyar --- lib/lacp.c | 44 +++++++++++++++++++++++++++++++++++--------- 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, 80 insertions(+), 16 deletions(-) diff --git a/lib/lacp.c b/lib/lacp.c index e768012..2bfa267 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,21 @@ 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 LACPDU and + * trigger re-checking of L1 state. + */ + carrier_up = bond_slave_get_carrier(bond, slave->aux); + 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 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 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-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; }