net/bonding: check return value when enable/disable promisc mode

Message ID 20241220070811.40124-1-sunyang.wu@jaguarmicro.com (mailing list archive)
State Accepted, archived
Delegated to: Stephen Hemminger
Headers
Series net/bonding: check return value when enable/disable promisc mode |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS

Commit Message

Sunyang Wu Dec. 20, 2024, 7:08 a.m. UTC
Add validation for the return value of rte_eth_promiscuous_enable
and rte_eth_promiscuous_disable.

Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 91bf2c2345..f69496feec 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2783,6 +2783,7 @@  bond_ethdev_promiscuous_update(struct rte_eth_dev *dev)
 {
 	struct bond_dev_private *internals = dev->data->dev_private;
 	uint16_t port_id = internals->current_primary_port;
+	int ret;
 
 	switch (internals->mode) {
 	case BONDING_MODE_ROUND_ROBIN:
@@ -2802,10 +2803,19 @@  bond_ethdev_promiscuous_update(struct rte_eth_dev *dev)
 		 * mode should be set to new primary member according to bonding
 		 * device.
 		 */
-		if (rte_eth_promiscuous_get(internals->port_id) == 1)
-			rte_eth_promiscuous_enable(port_id);
-		else
-			rte_eth_promiscuous_disable(port_id);
+		if (rte_eth_promiscuous_get(internals->port_id) == 1) {
+			ret = rte_eth_promiscuous_enable(port_id);
+			if (ret != 0)
+				RTE_BOND_LOG(ERR,
+					     "Failed to enable promiscuous mode for port %u: %s",
+					     port_id, rte_strerror(-ret));
+		} else {
+			ret = rte_eth_promiscuous_disable(port_id);
+			if (ret != 0)
+				RTE_BOND_LOG(ERR,
+					     "Failed to disable promiscuous mode for port %u: %s",
+					     port_id, rte_strerror(-ret));
+		}
 	}
 
 	return 0;