examples/ip_frag: check for non-existent ports
authorAnatoly Burakov <anatoly.burakov@intel.com>
Wed, 18 Jun 2014 14:50:35 +0000 (15:50 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 26 Jun 2014 20:51:51 +0000 (22:51 +0200)
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
examples/ip_fragmentation/main.c
examples/ip_reassembly/main.c

index 02e40a1..ac57555 100644 (file)
@@ -886,6 +886,10 @@ MAIN(int argc, char **argv)
        if (init_mem() < 0)
                rte_panic("Cannot initialize memory structures!\n");
 
+       /* check if portmask has non-existent ports */
+       if (enabled_port_mask & ~(RTE_LEN2MASK(nb_ports, unsigned)))
+               rte_exit(EXIT_FAILURE, "Non-existent ports in portmask!\n");
+
        /* initialize all ports */
        for (portid = 0; portid < nb_ports; portid++) {
                /* skip ports that are not enabled */
index 7311b29..d612c31 100644 (file)
@@ -1093,6 +1093,10 @@ MAIN(int argc, char **argv)
        if (init_mem() < 0)
                rte_panic("Cannot initialize memory structures!\n");
 
+       /* check if portmask has non-existent ports */
+       if (enabled_port_mask & ~(RTE_LEN2MASK(nb_ports, unsigned)))
+               rte_exit(EXIT_FAILURE, "Non-existent ports in portmask!\n");
+
        /* initialize all ports */
        for (portid = 0; portid < nb_ports; portid++) {
                /* skip ports that are not enabled */