From patchwork Fri Feb 14 17:13:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Bohac X-Patchwork-Id: 320495 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 99DF82C009E for ; Sat, 15 Feb 2014 04:13:58 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751594AbaBNRNy (ORCPT ); Fri, 14 Feb 2014 12:13:54 -0500 Received: from mail-we0-f174.google.com ([74.125.82.174]:60960 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751277AbaBNRNx (ORCPT ); Fri, 14 Feb 2014 12:13:53 -0500 Received: by mail-we0-f174.google.com with SMTP id w61so3222019wes.5 for ; Fri, 14 Feb 2014 09:13:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=X6KBUWJXz8POKScsOmN9VTgTnTW1Qa4ed40Z82sXUbM=; b=UJAfZ6S5wrYXx3LV+6LvBxUGFCHJTxIPyK98Uj6JO5dqyyWBKZz18pk2O1J2x1+u5l 3dJO6YMMVaDwtzpjo3hCk5ICqBjhZktCROPJMGsl8IU0KtSj1/NhbYINcngRyJgpP2PP V85C9DjmpIeMEI7l35s41WIxtpzCDnbTpr+Doo+dnT84j8+7qZArUu4L0OvIPAORa/9x gQvhBnkBJzv2iqqm05KZN4m+26vkzU0shWTp9kJp4Ht4Pb4ugTTMbM45klmeihWNjkh3 +oiK/+OBjOfTp/rwqq/MXjjSfKV/y9peMSNvqv7wwWktW70RFpLqoZGYIUGuOICDCpGS Rdsg== X-Gm-Message-State: ALoCoQk6txtjG+LUw0Eh65gMkOZTOtDzPyQ/QpjvtFWfUmAuKKkfYSWXk3SCQ3+XQee3PlGknpuf X-Received: by 10.180.108.199 with SMTP id hm7mr3196323wib.1.1392398032173; Fri, 14 Feb 2014 09:13:52 -0800 (PST) Received: from localhost (cl-455.prg-01.cz.sixxs.net. [2a01:8c00:ff00:1c6::2]) by mx.google.com with ESMTPSA id jd2sm6057704wic.9.2014.02.14.09.13.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Feb 2014 09:13:51 -0800 (PST) Date: Fri, 14 Feb 2014 18:13:50 +0100 From: Jiri Bohac To: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek Cc: netdev@vger.kernel.org Subject: [PATCH] bonding: 802.3ad: make aggregator_identifier bond-private Message-ID: <20140214171350.GC11688@midget.suse.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org aggregator_identifier is used to assign unique aggregator identifiers to aggregators of a bond during device enslaving. aggregator_identifier is currently a global variable that is zeroed in bond_3ad_initialize(). This sequence will lead to duplicate aggregator identifiers for eth1 and eth3: create bond0 change bond0 mode to 802.3ad enslave eth0 to bond0 //eth0 gets agg id 1 enslave eth1 to bond0 //eth1 gets agg id 2 create bond1 change bond1 mode to 802.3ad enslave eth2 to bond1 //aggregator_identifier is reset to 0 //eth2 gets agg id 1 enslave eth3 to bond0 //eth3 gets agg id 2 Fix this by making aggregator_identifier private to the bond. Signed-off-by: Jiri Bohac Acked-by: Veaceslav Falico --- drivers/net/bonding/bond_3ad.c | 6 ++---- drivers/net/bonding/bond_3ad.h | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 4ced594..dcf2ee8 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -1806,8 +1806,6 @@ void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout) BOND_AD_INFO(bond).agg_select_timer = timeout; } -static u16 aggregator_identifier; - /** * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures * @bond: bonding struct to work on @@ -1821,7 +1819,7 @@ void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution) if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond).system.sys_mac_addr), bond->dev->dev_addr)) { - aggregator_identifier = 0; + BOND_AD_INFO(bond).aggregator_identifier = 0; BOND_AD_INFO(bond).system.sys_priority = 0xFFFF; BOND_AD_INFO(bond).system.sys_mac_addr = *((struct mac_addr *)bond->dev->dev_addr); @@ -1892,7 +1890,7 @@ int bond_3ad_bind_slave(struct slave *slave) ad_initialize_agg(aggregator); aggregator->aggregator_mac_address = *((struct mac_addr *)bond->dev->dev_addr); - aggregator->aggregator_identifier = (++aggregator_identifier); + aggregator->aggregator_identifier = ++BOND_AD_INFO(bond).aggregator_identifier; aggregator->slave = slave; aggregator->is_active = 0; aggregator->num_of_ports = 0; diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h index 5d91ad0..1f081c8 100644 --- a/drivers/net/bonding/bond_3ad.h +++ b/drivers/net/bonding/bond_3ad.h @@ -253,6 +253,7 @@ struct ad_system { struct ad_bond_info { struct ad_system system; /* 802.3ad system structure */ u32 agg_select_timer; // Timer to select aggregator after all adapter's hand shakes + u16 aggregator_identifier; }; struct ad_slave_info {