patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Ivan Malov <ivan.malov@oktetlabs.ru>
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
Date: Tue,  1 Nov 2022 19:18:53 +0300	[thread overview]
Message-ID: <20221101161853.2702425-1-ivan.malov@oktetlabs.ru> (raw)

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(-)

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) {
-- 
2.30.2


             reply	other threads:[~2022-11-01 16:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 16:18 Ivan Malov [this message]
2022-11-01 19:32 ` Stephen Hemminger
2022-11-06  9:35   ` Andrew Rybchenko
2022-11-02  3:35 ` Yuan, DukaiX
2022-11-06  9:37   ` Andrew Rybchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221101161853.2702425-1-ivan.malov@oktetlabs.ru \
    --to=ivan.malov@oktetlabs.ru \
    --cc=anatoly.burakov@intel.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=chas3@att.com \
    --cc=dev@dpdk.org \
    --cc=humin29@huawei.com \
    --cc=stable@dpdk.org \
    --cc=yux.jiang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).