summaryrefslogtreecommitdiff
path: root/examples
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
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')
-rw-r--r--examples/bbdev_app/main.c10
-rw-r--r--examples/bond/main.c2
-rw-r--r--examples/distributor/main.c2
-rw-r--r--examples/eventdev_pipeline/main.c2
-rw-r--r--examples/flow_classify/flow_classify.c2
-rw-r--r--examples/ip_pipeline/kni.c4
-rw-r--r--examples/ipsec-secgw/ipsec-secgw.c6
-rw-r--r--examples/kni/main.c8
-rw-r--r--examples/l2fwd-cat/l2fwd-cat.c2
-rw-r--r--examples/l3fwd-acl/main.c6
-rw-r--r--examples/l3fwd-power/main.c6
-rw-r--r--examples/l3fwd-vf/main.c6
-rw-r--r--examples/l3fwd/main.c6
-rw-r--r--examples/multi_process/symmetric_mp/main.c2
-rw-r--r--examples/packet_ordering/main.c3
-rw-r--r--examples/performance-thread/l3fwd-thread/main.c6
-rw-r--r--examples/ptpclient/ptpclient.c2
-rw-r--r--examples/rxtx_callbacks/main.c2
-rw-r--r--examples/skeleton/basicfwd.c2
-rw-r--r--examples/tep_termination/main.c7
-rw-r--r--examples/tep_termination/vxlan_setup.c2
-rw-r--r--examples/vhost/main.c10
-rw-r--r--examples/vm_power_manager/main.c2
-rw-r--r--examples/vmdq/main.c8
-rw-r--r--examples/vmdq_dcb/main.c8
25 files changed, 56 insertions, 60 deletions
diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 3c45256..254cc06 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -1017,7 +1017,7 @@ int
main(int argc, char **argv)
{
int ret;
- unsigned int nb_bbdevs, nb_ports, flags, lcore_id;
+ unsigned int nb_bbdevs, flags, lcore_id;
void *sigret;
struct app_config_params app_params = def_app_config;
struct rte_mempool *ethdev_mbuf_mempool, *bbdev_mbuf_mempool;
@@ -1079,12 +1079,10 @@ main(int argc, char **argv)
nb_bbdevs, app_params.bbdev_id);
printf("Number of bbdevs detected: %d\n", nb_bbdevs);
- /* Get the number of available ethdev devices */
- nb_ports = rte_eth_dev_count();
- if (nb_ports <= app_params.port_id)
+ if (!rte_eth_dev_is_valid_port(app_params.port_id))
rte_exit(EXIT_FAILURE,
- "%u ports detected, cannot use port with ID %u!\n",
- nb_ports, app_params.port_id);
+ "cannot use port with ID %u!\n",
+ app_params.port_id);
/* create the mbuf mempool for ethdev pkts */
ethdev_mbuf_mempool = rte_pktmbuf_pool_create("ethdev_mbuf_pool",
diff --git a/examples/bond/main.c b/examples/bond/main.c
index d68162f..d4097d0 100644
--- a/examples/bond/main.c
+++ b/examples/bond/main.c
@@ -147,7 +147,7 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool)
struct rte_eth_txconf txq_conf;
struct rte_eth_conf local_port_conf = port_conf;
- if (portid >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(portid))
rte_exit(EXIT_FAILURE, "Invalid port\n");
rte_eth_dev_info_get(portid, &dev_info);
diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 62831a0..2e6b09d 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -116,7 +116,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
struct rte_eth_dev_info dev_info;
struct rte_eth_txconf txconf;
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
rte_eth_dev_info_get(port, &dev_info);
diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c
index bbab995..48358a7 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -285,7 +285,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
struct rte_eth_dev_info dev_info;
struct rte_eth_txconf txconf;
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
rte_eth_dev_info_get(port, &dev_info);
diff --git a/examples/flow_classify/flow_classify.c b/examples/flow_classify/flow_classify.c
index a65ef20..d0e537e 100644
--- a/examples/flow_classify/flow_classify.c
+++ b/examples/flow_classify/flow_classify.c
@@ -200,7 +200,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
struct rte_eth_dev_info dev_info;
struct rte_eth_txconf txconf;
- if (port >= rte_eth_dev_count())
+ if (rte_eth_dev_is_valid_port(port))
return -1;
rte_eth_dev_info_get(port, &dev_info);
diff --git a/examples/ip_pipeline/kni.c b/examples/ip_pipeline/kni.c
index 7127753..ed5f894 100644
--- a/examples/ip_pipeline/kni.c
+++ b/examples/ip_pipeline/kni.c
@@ -67,7 +67,7 @@ kni_config_network_interface(uint16_t port_id, uint8_t if_up)
{
int ret = 0;
- if (port_id >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port_id))
return -EINVAL;
ret = (if_up) ?
@@ -82,7 +82,7 @@ kni_change_mtu(uint16_t port_id, unsigned int new_mtu)
{
int ret;
- if (port_id >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port_id))
return -EINVAL;
if (new_mtu > ETHER_MAX_LEN)
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 3001d62..6bbb920 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -848,7 +848,7 @@ static int32_t
check_params(void)
{
uint8_t lcore;
- uint16_t portid, nb_ports;
+ uint16_t portid;
uint16_t i;
int32_t socket_id;
@@ -857,8 +857,6 @@ check_params(void)
return -1;
}
- nb_ports = rte_eth_dev_count();
-
for (i = 0; i < nb_lcore_params; ++i) {
lcore = lcore_params[i].lcore_id;
if (!rte_lcore_is_enabled(lcore)) {
@@ -877,7 +875,7 @@ check_params(void)
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;
}
diff --git a/examples/kni/main.c b/examples/kni/main.c
index d944bae..901480a 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -689,7 +689,7 @@ kni_change_mtu(uint16_t port_id, unsigned int new_mtu)
struct rte_eth_dev_info dev_info;
struct rte_eth_rxconf rxq_conf;
- if (port_id >= rte_eth_dev_count()) {
+ if (!rte_eth_dev_is_valid_port(port_id)) {
RTE_LOG(ERR, APP, "Invalid port id %d\n", port_id);
return -EINVAL;
}
@@ -748,7 +748,7 @@ kni_config_network_interface(uint16_t port_id, uint8_t if_up)
{
int ret = 0;
- if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) {
+ if (!rte_eth_dev_is_valid_port(port_id)) {
RTE_LOG(ERR, APP, "Invalid port id %d\n", port_id);
return -EINVAL;
}
@@ -782,7 +782,7 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
{
int ret = 0;
- if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) {
+ if (!rte_eth_dev_is_valid_port(port_id)) {
RTE_LOG(ERR, APP, "Invalid port id %d\n", port_id);
return -EINVAL;
}
@@ -932,7 +932,7 @@ main(int argc, char** argv)
/* Check if the configured port ID is valid */
for (i = 0; i < RTE_MAX_ETHPORTS; i++)
- if (kni_port_params_array[i] && i >= nb_sys_ports)
+ if (kni_port_params_array[i] && !rte_eth_dev_is_valid_port(i))
rte_exit(EXIT_FAILURE, "Configured invalid "
"port ID %u\n", i);
diff --git a/examples/l2fwd-cat/l2fwd-cat.c b/examples/l2fwd-cat/l2fwd-cat.c
index 3442928..ed48780 100644
--- a/examples/l2fwd-cat/l2fwd-cat.c
+++ b/examples/l2fwd-cat/l2fwd-cat.c
@@ -39,7 +39,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;
/* Configure the Ethernet device. */
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 3c547cd..2c891b4 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -1452,7 +1452,7 @@ check_lcore_params(void)
}
static int
-check_port_config(const unsigned nb_ports)
+check_port_config(void)
{
unsigned portid;
uint16_t i;
@@ -1464,7 +1464,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;
}
@@ -1893,7 +1893,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");
/* Add ACL rules and route entries, build trie */
diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 16f4d09..d6a0926 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -1056,7 +1056,7 @@ check_lcore_params(void)
}
static int
-check_port_config(const unsigned nb_ports)
+check_port_config(void)
{
unsigned portid;
uint16_t i;
@@ -1068,7 +1068,7 @@ check_port_config(const unsigned nb_ports)
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;
@@ -1652,7 +1652,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();
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();
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 8f7961c..ec1da5c 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -210,7 +210,7 @@ check_lcore_params(void)
}
static int
-check_port_config(const unsigned nb_ports)
+check_port_config(void)
{
uint16_t portid;
uint16_t i;
@@ -221,7 +221,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;
}
@@ -828,7 +828,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();
diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c
index 2fbf088..75cad0c 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -204,7 +204,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
if (rte_eal_process_type() == RTE_PROC_SECONDARY)
return 0;
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
printf("# Initialising port %u... ", port);
diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c
index 964e23c..676cb6f 100644
--- a/examples/packet_ordering/main.c
+++ b/examples/packet_ordering/main.c
@@ -261,7 +261,6 @@ configure_eth_port(uint16_t port_id)
{
struct ether_addr addr;
const uint16_t rxRings = 1, txRings = 1;
- const uint8_t nb_ports = rte_eth_dev_count();
int ret;
uint16_t q;
uint16_t nb_rxd = RX_DESC_PER_QUEUE;
@@ -270,7 +269,7 @@ configure_eth_port(uint16_t port_id)
struct rte_eth_txconf txconf;
struct rte_eth_conf port_conf = port_conf_default;
- if (port_id > nb_ports)
+ if (!rte_eth_dev_is_valid_port(port_id))
return -1;
rte_eth_dev_info_get(port_id, &dev_info);
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index 4fafed1..699b99d 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -2491,7 +2491,7 @@ check_lcore_params(void)
}
static int
-check_port_config(const unsigned nb_ports)
+check_port_config(void)
{
unsigned portid;
uint16_t i;
@@ -2502,7 +2502,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;
}
@@ -3516,7 +3516,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();
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);
diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c
index 46dacc7..84b09cf 100644
--- a/examples/rxtx_callbacks/main.c
+++ b/examples/rxtx_callbacks/main.c
@@ -80,7 +80,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
struct rte_eth_dev_info dev_info;
struct rte_eth_txconf txconf;
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
rte_eth_dev_info_get(port, &dev_info);
diff --git a/examples/skeleton/basicfwd.c b/examples/skeleton/basicfwd.c
index 11a9b57..5ac1dc8 100644
--- a/examples/skeleton/basicfwd.c
+++ b/examples/skeleton/basicfwd.c
@@ -42,7 +42,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
struct rte_eth_dev_info dev_info;
struct rte_eth_txconf txconf;
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
rte_eth_dev_info_get(port, &dev_info);
diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index cc12cd8..e868541 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -515,11 +515,10 @@ check_ports_num(unsigned max_nb_ports)
}
for (portid = 0; portid < nb_ports; portid++) {
- if (ports[portid] >= max_nb_ports) {
+ if (!rte_eth_dev_is_valid_port(ports[portid])) {
RTE_LOG(INFO, VHOST_PORT,
- "\nSpecified port ID(%u) exceeds max "
- " system port ID(%u)\n",
- ports[portid], (max_nb_ports - 1));
+ "\nSpecified port ID(%u) is not valid\n",
+ ports[portid]);
ports[portid] = INVALID_PORT_ID;
valid_nb_ports--;
}
diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c
index ba7d92a..299c29d 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -133,7 +133,7 @@ vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool)
txconf = &dev_info.default_txconf;
txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
rx_rings = nb_devices;
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 0b5221f..7cddac7 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -294,7 +294,8 @@ port_init(uint16_t port)
printf("pf queue num: %u, configured vmdq pool num: %u, each vmdq pool has %u queues\n",
num_pf_queues, num_devices, queues_per_pool);
- if (port >= rte_eth_dev_count()) return -1;
+ if (!rte_eth_dev_is_valid_port(port))
+ return -1;
rx_rings = (uint16_t)dev_info.max_rx_queues;
if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
@@ -667,9 +668,10 @@ static unsigned check_ports_num(unsigned nb_ports)
}
for (portid = 0; portid < num_ports; portid ++) {
- if (ports[portid] >= nb_ports) {
- RTE_LOG(INFO, VHOST_PORT, "\nSpecified port ID(%u) exceeds max system port ID(%u)\n",
- ports[portid], (nb_ports - 1));
+ if (!rte_eth_dev_is_valid_port(ports[portid])) {
+ RTE_LOG(INFO, VHOST_PORT,
+ "\nSpecified port ID(%u) is not valid\n",
+ ports[portid]);
ports[portid] = INVALID_PORT_ID;
valid_num_ports--;
}
diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c
index 4cde828..db0ddb0 100644
--- a/examples/vm_power_manager/main.c
+++ b/examples/vm_power_manager/main.c
@@ -61,7 +61,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
struct rte_eth_dev_info dev_info;
struct rte_eth_txconf txq_conf;
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
rte_eth_dev_info_get(port, &dev_info);
diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c
index 7284524..2f3eb74 100644
--- a/examples/vmdq/main.c
+++ b/examples/vmdq/main.c
@@ -201,7 +201,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
num_pf_queues, num_pools, queues_per_pool);
printf("vmdq queue base: %d pool base %d\n",
vmdq_queue_base, vmdq_pool_base);
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
/*
@@ -539,9 +539,9 @@ static unsigned check_ports_num(unsigned nb_ports)
}
for (portid = 0; portid < num_ports; portid++) {
- if (ports[portid] >= nb_ports) {
- printf("\nSpecified port ID(%u) exceeds max system port ID(%u)\n",
- ports[portid], (nb_ports - 1));
+ if (!rte_eth_dev_is_valid_port(ports[portid])) {
+ printf("\nSpecified port ID(%u) is not valid\n",
+ ports[portid]);
ports[portid] = INVALID_PORT_ID;
valid_num_ports--;
}
diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index 2016a95..9c68ab0 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -246,7 +246,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
num_pools, queues_per_pool);
}
- if (port >= rte_eth_dev_count())
+ if (!rte_eth_dev_is_valid_port(port))
return -1;
retval = get_eth_conf(&port_conf);
@@ -599,9 +599,9 @@ static unsigned check_ports_num(unsigned nb_ports)
}
for (portid = 0; portid < num_ports; portid++) {
- if (ports[portid] >= nb_ports) {
- printf("\nSpecified port ID(%u) exceeds max system port ID(%u)\n",
- ports[portid], (nb_ports - 1));
+ if (!rte_eth_dev_is_valid_port(ports[portid])) {
+ printf("\nSpecified port ID(%u) is not valid\n",
+ ports[portid]);
ports[portid] = INVALID_PORT_ID;
valid_num_ports--;
}