From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AE0E3A04C7; Mon, 14 Sep 2020 18:13:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 60AA0E07; Mon, 14 Sep 2020 18:13:25 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 752B9160 for ; Mon, 14 Sep 2020 18:13:23 +0200 (CEST) IronPort-SDR: E9Kyn6nHc+5+ZltYID6ivUob7ryMBcSzm5V/qy4wZ+ODzLCnvQt6X+3Y06eyppdgnioBUeva8N QoO2Fh8jK+Aw== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="138610501" X-IronPort-AV: E=Sophos;i="5.76,426,1592895600"; d="scan'208";a="138610501" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 09:13:20 -0700 IronPort-SDR: k92Mjg5tK1qEkAblnMk2M1q8d3ZWg1qemgQou9hhSD4P0m+Rk7OnXpe2qf34g8q/l/Oa4T6Te1 Dq3L+L3sCfRw== X-IronPort-AV: E=Sophos;i="5.76,426,1592895600"; d="scan'208";a="507193756" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.247.225]) ([10.213.247.225]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 09:13:17 -0700 To: "Wei Hu (Xavier)" , Wenzhuo Lu , Beilei Xing , Bernard Iremonger , Shahaf Shuler Cc: dev@dpdk.org, xavier.huwei@huawei.com References: <20200818120254.72792-1-huwei013@chinasoftinc.com> <20200820014204.25035-1-huwei013@chinasoftinc.com> <20200820014204.25035-2-huwei013@chinasoftinc.com> From: Ferruh Yigit Message-ID: <2888c27b-f6b6-589c-7338-843661ae90c1@intel.com> Date: Mon, 14 Sep 2020 17:13:12 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: <20200820014204.25035-2-huwei013@chinasoftinc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 1/4] app/testpmd: fix missing verification of port id 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" On 8/20/2020 2:42 AM, Wei Hu (Xavier) wrote: > From: Chengchang Tang > > To set Tx vlan offloads, it is required to stop port firstly. But before > checking whether the port is stopped, the port id entered by the user > is not checked for validity. When the port id is illegal, it would lead > to a segmentation fault since it attempts to access a member of > non-existent port. > > This patch adds verification of port id in tx vlan offloads. > > Fixes: 597f9fafe13b ("app/testpmd: convert to new Tx offloads API") > Cc: stable@dpdk.org > > Signed-off-by: Chengchang Tang > Signed-off-by: Wei Hu (Xavier) > --- > app/test-pmd/cmdline.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index 0a6ed85f3..8377f8401 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -4268,6 +4268,9 @@ cmd_tx_vlan_set_parsed(void *parsed_result, > { > struct cmd_tx_vlan_set_result *res = parsed_result; > > + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) > + return; > + > if (!port_is_stopped(res->port_id)) { > printf("Please stop port %d first\n", res->port_id); > return; These functions are wrappers to some testpmd functions, and those functions already have invalid port check, like 'tx_vlan_set()' Agree that check should be in these functions, but to prevent the duplicated checks, what do you think to remove checks from internal functions? ('tx_vlan_set', 'tx_qinq_set' & 'tx_vlan_reset').