From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <radu.nicolau@intel.com>
Received: from mga09.intel.com (mga09.intel.com [134.134.136.24])
 by dpdk.org (Postfix) with ESMTP id 4379F235;
 Wed, 25 Jul 2018 11:46:24 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 25 Jul 2018 02:46:23 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.51,400,1526367600"; d="scan'208";a="75766283"
Received: from silpixa00383879.ir.intel.com (HELO
 silpixa00383879.ger.corp.intel.com) ([10.237.223.127])
 by orsmga001.jf.intel.com with ESMTP; 25 Jul 2018 02:46:22 -0700
From: Radu Nicolau <radu.nicolau@intel.com>
To: dev@dpdk.org
Cc: declan.doherty@intel.com, chas3@att.com, ferruh.yigit@intel.com,
 Radu Nicolau <radu.nicolau@intel.com>, stable@dpdk.org
Date: Wed, 25 Jul 2018 10:39:40 +0100
Message-Id: <1532511580-2631-1-git-send-email-radu.nicolau@intel.com>
X-Mailer: git-send-email 2.7.5
In-Reply-To: <1532080957-26940-1-git-send-email-radu.nicolau@intel.com>
References: <1532080957-26940-1-git-send-email-radu.nicolau@intel.com>
Subject: [dpdk-stable] [PATCH v2] net/bonding: fix race condition
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 25 Jul 2018 09:46:26 -0000

Race condition can appear in the bond_mode_8023ad_periodic_cb()
callback when bonding port is stopped, reconfigured and restarted.

Re-ordered calls in bond_ethdev_start() to have callback alarm set
after slave ports are reconfigured.

Fixes: 2efb58cbab6e ("bond: new link bonding library")
Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
v2: reworked patch

 drivers/net/bonding/rte_eth_bond_pmd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index fc4d4fd..70ec728 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2113,10 +2113,6 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 		}
 	}
 
-	/* Update all slave devices MACs*/
-	if (mac_address_slaves_update(eth_dev) != 0)
-		goto out_err;
-
 	/* If bonded device is configure in promiscuous mode then re-apply config */
 	if (internals->promiscuous_en)
 		bond_ethdev_promiscuous_enable(eth_dev);
@@ -2157,6 +2153,10 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 			(void *)&rte_eth_devices[internals->port_id]);
 	}
 
+	/* Update all slave devices MACs*/
+	if (mac_address_slaves_update(eth_dev) != 0)
+		goto out_err;
+
 	if (internals->user_defined_primary_port)
 		bond_ethdev_primary_set(internals, internals->primary_port);
 
-- 
2.7.5