Skip to contentSkip to conversation

net/bonding: check return value in bond_ethdev_configure

PATCH In review Lee Daly 2 participants 4 messages Nov 16, 2018

Subsystems (2)
lore
Share & tools
lore

Lee Daly

author
#0 lore raw

PATCH 1/1 net/bonding: check return value in bond_ethdev_configure

This patch checks the return value of function rte_eth_bond_8023ad_agg_selection_set() in bond_ethdev_configure for error return value.

---
 drivers/net/bonding/rte_eth_bond_pmd.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +8 -3
index 156f31c..a7612ae 100644
@@ -3420,9 +3420,14 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				     "Failed to parse agg selection mode for bonded device %s",
 				     name);
 		}
-		if (internals->mode == BONDING_MODE_8023AD)
-			rte_eth_bond_8023ad_agg_selection_set(port_id,
-							      agg_mode);
+		if (internals->mode == BONDING_MODE_8023AD) {
+			if (rte_eth_bond_8023ad_agg_selection_set(port_id,
+							      agg_mode) < 0) {
+				RTE_BOND_LOG(ERR, "Invalid args for agg selection"
+					     " set for bonded device %s", name);
+				return -1;
+			}
+		}
 	}
 
 	/* Parse/add slave ports to bonded device */
Signature · 1 line
2.7.4
#1 lore raw
Quoted 3 lines · Lee Daly

This patch checks the return value of function rte_eth_bond_8023ad_agg_selection_set() in bond_ethdev_configure for error return value.

Thanks Lee, just a few minor syntax comment below.

Quoted 11 lines
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +0 -0
index 156f31c..a7612ae 100644

drivers/net/bonding/rte_eth_bond_pmd.c bond_ethdev_configure(struct rte_eth_dev *dev) · line 3425

Quoted 9 lines
drivers/net/bonding/rte_eth_bond_pmd.c +3 -3
@@ -3420,9 +3420,14 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				     "Failed to parse agg selection mode for bonded device %s",
 				     name);
 		}
-		if (internals->mode == BONDING_MODE_8023AD)
-			rte_eth_bond_8023ad_agg_selection_set(port_id,
-							      agg_mode);
+		if (internals->mode == BONDING_MODE_8023AD) {
+			if (rte_eth_bond_8023ad_agg_selection_set(port_id,
+							      agg_mode) < 0) {

It it clear if you extract the function out of if() and check return type in if()

drivers/net/bonding/rte_eth_bond_pmd.c bond_ethdev_configure(struct rte_eth_dev *dev) · line 3427

Quoted 2 lines
drivers/net/bonding/rte_eth_bond_pmd.c +2 -0
+				RTE_BOND_LOG(ERR, "Invalid args for agg selection"
+					     " set for bonded device %s", name);

You can merge the error msg, it is accepted to go beyond 80 chars for msgs.

Quoted 7 lines
drivers/net/bonding/rte_eth_bond_pmd.c +3 -0
+				return -1;
+			}
+		}
 	}
 
 	/* Parse/add slave ports to bonded device */
author
#2 lore raw

PATCH v2 1/1 net/bonding: fix possible silent failure in configuration

In reply to Lee Daly

This patch checks the return value of function rte_eth_bond_8023ad_agg_selection_set() in bond_ethdev_configure for error return value.

Fixes 6d72657ce379 ("net/bonding: add other aggregator modes")

V2:
syntax changes.
commit message update.

---
 drivers/net/bonding/rte_eth_bond_pmd.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +10 -3
index 156f31c..953cee5 100644
@@ -3420,9 +3420,16 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
 				     "Failed to parse agg selection mode for bonded device %s",
 				     name);
 		}
-		if (internals->mode == BONDING_MODE_8023AD)
-			rte_eth_bond_8023ad_agg_selection_set(port_id,
-							      agg_mode);
+		if (internals->mode == BONDING_MODE_8023AD) {
+			int ret = rte_eth_bond_8023ad_agg_selection_set(port_id,
+					agg_mode);
+			if (ret < 0) {
+				RTE_BOND_LOG(ERR,
+					"Invalid args for agg selection set for bonded device %s",
+					name);
+				return -1;
+			}
+		}
 	}
 
 	/* Parse/add slave ports to bonded device */
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1 Applied
#3 lore raw

Re: [dpdk-stable] [PATCH v2] net/bonding: fix possible silent failure in configuration

Quoted 4 lines · Lee Daly

This patch checks the return value of function rte_eth_bond_8023ad_agg_selection_set() in bond_ethdev_configure for error return value.

Quoted 8 lines
Fixes 6d72657ce379 ("net/bonding: add other aggregator modes")

V2:
syntax changes.
commit message update.

Applied to dpdk-next-net/master, thanks.