summaryrefslogtreecommitdiff
path: root/examples/ptpclient
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/ptpclient
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/ptpclient')
-rw-r--r--examples/ptpclient/ptpclient.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index ad98a39..55be3f7 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -187,7 +187,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
uint16_t nb_rxd = RX_RING_SIZE;
uint16_t nb_txd = TX_RING_SIZE;
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
rte_eth_dev_info_get(port, &dev_info);