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 8BBC2A04C8 for ; Sat, 19 Sep 2020 09:40:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7B58F1D98F; Sat, 19 Sep 2020 09:40:03 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id D8B6A1D98A for ; Sat, 19 Sep 2020 09:40:00 +0200 (CEST) Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E20216FDBD871474F296; Sat, 19 Sep 2020 15:39:58 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Sat, 19 Sep 2020 15:39:50 +0800 From: "Min Hu (Connor)" To: CC: , Chengchang Tang , , Wei Hu Date: Sat, 19 Sep 2020 15:37:09 +0800 Message-ID: <1600501034-50042-2-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600501034-50042-1-git-send-email-humin29@huawei.com> References: <1600501034-50042-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-stable] [PATCH v3 1/6] app/testpmd: fix missing verification of port id X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 and remove duplicated check. 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) --- v1 -> v2: remove the duplicated check. --- app/test-pmd/cmdline.c | 9 +++++++++ app/test-pmd/config.c | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 5f93409..43b7c2f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -4291,6 +4291,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; @@ -4345,6 +4348,9 @@ cmd_tx_vlan_set_qinq_parsed(void *parsed_result, { struct cmd_tx_vlan_set_qinq_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; @@ -4458,6 +4464,9 @@ cmd_tx_vlan_reset_parsed(void *parsed_result, { struct cmd_tx_vlan_reset_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; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b6eb2a5..2bdec25 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3545,8 +3545,6 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id) struct rte_eth_dev_info dev_info; int ret; - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return; if (vlan_id_is_invalid(vlan_id)) return; @@ -3577,8 +3575,6 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer) struct rte_eth_dev_info dev_info; int ret; - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return; if (vlan_id_is_invalid(vlan_id)) return; if (vlan_id_is_invalid(vlan_id_outer)) @@ -3604,8 +3600,6 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer) void tx_vlan_reset(portid_t port_id) { - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return; ports[port_id].dev_conf.txmode.offloads &= ~(DEV_TX_OFFLOAD_VLAN_INSERT | DEV_TX_OFFLOAD_QINQ_INSERT); -- 2.7.4