sync epoll: fix wild pointer detected by cooddy

(cherry picked from commit acc62d706b14666393c15053c53aec975c214dce)
This commit is contained in:
yinbin6 2024-08-30 16:13:15 +08:00 committed by openeuler-sync-bot
parent 68fb13d92d
commit ff7fcbee80
5 changed files with 164 additions and 1 deletions

View File

@ -0,0 +1,57 @@
From 783ea4a8f8949cb943a94cb6fdb1690852f7faa3 Mon Sep 17 00:00:00 2001
From: yangchen <yangchen145@huawei.com>
Date: Fri, 16 Aug 2024 05:55:40 +0800
Subject: [PATCH] fix mbuf_total calculation error
---
src/lstack/core/lstack_protocol_stack.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 6e980a8..ba90d86 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -548,29 +548,31 @@ static void* gazelle_stack_thread(void *arg)
int32_t stack_group_init_mempool(void)
{
- struct cfg_params *global_cfg_parmas = get_global_cfg_params();
- uint32_t total_mbufs = get_global_cfg_params()->mbuf_count_per_conn * get_global_cfg_params()->tcp_conn_count;
+ struct cfg_params *cfg_params = get_global_cfg_params();
+ uint32_t total_mbufs = 0;
+ uint32_t total_conn_mbufs = cfg_params->mbuf_count_per_conn * cfg_params->tcp_conn_count;
+ uint32_t total_nic_mbufs = cfg_params->nic.rxqueue_size + cfg_params->nic.txqueue_size;
struct rte_mempool *rxtx_mbuf = NULL;
uint32_t cpu_id = 0;
unsigned numa_id = 0;
int queue_id = 0;
LSTACK_LOG(INFO, LSTACK,
- "config::num_cpu=%d num_process=%d \n", global_cfg_parmas->num_cpu, global_cfg_parmas->num_process);
+ "config::num_cpu=%d num_process=%d \n", cfg_params->num_cpu, cfg_params->num_process);
- for (int cpu_idx = 0; cpu_idx < get_global_cfg_params()->num_queue; cpu_idx++) {
- cpu_id = global_cfg_parmas->cpus[cpu_idx];
+ for (int cpu_idx = 0; cpu_idx < cfg_params->num_queue; cpu_idx++) {
+ cpu_id = cfg_params->cpus[cpu_idx];
numa_id = numa_node_of_cpu(cpu_id);
- for (int process_idx = 0; process_idx < global_cfg_parmas->num_process; process_idx++) {
- queue_id = cpu_idx * global_cfg_parmas->num_process + process_idx;
+ for (int process_idx = 0; process_idx < cfg_params->num_process; process_idx++) {
+ queue_id = cpu_idx * cfg_params->num_process + process_idx;
if (queue_id >= PROTOCOL_STACK_MAX) {
LSTACK_LOG(ERR, LSTACK, "index is over\n");
return -1;
}
- rxtx_mbuf = create_pktmbuf_mempool(
- "rxtx_mbuf", total_mbufs / get_global_cfg_params()->num_queue, RXTX_CACHE_SZ, queue_id, numa_id);
+ total_mbufs = (total_conn_mbufs / cfg_params->num_queue) + total_nic_mbufs + MBUFPOOL_RESERVE_NUM;
+ rxtx_mbuf = create_pktmbuf_mempool("rxtx_mbuf", total_mbufs, RXTX_CACHE_SZ, queue_id, numa_id);
if (rxtx_mbuf == NULL) {
LSTACK_LOG(ERR, LSTACK, "cpuid=%u, numid=%d , rxtx_mbuf idx= %d create_pktmbuf_mempool fail\n",
cpu_id, numa_id, queue_id);
--
2.33.0

View File

@ -0,0 +1,25 @@
From 5c0ece87e2ce183119f29f5d6a2c53465a622ac9 Mon Sep 17 00:00:00 2001
From: yangchen <yangchen145@huawei.com>
Date: Sat, 17 Aug 2024 05:15:57 +0800
Subject: [PATCH] cfg: modify maximum tcp_conn_count to 2w
---
src/lstack/core/lstack_cfg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index cd81edb..882e60a 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -917,7 +917,7 @@ static int32_t parse_use_ltran(void)
static int32_t parse_tcp_conn_count(void)
{
int32_t ret;
- PARSE_ARG(g_config_params.tcp_conn_count, "tcp_conn_count", TCP_CONN_COUNT, 1, TCP_CONN_COUNT, ret);
+ PARSE_ARG(g_config_params.tcp_conn_count, "tcp_conn_count", TCP_CONN_COUNT, 1, GAZELLE_MAX_CLIENTS, ret);
return ret;
}
--
2.33.0

View File

@ -0,0 +1,47 @@
From ccab3a40054a7d95e144bca8f9e0fd0c376cbaf6 Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Mon, 26 Aug 2024 21:12:17 +0800
Subject: [PATCH] tools: fix sync patch script date wrong and update the way
get patchnum
---
tools/sync-gazelle-src.sh | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/sync-gazelle-src.sh b/tools/sync-gazelle-src.sh
index 8d44ca2..142e770 100644
--- a/tools/sync-gazelle-src.sh
+++ b/tools/sync-gazelle-src.sh
@@ -63,10 +63,16 @@ for commitid in ${COMMIT_ID};do
git checkout -b $TARGET_BRANCH origin/$TARGET_BRANCH
git pull https://gitee.com/src-openeuler/gazelle.git $TARGET_BRANCH
fi
- patchnum=$(ls ./*.patch | wc -l)
- let patchnum+=1
- let Patchnum=9000+$patchnum
- patchnum=$(printf "%04d\n" $patchnum)
+
+ #get patchnum from spec file.
+ patchnum=$(grep -o "Patch[0-9]\+" *.spec | tail -n 1 | awk -Fh '{print $2}')
+ if [ -z $patchnum ];then
+ #there is no patch in spec file. get patch by conunt patches in dir.
+ patchnum=$(ls ./*.patch | wc -l)
+ let Patchnum=9000+$patchnum
+ patchnum=$(printf "%04d\n" $patchnum)
+ fi
+ let patchnum+=1
new_patchname=$(echo $patchname | sed -e "s/^0001-/${patchnum}-/g")
echo $new_patchname
@@ -82,7 +88,7 @@ for commitid in ${COMMIT_ID};do
#add changelog in spec file
changelog_line=$(grep -n '^%changelog' gazelle.spec | cut -f1 -d':')
- changelog_data=$(date | awk '{print $1,$2,$3,$6}')
+ changelog_data=$(date +"%a %b %d %Y")
changelog_version=$(grep '^Version' gazelle.spec | awk '{print $2}')
if [ -z "$done_once" ];then
--
2.33.0

View File

@ -0,0 +1,24 @@
From 2adb9415c567037a44f6adf7df3b91ced624cb51 Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Tue, 27 Aug 2024 16:23:03 +0800
Subject: [PATCH] epoll: fix wild pointer detected by cooddy
---
src/lstack/api/lstack_epoll.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c
index b83da70..5b0bee4 100644
--- a/src/lstack/api/lstack_epoll.c
+++ b/src/lstack/api/lstack_epoll.c
@@ -782,6 +782,7 @@ static int resize_kernel_poll(struct wakeup_poll *wakeup, nfds_t nfds)
if (wakeup->events == NULL) {
LSTACK_LOG(ERR, LSTACK, "calloc failed errno=%d\n", errno);
free(wakeup->last_fds);
+ wakeup->last_fds = NULL;
return -1;
}
--
2.33.0

View File

@ -2,7 +2,7 @@
Name: gazelle
Version: 1.0.2
Release: 58
Release: 59
Summary: gazelle is a high performance user-mode stack
License: MulanPSL-2.0
URL: https://gitee.com/openeuler/gazelle
@ -262,6 +262,10 @@ Patch9242: 0242-fix-redis-coredump-ctrl-c-during-the-pressure-test.patch
Patch9243: 0243-virtio_user-check-netif-status.patch
Patch9244: 0244-virtio-solve-compilation-error-in-2003sp3.patch
Patch9245: 0245-CMAKE-fix-ltran-build-error-in-2403.patch
Patch9246: 0246-fix-mbuf_total-calculation-error.patch
Patch9247: 0247-cfg-modify-maximum-tcp_conn_count-to-2w.patch
Patch9248: 0248-tools-fix-sync-patch-script-date-wrong-and-update-th.patch
Patch9249: 0249-epoll-fix-wild-pointer-detected-by-cooddy.patch
%description
%{name} is a high performance user-mode stack.
@ -303,6 +307,12 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
%config(noreplace) %{conf_path}/ltran.conf
%changelog
* Fri Aug 30 2024 yinbin6 <yinbin8@huawei.com> - 1.0.2-59
- epoll: fix wild pointer detected by cooddy
- tools: fix sync patch script date wrong and update the way get patchnum
- cfg: modify maximum tcp_conn_count to 2w
- fix mbuf_total calculation error
* Wed Aug 28 2024 laokz <zhangkai@iscas.ac.cn> - 1.0.2-58
- add riscv64 to %ExclusiveArch