From patchwork Thu Sep 28 01:03:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh Bandewar X-Patchwork-Id: 819368 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bandewar-net.20150623.gappssmtp.com header.i=@bandewar-net.20150623.gappssmtp.com header.b="Nr72md8N"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y2bzy6lPgz9t5C for ; Thu, 28 Sep 2017 11:03:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752555AbdI1BD4 (ORCPT ); Wed, 27 Sep 2017 21:03:56 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35081 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752520AbdI1BDz (ORCPT ); Wed, 27 Sep 2017 21:03:55 -0400 Received: by mail-pf0-f193.google.com with SMTP id i23so18433pfi.2 for ; Wed, 27 Sep 2017 18:03:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bandewar-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=TWIevZOerx0bDeyDCTmlGLOSEljjYl9xVeC/1aBryR0=; b=Nr72md8NS3XceEQ8cAIYivQukmzwHlj54/vbUk/dW13oUlNUgH5gNIuQvbFW+1BNWt OIJYJN8Iw5D+3tPd9NKTtej+ZbGD/OvT2vRHRWqNU1AuHAPGje86kkyTbEJw2yEfeAAe 0jl6Y00ot1IXZZwGmI9xs2IombZ5+Uax7/QVEijNwXV6Pd1j/+lETZvaY8GJb5KJwm0C g+AzRsTV/jqn5fve0k49EyeeuHhng9dPYUVCGsCwCcW4mgq1SUg60QCt/YBxVzmistiV 4WPo53brbBXJeUTJPT+GuRRjEBuK1ngUHLJ03FeecHzxUAgCpW/U5xCRJEZcqfK7vBXQ HSEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TWIevZOerx0bDeyDCTmlGLOSEljjYl9xVeC/1aBryR0=; b=IZneOBGvqhCnA4z08p1KbPG9QRI8P+XnLf/CTIgT6ppvd28Myao5Wh91at2eNzFii5 dmCta/wl8GZgqQ/dJU62XAsHNObG89U82swuYr2aNLn5SdKI6vMiiAOvESwNB1DaXtFQ sMtP1mIbPJBfW1KQR7l4X2E1+bOrLDQ08WWh6dsj+GKxjQ5Mz6I8wBkIJ513srbV1R68 7/bwIjzhEoUZ6Pv6Mfn3cFxLCkMjDeSpT/NOMafbCuFJQKKwxw9m6AW7pX5oh1nTl/Sh OcMCFDmN+rtbET//uMlNETOXufkrDIfJn69tBQEWlZBCqmTUai0avS7rp6JY2U/Rw4M3 6tyQ== X-Gm-Message-State: AHPjjUjPMCIZI1L0VngbTQEuHwvtQzQ4tBwKwXgfVbDtnEBOlsOJIIQx Ag/yfq4bFBUECIQ2sv10Ae7KzA== X-Google-Smtp-Source: AOwi7QDBOlXetDeUeFfySI6zSzklFlttN6jVVgzT4K190qzjTFvue+FQ9q1jHycPZ6Zi9iqjOM5NCw== X-Received: by 10.98.10.146 with SMTP id 18mr2746620pfk.346.1506560635006; Wed, 27 Sep 2017 18:03:55 -0700 (PDT) Received: from localhost ([2620:15c:2cb:201:b9ec:cca:f2e7:81d7]) by smtp.gmail.com with ESMTPSA id b68sm285416pfk.23.2017.09.27.18.03.53 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 27 Sep 2017 18:03:53 -0700 (PDT) From: Mahesh Bandewar To: Jay Vosburgh , Andy Gospodarek , Veaceslav Falico , David Miller Cc: Mahesh Bandewar , Netdev , Mahesh Bandewar Subject: [PATCH next] bonding: speed/duplex update at NETDEV_UP event Date: Wed, 27 Sep 2017 18:03:49 -0700 Message-Id: <20170928010349.8988-1-mahesh@bandewar.net> X-Mailer: git-send-email 2.14.2.822.g60be5d43e6-goog Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Mahesh Bandewar Some NIC drivers don't have correct speed/duplex settings at the time they send NETDEV_UP notification and that messes up the bonding state. Especially 802.3ad mode which is very sensitive to these settings. In the current implementation we invoke bond_update_speed_duplex() when we receive NETDEV_UP, however, ignore the return value. If the values we get are invalid (UNKNOWN), then slave gets removed from the aggregator with speed and duplex set to UNKNOWN while link is still marked as UP. This patch fixes this scenario. Also 802.3ad mode is sensitive to these conditions while other modes are not, so making sure that it doesn't change the behavior for other modes. Signed-off-by: Mahesh Bandewar --- drivers/net/bonding/bond_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b7313c1d9dcd..177be373966b 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3076,7 +3076,16 @@ static int bond_slave_netdev_event(unsigned long event, break; case NETDEV_UP: case NETDEV_CHANGE: - bond_update_speed_duplex(slave); + /* For 802.3ad mode only: + * Getting invalid Speed/Duplex values here will put slave + * in weird state. So mark it as link-down for the time + * being and let link-monitoring (miimon) set it right when + * correct speeds/duplex are available. + */ + if (bond_update_speed_duplex(slave) && + BOND_MODE(bond) == BOND_MODE_8023AD) + slave->link = BOND_LINK_DOWN; + if (BOND_MODE(bond) == BOND_MODE_8023AD) bond_3ad_adapter_speed_duplex_changed(slave); /* Fallthrough */