From patchwork Wed Dec 21 17:26:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 707909 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3tkM5S4gnwz9svs for ; Thu, 22 Dec 2016 04:26:36 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7D48AB9E; Wed, 21 Dec 2016 17:26:34 +0000 (UTC) X-Original-To: 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 36383B8B for ; Wed, 21 Dec 2016 17:26:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8FD751A4 for ; Wed, 21 Dec 2016 17:26:32 +0000 (UTC) Received: from mfilter28-d.gandi.net (mfilter28-d.gandi.net [217.70.178.159]) by relay2-d.mail.gandi.net (Postfix) with ESMTP id 5C034C5A81; Wed, 21 Dec 2016 18:26:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter28-d.gandi.net Received: from relay2-d.mail.gandi.net ([IPv6:::ffff:217.70.183.194]) by mfilter28-d.gandi.net (mfilter28-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id VQWYfO7TYz9k; Wed, 21 Dec 2016 18:26:29 +0100 (CET) X-Originating-IP: 173.228.112.229 Received: from sigabrt.gateway.sonic.net (173-228-112-229.dsl.dynamic.fusionbroadband.com [173.228.112.229]) (Authenticated sender: blp@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id DC916C5A5C; Wed, 21 Dec 2016 18:26:28 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 21 Dec 2016 09:26:27 -0800 Message-Id: <20161221172627.31819-1-blp@ovn.org> X-Mailer: git-send-email 2.10.2 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH v2] lacp: Select a may-enable IF as the lead IF 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: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org A reboot of one switch in an MC-LAG bond makes all bond links to go down, causing a total connectivity loss for 3 seconds. Packet capture shows that spurious LACP PDUs are sent to OVS with a different MAC address (partner system id) during the final stages of the MC-LAG switch reboot. The current code selects a lead interface based on information in the LACP PDU, regardless of its synchronization state. If a non-synchronized interface is selected as the OVS lead interface then all other interfaces are forced down as their stored partner system id differs and the bond ends up with no working interface. The bond recovers within three seconds after the last spurious message. To avoid the problem, this commit requires a lead interface to be synchronized. In case no synchronized interface exists, the selection of lead interface is done as in the current code. Signed-off-by: Torgny Lindberg Signed-off-by: Ben Pfaff --- v1->v2: Rewrite preference for a synchronized interface in terms of a comparison inside the loop. lib/lacp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/lacp.c b/lib/lacp.c index ad6ef8e..84b2cf6 100644 --- a/lib/lacp.c +++ b/lib/lacp.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, 2012, 2013, 2014, 2015 Nicira, Inc. +/* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -596,11 +596,13 @@ lacp_update_attached(struct lacp *lacp) OVS_REQUIRES(mutex) { struct slave *lead, *slave; struct lacp_info lead_pri; + bool lead_enable; static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 10); lacp->update = false; lead = NULL; + lead_enable = false; HMAP_FOR_EACH (slave, node, &lacp->slaves) { struct lacp_info pri; @@ -623,9 +625,14 @@ lacp_update_attached(struct lacp *lacp) OVS_REQUIRES(mutex) slave->attached = true; slave_get_priority(slave, &pri); + bool enable = slave_may_enable__(slave); - if (!lead || memcmp(&pri, &lead_pri, sizeof pri) < 0) { + if (!lead + || enable > lead_enable + || (enable == lead_enable + && memcmp(&pri, &lead_pri, sizeof pri) < 0)) { lead = slave; + lead_enable = enable; lead_pri = pri; } }