!1028 [sync] PR-1022: sync bugfix: fix gazelle init failed while setup by non-root user

From: @openeuler-sync-bot 
Reviewed-by: @jiangheng12 
Signed-off-by: @jiangheng12
This commit is contained in:
openeuler-ci-bot 2024-10-10 03:13:33 +00:00 committed by Gitee
commit 4e0848ad2a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 235 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From 14faa8f3a28490367c41c32ccb714ca4e743775d Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 30 Sep 2024 14:46:55 +0800
Subject: [PATCH] fix stack null when register interrupt
---
src/lstack/core/lstack_protocol_stack.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index e412c3b..553dff3 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -562,7 +562,6 @@ static void* gazelle_stack_thread(void *arg)
unsigned wakeup_tick = 0;
stack = stack_thread_init(arg);
- intr_register(stack->stack_idx, INTR_LOCAL_EVENT, stack_local_event_get);
free(arg);
if (stack == NULL) {
LSTACK_LOG(ERR, LSTACK, "stack_thread_init failed queue_id=%hu\n", queue_id);
@@ -577,6 +576,7 @@ static void* gazelle_stack_thread(void *arg)
return NULL;
}
+ intr_register(stack->stack_idx, INTR_LOCAL_EVENT, stack_local_event_get);
stack_set_state(stack, RUNNING);
while (stack_polling(wakeup_tick) == 0) {
--
2.33.0

View File

@ -0,0 +1,69 @@
From 26550111abb490691a8b774f8bcc5a11a5a1cd9a Mon Sep 17 00:00:00 2001
From: Lemmy Huang <huangliming5@huawei.com>
Date: Mon, 30 Sep 2024 11:33:05 +0800
Subject: [PATCH] rtw: fix send length exceeding send_ring_size
Signed-off-by: Lemmy Huang <huangliming5@huawei.com>
---
src/lstack/core/lstack_lwip.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 2eb872c..cb0964b 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -538,8 +538,8 @@ static ssize_t do_lwip_udp_fill_sendring(struct lwip_sock *sock, const void *buf
return send_len;
}
-static ssize_t do_lwip_tcp_fill_sendring(struct lwip_sock *sock, const void *buf, size_t len,
- const struct sockaddr *addr, socklen_t addrlen)
+static ssize_t __do_lwip_tcp_fill_sendring(struct lwip_sock *sock, const void *buf, size_t len,
+ const struct sockaddr *addr, socklen_t addrlen)
{
/* refer to the lwip implementation. */
if (len == 0) {
@@ -566,6 +566,10 @@ static ssize_t do_lwip_tcp_fill_sendring(struct lwip_sock *sock, const void *buf
if (sock->errevent > 0) {
GAZELLE_RETURN(ENOTCONN);
}
+ /* wait until (send_ring_size / 4) */
+ if (write_avail > (rte_ring_get_capacity(sock->send_ring) >> 2)) {
+ break;
+ }
write_avail = gazelle_ring_readable_count(sock->send_ring);
}
@@ -600,6 +604,29 @@ END:
return send_len;
}
+static inline void notice_stack_tcp_send(struct lwip_sock *sock, int32_t fd, int32_t len, int32_t flags);
+static ssize_t do_lwip_tcp_fill_sendring(struct lwip_sock *sock, const void *buf, size_t len,
+ const struct sockaddr *addr, socklen_t addrlen)
+{
+ ssize_t ret, send_len = 0;
+
+ while (true) {
+ ret = __do_lwip_tcp_fill_sendring(sock, (char *)buf + send_len, len - send_len, addr, addrlen);
+ // send = 0 : tcp peer close connection ?
+ if (unlikely(ret <= 0)) {
+ break;
+ }
+ send_len += ret;
+ if (send_len == len || netconn_is_nonblocking(sock->conn)) {
+ break;
+ }
+
+ notice_stack_tcp_send(sock, sock->conn->callback_arg.socket, ret, 0);
+ }
+
+ return send_len == 0 ? ret : send_len;
+}
+
bool do_lwip_replenish_sendring(struct protocol_stack *stack, struct lwip_sock *sock)
{
bool replenish_again = false;
--
2.33.0

View File

@ -0,0 +1,84 @@
From 870caa8931a9f6a068172e56d7e401cd4b9b4086 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Tue, 8 Oct 2024 20:39:37 +0800
Subject: [PATCH] rpc: fix rpc_sync_call spinlock block when msg be recalled
---
src/lstack/core/lstack_thread_rpc.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/lstack/core/lstack_thread_rpc.c b/src/lstack/core/lstack_thread_rpc.c
index 7f77c12..aed792d 100644
--- a/src/lstack/core/lstack_thread_rpc.c
+++ b/src/lstack/core/lstack_thread_rpc.c
@@ -97,13 +97,19 @@ static void rpc_msg_free(struct rpc_msg *msg)
}
__rte_always_inline
-static void rpc_async_call(rpc_queue *queue, struct rpc_msg *msg)
+static void rpc_call(rpc_queue *queue, struct rpc_msg *msg)
{
- msg->sync_flag = 0;
lockless_queue_mpsc_push(&queue->queue, &msg->queue_node);
intr_wakeup(queue->queue_id, INTR_REMOTE_EVENT);
}
+__rte_always_inline
+static void rpc_async_call(rpc_queue *queue, struct rpc_msg *msg)
+{
+ msg->sync_flag = 0;
+ rpc_call(queue, msg);
+}
+
__rte_always_inline
static int rpc_sync_call(rpc_queue *queue, struct rpc_msg *msg)
{
@@ -112,8 +118,7 @@ static int rpc_sync_call(rpc_queue *queue, struct rpc_msg *msg)
pthread_spin_trylock(&msg->lock);
msg->sync_flag = 1;
- lockless_queue_mpsc_push(&queue->queue, &msg->queue_node);
- intr_wakeup(queue->queue_id, INTR_REMOTE_EVENT);
+ rpc_call(queue, msg);
// waiting stack unlock
pthread_spin_lock(&msg->lock);
@@ -209,7 +214,7 @@ static void callback_close(struct rpc_msg *msg)
if (sock && __atomic_load_n(&sock->call_num, __ATOMIC_ACQUIRE) > 0) {
msg->recall_flag = 1;
- rpc_async_call(&stack->rpc_queue, msg); /* until stack_send recall finish */
+ rpc_call(&stack->rpc_queue, msg); /* until stack_send recall finish */
return;
}
@@ -228,7 +233,7 @@ static void callback_shutdown(struct rpc_msg *msg)
if (sock && __atomic_load_n(&sock->call_num, __ATOMIC_ACQUIRE) > 0) {
msg->recall_flag = 1;
- rpc_async_call(&stack->rpc_queue, msg);
+ rpc_call(&stack->rpc_queue, msg);
return;
}
@@ -586,7 +591,7 @@ static void callback_tcp_send(struct rpc_msg *msg)
if (ret > 0 || NETCONN_IS_DATAOUT(sock)) {
if (__atomic_load_n(&sock->call_num, __ATOMIC_ACQUIRE) == 1) {
msg->recall_flag = 1;
- rpc_async_call(&stack->rpc_queue, msg);
+ rpc_call(&stack->rpc_queue, msg);
return;
}
}
@@ -675,7 +680,7 @@ static void callback_replenish_sendring(struct rpc_msg *msg)
msg->result = do_lwip_replenish_sendring(stack, sock);
if (msg->result == true) {
msg->recall_flag = 1;
- rpc_async_call(&stack->rpc_queue, msg);
+ rpc_call(&stack->rpc_queue, msg);
}
}
--
2.33.0

View File

@ -0,0 +1,39 @@
From 6b489d5555a2d28c37bb64f995962239f4e91624 Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Tue, 8 Oct 2024 20:25:34 +0800
Subject: [PATCH] bugfix: fix gazelle init failed while setup by non-root user
---
src/lstack/core/lstack_init.c | 3 +--
src/lstack/include/lstack_log.h | 1 +
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c
index 53e25b4..a72af84 100644
--- a/src/lstack/core/lstack_init.c
+++ b/src/lstack/core/lstack_init.c
@@ -257,8 +257,7 @@ __attribute__((constructor)) void gazelle_network_init(void)
wrap_api_init();
if (set_rlimit_unlimited() != 0) {
- LSTACK_PRE_LOG(LSTACK_INFO, "set rlimit unlimited failed\n");
- LSTACK_EXIT(1, "set rlimit unlimited failed\n");
+ LSTACK_PRE_LOG(LSTACK_WARNING, "set rlimit unlimited failed. errno=%d\n", errno);
}
/* check primary process start */
diff --git a/src/lstack/include/lstack_log.h b/src/lstack/include/lstack_log.h
index e4bed37..a48e02f 100644
--- a/src/lstack/include/lstack_log.h
+++ b/src/lstack/include/lstack_log.h
@@ -23,6 +23,7 @@
#define LSTACK_INFO LOG_INFO
#define LSTACK_ERR LOG_ERR
+#define LSTACK_WARNING LOG_WARNING
/* before rte_eal_init */
#define LSTACK_PRE_LOG(level, fmt, ...) \
--
2.33.0

View File

@ -2,7 +2,7 @@
Name: gazelle
Version: 1.0.2
Release: 66
Release: 67
Summary: gazelle is a high performance user-mode stack
License: MulanPSL-2.0
URL: https://gitee.com/openeuler/gazelle
@ -281,6 +281,10 @@ Patch9261: 0261-Fill-in-a-portion-of-mbuf-to-send_ring-when-mbuf-is-.patch
Patch9262: 0262-add-pingpong-dfx-support.patch
Patch9263: 0263-add-interrupt-mode-support.patch
Patch9264: 0264-af_xdp-set-rlimit-unlimit-when-gazelle-init.patch
Patch9265: 0265-fix-stack-null-when-register-interrupt.patch
Patch9266: 0266-rtw-fix-send-length-exceeding-send_ring_size.patch
Patch9267: 0267-rpc-fix-rpc_sync_call-spinlock-block-when-msg-be-rec.patch
Patch9268: 0268-bugfix-fix-gazelle-init-failed-while-setup-by-non-ro.patch
%description
%{name} is a high performance user-mode stack.
@ -322,6 +326,12 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
%config(noreplace) %{conf_path}/ltran.conf
%changelog
* Wed Oct 09 2024 yinbin6 <jiangheng14@huawei.com> - 1.0.2-67
- bugfix: fix gazelle init failed while setup by non-root user
- rpc: fix rpc_sync_call spinlock block when msg be recalled
- rtw: fix send length exceeding send_ring_size
- fix stack null when register interrupt
* Sun Sep 29 2024 yinbin6 <jiangheng14@huawei.com> - 1.0.2-66
- af_xdp: set rlimit unlimit when gazelle init
- add interrupt mode support