summaryrefslogtreecommitdiff
path: root/examples/l3fwd-vf
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2018-04-05 17:33:21 +0200
committerThomas Monjalon <thomas@monjalon.net>2018-04-18 00:37:05 +0200
commita9dbe180222680edf8c49e86791f972549ce5be3 (patch)
tree24de43bfe7364653ede899a7e2a391a1c7bd65b9 /examples/l3fwd-vf
parent8728ccf37615904cf23fb8763895b05c9a3c6b0c (diff)
downloaddpdk-a9dbe180222680edf8c49e86791f972549ce5be3.zip
dpdk-a9dbe180222680edf8c49e86791f972549ce5be3.tar.gz
dpdk-a9dbe180222680edf8c49e86791f972549ce5be3.tar.xz
fix ethdev port id validation
Some DPDK applications wrongly assume these requirements: - no hotplug, i.e. ports are never detached - all allocated ports are available to the application Such application assume a valid port index is in the range [0..count[. There are three consequences when using such wrong design: - new ports having an index higher than the port count won't be valid - old ports being detached (RTE_ETH_DEV_UNUSED) can be valid Such mistake will be less common with growing hotplug awareness. All applications and examples inside this repository - except testpmd - must be fixed to use the function rte_eth_dev_is_valid_port. Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Diffstat (limited to 'examples/l3fwd-vf')
-rw-r--r--examples/l3fwd-vf/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c
index 7a9927c..dd0e057 100644
--- a/examples/l3fwd-vf/main.c
+++ b/examples/l3fwd-vf/main.c
@@ -575,7 +575,7 @@ check_lcore_params(void)
}
static int
-check_port_config(const unsigned nb_ports)
+check_port_config(void)
{
unsigned portid;
uint16_t i;
@@ -586,7 +586,7 @@ check_port_config(const unsigned nb_ports)
printf("port %u is not enabled in port mask\n", portid);
return -1;
}
- if (portid >= nb_ports) {
+ if (!rte_eth_dev_is_valid_port(portid)) {
printf("port %u is not present on the board\n", portid);
return -1;
}
@@ -951,7 +951,7 @@ main(int argc, char **argv)
nb_ports = rte_eth_dev_count();
- if (check_port_config(nb_ports) < 0)
+ if (check_port_config() < 0)
rte_exit(EXIT_FAILURE, "check_port_config failed\n");
nb_lcores = rte_lcore_count();