]> git.droids-corp.org - dpdk.git/commitdiff
examples/l2fwd: check if user portmask is valid
authorVipin Varghese <vipin.varghese@intel.com>
Thu, 1 Feb 2018 18:58:42 +0000 (00:28 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 6 Feb 2018 17:52:52 +0000 (18:52 +0100)
User can pass portmask with any value, even invalid mask. The code
checks against actual portmask.

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
examples/l2fwd/main.c

index 6c07ed43e1030988958a5825efabc1850a3133f3..e4a4a7c36c5df2428c6e735ea97e2e81e6825c29 100644 (file)
@@ -549,6 +549,11 @@ main(int argc, char **argv)
        if (nb_ports == 0)
                rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
+       /* check port mask to possible port mask */
+       if (l2fwd_enabled_port_mask & ~((1 << nb_ports) - 1))
+               rte_exit(EXIT_FAILURE, "Invalid portmask; possible (0x%x)\n",
+                       (1 << nb_ports) - 1);
+
        /* reset l2fwd_dst_ports */
        for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
                l2fwd_dst_ports[portid] = 0;