Fetch the repository succeeded.
This action will force synchronization from src-openEuler/gazelle, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
From 11f46783f88912e3c204fc12d4f33034f371881b Mon Sep 17 00:00:00 2001
From: Honggang LI <honggangli@163.com>
Date: Thu, 23 Jun 2022 13:36:36 +0800
Subject: [PATCH 19/40] lstack/core: fix reta_conf array size calculation
When dev_info.reta_size is smaller than RTE_RETA_GROUP_SIZE, the first
parameter (nmemb) of calloc is zero.
If nmemb is 0, then calloc() returns either NULL, or a unique pointer
value that can later be successfully passed to free(). When non-NULL
unique pointer was returned, rss_setup() will failed because of garbage
value in memory pointed by the unique pointer.
Signed-off-by: Honggang LI <honggangli@163.com>
---
src/lstack/core/lstack_dpdk.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
index df0332b..3f0dbb4 100644
--- a/src/lstack/core/lstack_dpdk.c
+++ b/src/lstack/core/lstack_dpdk.c
@@ -428,6 +428,7 @@ static int rss_setup(const int port_id, const uint16_t nb_queues)
int ret;
struct rte_eth_dev_info dev_info;
struct rte_eth_rss_reta_entry64 *reta_conf = NULL;
+ size_t reta_conf_size, n;
rte_eth_dev_info_get(port_id, &dev_info);
@@ -435,8 +436,11 @@ static int rss_setup(const int port_id, const uint16_t nb_queues)
return ERR_VAL;
}
- reta_conf = calloc(dev_info.reta_size / RTE_RETA_GROUP_SIZE,
- sizeof(struct rte_eth_rss_reta_entry64));
+ reta_conf_size = dev_info.reta_size / RTE_RETA_GROUP_SIZE;
+ if (dev_info.reta_size % RTE_RETA_GROUP_SIZE)
+ reta_conf_size += 1;
+
+ reta_conf = calloc(reta_conf_size, sizeof(struct rte_eth_rss_reta_entry64));
if (!reta_conf) {
return ERR_MEM;
}
@@ -446,8 +450,8 @@ static int rss_setup(const int port_id, const uint16_t nb_queues)
one_reta_conf->reta[i % RTE_RETA_GROUP_SIZE] = i % nb_queues;
}
- for (i = 0; i < dev_info.reta_size / RTE_RETA_GROUP_SIZE; i++) {
- struct rte_eth_rss_reta_entry64 *one_reta_conf = &reta_conf[i];
+ for (n = 0; n < reta_conf_size; n++) {
+ struct rte_eth_rss_reta_entry64 *one_reta_conf = &reta_conf[n];
one_reta_conf->mask = 0xFFFFFFFFFFFFFFFFULL;
}
--
2.23.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。