From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vipin Varghese Subject: [PATCH] examples/l2fwd: check if user portmask is valid Date: Fri, 2 Feb 2018 00:21:21 +0530 Message-ID: <1517511081-16289-1-git-send-email-vipin.varghese@intel.com> Cc: stable@dpdk.org, pablo.de.lara.guarch@intel.com, bruce.richardson@intel.com, Vipin Varghese To: dev@dpdk.org Return-path: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" User can pass portmask with any value, even invalid mask. The code checks against actual portmask. Signed-off-by: Vipin Varghese --- examples/l2fwd/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 6c07ed4..1c02c1b 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -549,6 +549,11 @@ enum { if (nb_ports == 0) rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); + /* icheck 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; -- 1.9.1