fix ethdev port id validation
[dpdk.git] / examples / l3fwd-power / main.c
index 16f4d09..d6a0926 100644 (file)
@@ -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();