1 Star 0 Fork 72

叶青龙/dpdk

forked from src-openEuler/dpdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0312-app-testpmd-fix-segment-fault-with-invalid-queue-ID.patch 2.63 KB
一键复制 编辑 原始数据 按行查看 历史
From 1c7616769fc09d9443cfd39816fa35b4b0ddd33d Mon Sep 17 00:00:00 2001
From: Dengdui Huang <huangdengdui@huawei.com>
Date: Mon, 5 Jun 2023 10:27:41 +0800
Subject: app/testpmd: fix segment fault with invalid queue ID
[ upstream commit 53191add2203e943c46af0b86002613f22b734b3 ]
When input queue ID is invalid, it will lead to
Segmentation fault, like:
dpdk-testpmd -a 0000:01:00.0 -- -i
testpmd> show port 0 txq/rxq 99 desc 0 status
Segmentation fault
dpdk-testpmd -a 0000:01:00.0 -- -i
testpmd> show port 0 rxq 99 desc used count
Segmentation fault
This patch fixes it.
Fixes: fae9aa717d6c ("app/testpmd: support checking descriptor status")
Fixes: 3f9acb5c83bb ("ethdev: avoid non-dataplane checks in Rx queue count")
Cc: stable@dpdk.org
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
app/test-pmd/cmdline.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0d9c7d449c..bc770f3d56 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -17315,12 +17315,13 @@ cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
int rc;
- if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
- fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
- return;
- }
-
if (!strcmp(res->cmd_keyword, "rxq")) {
+ if (rte_eth_dev_is_valid_rxq(res->cmd_pid, res->cmd_qid) != 0) {
+ fprintf(stderr,
+ "Invalid input: port id = %d, queue id = %d\n",
+ res->cmd_pid, res->cmd_qid);
+ return;
+ }
rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
res->cmd_did);
if (rc < 0) {
@@ -17336,6 +17337,12 @@ cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
else
printf("Desc status = UNAVAILABLE\n");
} else if (!strcmp(res->cmd_keyword, "txq")) {
+ if (rte_eth_dev_is_valid_txq(res->cmd_pid, res->cmd_qid) != 0) {
+ fprintf(stderr,
+ "Invalid input: port id = %d, queue id = %d\n",
+ res->cmd_pid, res->cmd_qid);
+ return;
+ }
rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
res->cmd_did);
if (rc < 0) {
@@ -17415,8 +17422,10 @@ cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
int rc;
- if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
- fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
+ if (rte_eth_dev_is_valid_rxq(res->cmd_pid, res->cmd_qid) != 0) {
+ fprintf(stderr,
+ "Invalid input: port id = %d, queue id = %d\n",
+ res->cmd_pid, res->cmd_qid);
return;
}
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yeqinglong01/dpdk.git
git@gitee.com:yeqinglong01/dpdk.git
yeqinglong01
dpdk
dpdk
master

搜索帮助