From: Vipin Varghese Date: Thu, 1 Feb 2018 18:58:42 +0000 (+0530) Subject: examples/l2fwd: check if user portmask is valid X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6726521997fcb35cd1ad5a7ec806772c9f6f39c8;p=dpdk.git examples/l2fwd: check if user portmask is valid User can pass portmask with any value, even invalid mask. The code checks against actual portmask. Signed-off-by: Vipin Varghese Acked-by: Pablo de Lara --- diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 6c07ed43e1..e4a4a7c36c 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -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;