Skip to content

Commit

Permalink
net/bonding: fix port id validity check on parsing
Browse files Browse the repository at this point in the history
[ upstream commit 44cd624 ]

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: 2efb58c ("bond: new link bonding library")

Signed-off-by: Gaetan Rivet <grive@u256.net>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
  • Loading branch information
Gaetan Rivet authored and bluca committed Feb 2, 2021
1 parent 81a66f3 commit 64fdf34
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/net/bonding/rte_eth_bond_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 64fdf34

Please sign in to comment.