[v1,1/2] bonding: fix port id validity check on parsing

Message ID 0d0871d076871a3c7d9ea0d2dc479a725151f8c0.1587137703.git.grive@u256.net (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series bonding: fix port id check and PCI addr cmp |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance fail Performance Testing issues
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues
ci/Intel-compilation fail Compilation issues

Commit Message

Gaëtan Rivet April 17, 2020, 4:42 p.m. UTC
  If the port_id is equal to RTE_MAX_ETHPORTS, it should be considered
invalid. Additionally, UNUSED ports are also not valid port ids to be
used afterward.

To simplify following the ethdev API rules, use the exposed function
checking whether a port id is valid.

Fixes: 2efb58cbab6e ("bond: new link bonding library")
Cc: stable@dpdk.org

Cc: Chas Williams <chas3@att.com>
Signed-off-by: Gaetan Rivet <grive@u256.net>
---
 drivers/net/bonding/rte_eth_bond_args.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
  

Comments

humin (Q) Nov. 26, 2020, 2:45 a.m. UTC | #1
It looks good to me, thanks.
  
Ferruh Yigit Dec. 7, 2020, 1:34 p.m. UTC | #2
On 11/26/2020 2:45 AM, Min Hu (Connor) wrote:
> It looks good to me, thanks.
> 

Converting it to an explicit ack:
Acked-by: Min Hu (Connor) <humin29@huawei.com>

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

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index abdf55261..35616fb8b 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -108,9 +108,8 @@  parse_port_id(const char *port_str)
 		}
 	}
 
-	if (port_id < 0 || port_id > RTE_MAX_ETHPORTS) {
-		RTE_BOND_LOG(ERR, "Slave port specified (%s) outside expected range",
-				port_str);
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		RTE_BOND_LOG(ERR, "Specified port (%s) is invalid", port_str);
 		return -1;
 	}
 	return port_id;