From 843b2df32a5f497d653de42b88020324c5efd37e Mon Sep 17 00:00:00 2001 From: compile_success <980965867@qq.com> Date: Thu, 1 Dec 2022 14:51:47 +0000 Subject: [PATCH] sync add malloc init zero (cherry picked from commit c2dfab92ca3569b5ddbb662285fc209c41e7f769) --- 0143-add-malloc-init-zero.patch | 95 +++++++++++++++++++++++++++++++++ 0144-modify-event-error.patch | 28 ++++++++++ gazelle.spec | 8 ++- 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 0143-add-malloc-init-zero.patch create mode 100644 0144-modify-event-error.patch diff --git a/0143-add-malloc-init-zero.patch b/0143-add-malloc-init-zero.patch new file mode 100644 index 0000000..081c0ea --- /dev/null +++ b/0143-add-malloc-init-zero.patch @@ -0,0 +1,95 @@ +From 31f0d1f4b5d8617ef15226f7c88156308626da0f Mon Sep 17 00:00:00 2001 +From: wu-changsheng +Date: Fri, 18 Nov 2022 20:51:03 +0800 +Subject: [PATCH] add malloc init zero + +--- + src/lstack/core/lstack_cfg.c | 2 +- + src/lstack/core/lstack_control_plane.c | 2 +- + src/lstack/core/lstack_protocol_stack.c | 2 +- + src/ltran/ltran_param.c | 2 +- + src/ltran/ltran_stack.c | 2 +- + src/ltran/ltran_tcp_sock.c | 2 +- + 6 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 1ff3794..52ff3f5 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -785,7 +785,7 @@ static int32_t parse_conf_file(const char *path) + int32_t cfg_init(void) + { + int32_t ret; +- char *config_file = malloc(PATH_MAX * sizeof(char)); ++ char *config_file = calloc(PATH_MAX, sizeof(char)); + if (config_file == NULL) { + return -1; + } +diff --git a/src/lstack/core/lstack_control_plane.c b/src/lstack/core/lstack_control_plane.c +index 0a10d83..bf55df5 100644 +--- a/src/lstack/core/lstack_control_plane.c ++++ b/src/lstack/core/lstack_control_plane.c +@@ -586,7 +586,7 @@ static int32_t thread_register(void) + { + int32_t ret; + +- struct gazelle_stat_lstack_conn *conn = malloc(sizeof(struct gazelle_stat_lstack_conn)); ++ struct gazelle_stat_lstack_conn *conn = calloc(1, sizeof(struct gazelle_stat_lstack_conn)); + if (conn == NULL) { + LSTACK_LOG(ERR, LSTACK, "malloc fail\n"); + return -1; +diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c +index 14c25f5..d5830f1 100644 +--- a/src/lstack/core/lstack_protocol_stack.c ++++ b/src/lstack/core/lstack_protocol_stack.c +@@ -344,7 +344,7 @@ static struct protocol_stack *stack_thread_init(uint16_t queue_id) + { + struct protocol_stack_group *stack_group = get_protocol_stack_group(); + +- struct protocol_stack *stack = malloc(sizeof(*stack)); ++ struct protocol_stack *stack = calloc(1, sizeof(*stack)); + if (stack == NULL) { + LSTACK_LOG(ERR, LSTACK, "malloc stack failed\n"); + sem_post(&stack_group->thread_phase1); +diff --git a/src/ltran/ltran_param.c b/src/ltran/ltran_param.c +index 4974085..18854cf 100644 +--- a/src/ltran/ltran_param.c ++++ b/src/ltran/ltran_param.c +@@ -101,7 +101,7 @@ static int32_t parse_forward_kit_args_single(char *dpdk_str, size_t len, struct + (void)len; + do { + ltran_config->dpdk.dpdk_argc = 0; +- ltran_config->dpdk.dpdk_argv = malloc(GAZELLE_MAX_DPDK_ARGS_NUM * sizeof(char *)); ++ ltran_config->dpdk.dpdk_argv = calloc(GAZELLE_MAX_DPDK_ARGS_NUM, sizeof(char *)); + if (ltran_config->dpdk.dpdk_argv == NULL) { + gazelle_set_errno(GAZELLE_ENOMEM); + break; +diff --git a/src/ltran/ltran_stack.c b/src/ltran/ltran_stack.c +index 1c0d4f7..d4e935e 100644 +--- a/src/ltran/ltran_stack.c ++++ b/src/ltran/ltran_stack.c +@@ -36,7 +36,7 @@ struct gazelle_stack_htable *gazelle_stack_htable_create(uint32_t max_stack_num) + struct gazelle_stack_htable *stack_htable; + uint32_t i; + +- stack_htable = malloc(sizeof(struct gazelle_stack_htable)); ++ stack_htable = calloc(1, sizeof(struct gazelle_stack_htable)); + if (stack_htable == NULL) { + return NULL; + } +diff --git a/src/ltran/ltran_tcp_sock.c b/src/ltran/ltran_tcp_sock.c +index 7ba23f0..d6a0d17 100644 +--- a/src/ltran/ltran_tcp_sock.c ++++ b/src/ltran/ltran_tcp_sock.c +@@ -40,7 +40,7 @@ struct gazelle_tcp_sock_htable *gazelle_tcp_sock_htable_create(uint32_t max_tcp_ + uint32_t i; + struct gazelle_tcp_sock_htable *tcp_sock_htable = NULL; + +- tcp_sock_htable = malloc(sizeof(struct gazelle_tcp_sock_htable)); ++ tcp_sock_htable = calloc(1, sizeof(struct gazelle_tcp_sock_htable)); + if (tcp_sock_htable == NULL) { + return NULL; + } +-- +2.33.0 + diff --git a/0144-modify-event-error.patch b/0144-modify-event-error.patch new file mode 100644 index 0000000..2ce2773 --- /dev/null +++ b/0144-modify-event-error.patch @@ -0,0 +1,28 @@ +From 41a1d215efc76fb07630c15cbe5580466f950f30 Mon Sep 17 00:00:00 2001 +From: compile_success <980965867@qq.com> +Date: Tue, 22 Nov 2022 15:31:19 +0000 +Subject: [PATCH] modify event error + +--- + src/lstack/api/lstack_epoll.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c +index 02889d6..c3fd31c 100644 +--- a/src/lstack/api/lstack_epoll.c ++++ b/src/lstack/api/lstack_epoll.c +@@ -145,9 +145,9 @@ static void raise_pending_events(struct wakeup_poll *wakeup, struct lwip_sock *s + event |= EPOLLERR | EPOLLIN; + } + +- sock->events = event; +- if (sock->events) { ++ if (event) { + pthread_spin_lock(&wakeup->event_list_lock); ++ sock->events = event; + if (wakeup->type == WAKEUP_EPOLL && list_is_null(&sock->event_list)) { + list_add_node(&wakeup->event_list, &sock->event_list); + } +-- +2.33.0 + diff --git a/gazelle.spec b/gazelle.spec index 18175ab..71d17ea 100644 --- a/gazelle.spec +++ b/gazelle.spec @@ -2,7 +2,7 @@ Name: gazelle Version: 1.0.1 -Release: 24 +Release: 25 Summary: gazelle is a high performance user-mode stack License: MulanPSL-2.0 URL: https://gitee.com/openeuler/gazelle @@ -157,6 +157,8 @@ Patch9139: 0139-fix-pcb-snd_buf-flip.patch Patch9140: 0140-fix-lwip-send-return-0-add-err-event.patch Patch9141: 0141-fix-data-flow-error-when-use-NIC-in-kernel.patch Patch9142: 0142-fix-write-event-error.patch +Patch9143: 0143-add-malloc-init-zero.patch +Patch9144: 0144-modify-event-error.patch %description %{name} is a high performance user-mode stack. @@ -197,6 +199,10 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b %config(noreplace) %{conf_path}/ltran.conf %changelog +* Thu Dec 1 UTC compile_success <980965867@qq.com> - 1.0.1-25 +- add malloc init zero +- modify EPOLLOUT event is overwritten. + * Sat Nov 26 UTC compile_success <980965867@qq.com> - 1.0.1-24 - fix write event error