!343 [sync] PR-339: sync add socket check before write it

From: @openeuler-sync-bot 
Reviewed-by: @jiangheng12 
Signed-off-by: @jiangheng12
This commit is contained in:
openeuler-ci-bot 2023-04-01 06:23:54 +00:00 committed by Gitee
commit 45aa63c6f3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 107 additions and 1 deletions

View File

@ -0,0 +1,25 @@
From c721d637a8a387b53ec614705238714412cfe1be Mon Sep 17 00:00:00 2001
From: kircher <majun65@huawei.com>
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

View File

@ -0,0 +1,27 @@
From 17120ad1d57365d2980d4d60742b25cf76ac35bd Mon Sep 17 00:00:00 2001
From: jiangheng12 <jiangheng14@huawei.com>
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

View File

@ -0,0 +1,46 @@
From da9f7797985fe2cc7bd6a5f1a5837bd833838982 Mon Sep 17 00:00:00 2001
From: kircher <majun65@huawei.com>
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

View File

@ -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 <jiangheng14@huawei.com> - 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 <majun65@huawei.com> - 1.0.1-59
- optimite select_path and pbuf_take
- check primary process idx and secondary lstack num