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 A381BA04C8; Sat, 19 Sep 2020 12:47:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E86CD1C232; Sat, 19 Sep 2020 12:47:32 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id 8045D1C1FE for ; Sat, 19 Sep 2020 12:47:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=IdFGpcfdk4MhdHpENQ 0qN4CbRt70pmakc+QhfJPW/bo=; b=nw5j4Yzmc4ZuA8AM4Gv5gzuQrK/j/c1e+L qmJ0tR6xZ61PiN/R8GVuFB3NvWwZCoTBhDKpjsI2YWJ92tLZ1R5oNjpM1irpatVA SGl3hxPWYLn5RX+x3McNoEyssp0L0ft+o9F0GrEYLQWNQE4fiGPOCgWOuFd4dbt7 0quL1xbi8= Received: from localhost.localdomain (unknown [65.49.108.226]) by smtp9 (Coremail) with SMTP id DcCowAB3fIit4WVfEoCpHA--.12337S3; Sat, 19 Sep 2020 18:47:24 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org Cc: xavier.huwei@huawei.com Date: Sat, 19 Sep 2020 18:47:03 +0800 Message-Id: <20200919104708.58451-2-xavier_huwei@163.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200919104708.58451-1-xavier_huwei@163.com> References: <20200818120254.72792-1-huwei013@chinasoftinc.com> <20200919104708.58451-1-xavier_huwei@163.com> X-CM-TRANSID: DcCowAB3fIit4WVfEoCpHA--.12337S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxWw15Kr48Ar1UZw47ZFyDtrb_yoW5AFy8pF 4DJFyIk3yDGFs3ur47AayF9r45Gr93Xa10qrZ7Zr1Yy3W5KFn7Jr40gwnIqr4fWry09ryS 9Fnxua4qyF1DXaDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UKJmUUUUUU= X-Originating-IP: [65.49.108.226] X-CM-SenderInfo: 50dyxv5ubk34lhl6il2tof0z/xtbBZxqko1et0OWcjQABsl Subject: [dpdk-dev] [PATCH v3 1/6] 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" 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.9.5