From 613832454dd306b45558737a9fd5b618e21f7855 Mon Sep 17 00:00:00 2001 From: jiangheng12 Date: Tue, 28 Mar 2023 15:24:01 +0800 Subject: [PATCH] sync add socket check before write it (cherry picked from commit f6998e64b9571179eabf8f8e4cf574db964738db) --- 0227-fix-build-err-on-select_path.patch | 25 ++++++++++ ...switch-valid-only-in-primary-process.patch | 27 +++++++++++ 0229-add-socket-check-before-write-it.patch | 46 +++++++++++++++++++ gazelle.spec | 10 +++- 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 0227-fix-build-err-on-select_path.patch create mode 100644 0228-set-kni_switch-valid-only-in-primary-process.patch create mode 100644 0229-add-socket-check-before-write-it.patch diff --git a/0227-fix-build-err-on-select_path.patch b/0227-fix-build-err-on-select_path.patch new file mode 100644 index 0000000..e478bc0 --- /dev/null +++ b/0227-fix-build-err-on-select_path.patch @@ -0,0 +1,25 @@ +From c721d637a8a387b53ec614705238714412cfe1be Mon Sep 17 00:00:00 2001 +From: kircher +Date: Mon, 27 Mar 2023 20:05:59 +0800 +Subject: [PATCH] fix build err on select_path + +--- + src/lstack/api/lstack_wrap.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c +index 1fe576f..aacb30c 100644 +--- a/src/lstack/api/lstack_wrap.c ++++ b/src/lstack/api/lstack_wrap.c +@@ -83,7 +83,7 @@ static inline enum KERNEL_LWIP_PATH select_path(int fd, struct lwip_sock **socke + /* after lwip connect, call send immediately, pcb->state is SYN_SENT, need return PATH_LWIP */ + /* pcb->state default value is CLOSED when call socket, need return PATH_UNKNOW */ + if (pcb != NULL && pcb->state <= ESTABLISHED && pcb->state >= LISTEN) { +- *socket = sock ++ *socket = sock; + return PATH_LWIP; + } + +-- +2.23.0 + diff --git a/0228-set-kni_switch-valid-only-in-primary-process.patch b/0228-set-kni_switch-valid-only-in-primary-process.patch new file mode 100644 index 0000000..5ea937b --- /dev/null +++ b/0228-set-kni_switch-valid-only-in-primary-process.patch @@ -0,0 +1,27 @@ +From 17120ad1d57365d2980d4d60742b25cf76ac35bd Mon Sep 17 00:00:00 2001 +From: jiangheng12 +Date: Mon, 27 Mar 2023 20:16:00 +0800 +Subject: [PATCH] set kni_switch valid only in primary process + +--- + src/lstack/core/lstack_cfg.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 95590e2..168aa49 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -855,6 +855,10 @@ static int32_t parse_kni_switch(void) + return -1; + } + ++ if (!g_config_params.use_ltran && !g_config_params.is_primary) { ++ g_config_params.kni_switch = 0; ++ } ++ + return 0; + } + +-- +2.23.0 + diff --git a/0229-add-socket-check-before-write-it.patch b/0229-add-socket-check-before-write-it.patch new file mode 100644 index 0000000..39bc8a1 --- /dev/null +++ b/0229-add-socket-check-before-write-it.patch @@ -0,0 +1,46 @@ +From da9f7797985fe2cc7bd6a5f1a5837bd833838982 Mon Sep 17 00:00:00 2001 +From: kircher +Date: Mon, 27 Mar 2023 22:15:48 +0800 +Subject: [PATCH] add socket check before write it + +--- + src/lstack/api/lstack_wrap.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c +index aacb30c..f81328d 100644 +--- a/src/lstack/api/lstack_wrap.c ++++ b/src/lstack/api/lstack_wrap.c +@@ -75,7 +75,9 @@ static inline enum KERNEL_LWIP_PATH select_path(int fd, struct lwip_sock **socke + } + + if (likely(CONN_TYPE_IS_LIBOS(sock->conn))) { +- *socket = sock; ++ if (socket) { ++ *socket = sock; ++ } + return PATH_LWIP; + } + +@@ -83,7 +85,9 @@ static inline enum KERNEL_LWIP_PATH select_path(int fd, struct lwip_sock **socke + /* after lwip connect, call send immediately, pcb->state is SYN_SENT, need return PATH_LWIP */ + /* pcb->state default value is CLOSED when call socket, need return PATH_UNKNOW */ + if (pcb != NULL && pcb->state <= ESTABLISHED && pcb->state >= LISTEN) { +- *socket = sock; ++ if (socket) { ++ *socket = sock; ++ } + return PATH_LWIP; + } + +@@ -273,6 +277,7 @@ static int32_t do_connect(int32_t s, const struct sockaddr *name, socklen_t name + return posix_api->connect_fn(s, name, namelen); + } + ++ sock = get_socket(s); + if (sock == NULL) { + return posix_api->connect_fn(s, name, namelen); + } +-- +2.23.0 + diff --git a/gazelle.spec b/gazelle.spec index 02e113e..7087237 100644 --- a/gazelle.spec +++ b/gazelle.spec @@ -2,7 +2,7 @@ Name: gazelle Version: 1.0.1 -Release: 59 +Release: 60 Summary: gazelle is a high performance user-mode stack License: MulanPSL-2.0 URL: https://gitee.com/openeuler/gazelle @@ -241,6 +241,9 @@ Patch9223: 0223-revert-select_thread_path-and-optimize-app-thread-wh.patch Patch9224: 0224-sepeate_string_to-array-add-error-args-handle.patch Patch9225: 0225-check-primary-process-idx-and-secondary-lstack-num.patch Patch9226: 0226-optimite-select_path-and-pbuf_take.patch +Patch9227: 0227-fix-build-err-on-select_path.patch +Patch9228: 0228-set-kni_switch-valid-only-in-primary-process.patch +Patch9229: 0229-add-socket-check-before-write-it.patch %description %{name} is a high performance user-mode stack. @@ -281,6 +284,11 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b %config(noreplace) %{conf_path}/ltran.conf %changelog +* Tue Mar 28 2023 jiangheng12 - 1.0.1-60 +- add socket check before write it +- set kni_switch valid only in primary process +- fix build err on select_path + * Mon Mar 27 2023 kircher - 1.0.1-59 - optimite select_path and pbuf_take - check primary process idx and secondary lstack num