From patchwork Thu Feb 1 18:58:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Varghese, Vipin" X-Patchwork-Id: 34857 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 18D0E2F42; Thu, 1 Feb 2018 19:58:42 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 9AD612C2E; Thu, 1 Feb 2018 19:58:39 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 10:58:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,444,1511856000"; d="scan'208";a="170953538" Received: from unknown (HELO localhost.localdomain) ([10.224.122.203]) by orsmga004.jf.intel.com with ESMTP; 01 Feb 2018 10:58:36 -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:28:42 +0530 Message-Id: <1517511522-16486-1-git-send-email-vipin.varghese@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1517511081-16289-1-git-send-email-vipin.varghese@intel.com> References: <1517511081-16289-1-git-send-email-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v2] 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: , 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 Acked-by: Pablo de Lara --- V2 Changes: - correct the spelling in comment - Vipin --- examples/l2fwd/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 6c07ed4..e4a4a7c 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"); + /* 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;