From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id ECC9C2BBB; Thu, 1 Feb 2018 19:51:18 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 10:51:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,444,1511856000"; d="scan'208";a="14332869" Received: from unknown (HELO localhost.localdomain) ([10.224.122.203]) by orsmga007.jf.intel.com with ESMTP; 01 Feb 2018 10:51:15 -0800 From: Vipin Varghese To: dev@dpdk.org Cc: stable@dpdk.org, pablo.de.lara.guarch@intel.com, bruce.richardson@intel.com, Vipin Varghese Date: Fri, 2 Feb 2018 00:21:21 +0530 Message-Id: <1517511081-16289-1-git-send-email-vipin.varghese@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] examples/l2fwd: check if user portmask is valid X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2018 18:51:21 -0000 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