From: Gaetan Rivet Date: Fri, 17 Apr 2020 16:42:06 +0000 (+0200) Subject: net/bonding: fix port id validity check on parsing X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=44cd624a4b8c626fb5444199c06b5e05675c3cc1;p=dpdk.git net/bonding: fix port id validity check on parsing 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 Signed-off-by: Gaetan Rivet Acked-by: Min Hu (Connor) --- diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c index abdf552610..35616fb8bc 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;