net/bonding: fix device configure reentrancy

Message ID 20221101161853.2702425-1-ivan.malov@oktetlabs.ru (mailing list archive)
State Accepted, archived
Delegated to: Andrew Rybchenko
Headers
Series net/bonding: fix device configure reentrancy |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed

Commit Message

Ivan Malov Nov. 1, 2022, 4:18 p.m. UTC
  As per report [1], the previous patch for device
configure code apparently overlooks the corner
case of manually adding back-end devices to
the bond using testpmd CLI. The problem is
in removing back-end ports on re-configure
instead of just stopping them. Fix that.

Fixes: 339f1ba51353 ("net/bonding: make configure method re-entrant")
Cc: stable@dpdk.org

[1] https://bugs.dpdk.org/show_bug.cgi?id=1119

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
---
 drivers/net/bonding/eth_bond_private.h |  2 ++
 drivers/net/bonding/rte_eth_bond_pmd.c | 17 ++++++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)
  

Comments

Stephen Hemminger Nov. 1, 2022, 7:32 p.m. UTC | #1
On Tue,  1 Nov 2022 19:18:53 +0300
Ivan Malov <ivan.malov@oktetlabs.ru> wrote:

> diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h
> index d067ea8c9a..7171516d0d 100644
> --- a/drivers/net/bonding/eth_bond_private.h
> +++ b/drivers/net/bonding/eth_bond_private.h
> @@ -184,6 +184,8 @@ struct bond_dev_private {
>  
>  	void *vlan_filter_bmpmem;		/* enabled vlan filter bitmap */
>  	struct rte_bitmap *vlan_filter_bmp;
> +
> +	bool kvargs_processing_is_done;
>  };

Minor nit: why not use existing hole in data structure after slave_update_idx?
  
Yuan, DukaiX Nov. 2, 2022, 3:35 a.m. UTC | #2
-----Original Message-----
From: Ivan Malov <ivan.malov@oktetlabs.ru> 
Sent: 2022年11月2日 0:19
To: dev@dpdk.org
Cc: Jiang, YuX <yux.jiang@intel.com>; Chas Williams <chas3@att.com>; Min Hu (Connor) <humin29@huawei.com>; Burakov, Anatoly <anatoly.burakov@intel.com>; stable@dpdk.org; Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: [PATCH] net/bonding: fix device configure reentrancy

As per report [1], the previous patch for device configure code apparently overlooks the corner case of manually adding back-end devices to the bond using testpmd CLI. The problem is in removing back-end ports on re-configure instead of just stopping them. Fix that.

Fixes: 339f1ba51353 ("net/bonding: make configure method re-entrant")
Cc: stable@dpdk.org

[1] https://bugs.dpdk.org/show_bug.cgi?id=1119

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
---
Tested-by: Dukai Yuan<dukaix.yuan@intel.com>
  
Andrew Rybchenko Nov. 6, 2022, 9:35 a.m. UTC | #3
On 11/1/22 22:32, Stephen Hemminger wrote:
> On Tue,  1 Nov 2022 19:18:53 +0300
> Ivan Malov <ivan.malov@oktetlabs.ru> wrote:
> 
>> diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h
>> index d067ea8c9a..7171516d0d 100644
>> --- a/drivers/net/bonding/eth_bond_private.h
>> +++ b/drivers/net/bonding/eth_bond_private.h
>> @@ -184,6 +184,8 @@ struct bond_dev_private {
>>   
>>   	void *vlan_filter_bmpmem;		/* enabled vlan filter bitmap */
>>   	struct rte_bitmap *vlan_filter_bmp;
>> +
>> +	bool kvargs_processing_is_done;
>>   };
> 
> Minor nit: why not use existing hole in data structure after slave_update_idx?
> 

Good idea, I'll update it on applying. Thanks.
  
Andrew Rybchenko Nov. 6, 2022, 9:37 a.m. UTC | #4
On 11/2/22 06:35, Yuan, DukaiX wrote:
> -----Original Message-----
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
> Sent: 2022年11月2日 0:19
> To: dev@dpdk.org
> Cc: Jiang, YuX <yux.jiang@intel.com>; Chas Williams <chas3@att.com>; Min Hu (Connor) <humin29@huawei.com>; Burakov, Anatoly <anatoly.burakov@intel.com>; stable@dpdk.org; Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Subject: [PATCH] net/bonding: fix device configure reentrancy
> 
> As per report [1], the previous patch for device configure code apparently overlooks the corner case of manually adding back-end devices to the bond using testpmd CLI. The problem is in removing back-end ports on re-configure instead of just stopping them. Fix that.
> 
> Fixes: 339f1ba51353 ("net/bonding: make configure method re-entrant")
> Cc: stable@dpdk.org
> 
> [1] https://bugs.dpdk.org/show_bug.cgi?id=1119
> 
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> ---
> Tested-by: Dukai Yuan<dukaix.yuan@intel.com>

Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

Applied to dpdk-next-net/main with minor fix suggested by
Stephen, thanks.
  

Patch

diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h
index d067ea8c9a..7171516d0d 100644
--- a/drivers/net/bonding/eth_bond_private.h
+++ b/drivers/net/bonding/eth_bond_private.h
@@ -184,6 +184,8 @@  struct bond_dev_private {
 
 	void *vlan_filter_bmpmem;		/* enabled vlan filter bitmap */
 	struct rte_bitmap *vlan_filter_bmp;
+
+	bool kvargs_processing_is_done;
 };
 
 extern const struct eth_dev_ops default_dev_ops;
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index dc74852137..bd25040851 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2170,7 +2170,7 @@  bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 }
 
 static void
-bond_ethdev_cfg_cleanup(struct rte_eth_dev *dev)
+bond_ethdev_cfg_cleanup(struct rte_eth_dev *dev, bool remove)
 {
 	struct bond_dev_private *internals = dev->data->dev_private;
 	uint16_t bond_port_id = internals->port_id;
@@ -2182,10 +2182,15 @@  bond_ethdev_cfg_cleanup(struct rte_eth_dev *dev)
 
 	while (internals->slave_count != skipped) {
 		uint16_t port_id = internals->slaves[skipped].port_id;
+		int ret;
 
-		if (rte_eth_dev_stop(port_id) != 0) {
+		ret = rte_eth_dev_stop(port_id);
+		if (ret != 0) {
 			RTE_BOND_LOG(ERR, "Failed to stop device on port %u",
 				     port_id);
+		}
+
+		if (ret != 0 || !remove) {
 			skipped++;
 			continue;
 		}
@@ -2209,7 +2214,7 @@  bond_ethdev_close(struct rte_eth_dev *dev)
 
 	RTE_BOND_LOG(INFO, "Closing bonded device %s", dev->device->name);
 
-	bond_ethdev_cfg_cleanup(dev);
+	bond_ethdev_cfg_cleanup(dev, true);
 
 	bond_ethdev_free_queues(dev);
 	rte_bitmap_reset(internals->vlan_filter_bmp);
@@ -3644,7 +3649,7 @@  bond_ethdev_configure(struct rte_eth_dev *dev)
 	unsigned i, j;
 
 
-	bond_ethdev_cfg_cleanup(dev);
+	bond_ethdev_cfg_cleanup(dev, false);
 
 	/*
 	 * If RSS is enabled, fill table with default values and
@@ -3733,9 +3738,11 @@  bond_ethdev_configure(struct rte_eth_dev *dev)
 	 * if no kvlist, it means that this bonded device has been created
 	 * through the bonding api.
 	 */
-	if (!kvlist)
+	if (!kvlist || internals->kvargs_processing_is_done)
 		return 0;
 
+	internals->kvargs_processing_is_done = true;
+
 	/* Parse MAC address for bonded device */
 	arg_count = rte_kvargs_count(kvlist, PMD_BOND_MAC_ADDR_KVARG);
 	if (arg_count == 1) {