From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 40C6DA00C4 for ; Tue, 1 Nov 2022 17:18:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3656E40A80; Tue, 1 Nov 2022 17:18:57 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 0914F40223; Tue, 1 Nov 2022 17:18:56 +0100 (CET) Received: from bree.oktetlabs.ru (bree.oktetlabs.ru [192.168.34.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPS id 54E6C5A; Tue, 1 Nov 2022 19:18:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 54E6C5A Authentication-Results: shelob.oktetlabs.ru/54E6C5A; dkim=none; dkim-atps=neutral From: Ivan Malov To: dev@dpdk.org Cc: "Jiang, YuX" , Chas Williams , "Min Hu (Connor)" , "Burakov, Anatoly" , stable@dpdk.org, Andrew Rybchenko Subject: [PATCH] net/bonding: fix device configure reentrancy Date: Tue, 1 Nov 2022 19:18:53 +0300 Message-Id: <20221101161853.2702425-1-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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 --- 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