patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <xavier.huwei@foxmail.com>
Cc: <forest.zhouchang@huawei.com>,
	Chengchang Tang <tangchengchang@huawei.com>, <stable@dpdk.org>,
	Wei Hu <xavier.huwei@huawei.com>
Subject: [dpdk-stable] [PATCH v3 1/6] app/testpmd: fix missing verification of port id
Date: Sat, 19 Sep 2020 15:37:09 +0800	[thread overview]
Message-ID: <1600501034-50042-2-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1600501034-50042-1-git-send-email-humin29@huawei.com>

From: Chengchang Tang <tangchengchang@huawei.com>

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 <tangchengchang@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
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


       reply	other threads:[~2020-09-19  7:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1600501034-50042-1-git-send-email-humin29@huawei.com>
2020-09-19  7:37 ` Min Hu (Connor) [this message]
2020-09-19  7:37 ` [dpdk-stable] [PATCH v3 2/6] app/testpmd: fix VLAN offload configuration when config fail Min Hu (Connor)
2020-09-19  7:37 ` [dpdk-stable] [PATCH v3 3/6] app/testpmd: remove restriction on txpkts set Min Hu (Connor)
2020-09-19  7:37 ` [dpdk-stable] [PATCH v3 4/6] app/testpmd: fix packet header in txonly mode Min Hu (Connor)
2020-09-19  7:37 ` [dpdk-stable] [PATCH v3 5/6] app/testpmd: fix valid desc id check Min Hu (Connor)
2020-09-19  7:37 ` [dpdk-stable] [PATCH v3 6/6] app/testpmd: fix displaying Rx Tx queues information Min Hu (Connor)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1600501034-50042-2-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=forest.zhouchang@huawei.com \
    --cc=stable@dpdk.org \
    --cc=tangchengchang@huawei.com \
    --cc=xavier.huwei@foxmail.com \
    --cc=xavier.huwei@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).