sync fix socket init and clean
(cherry picked from commit 633fab2b0c01873c32152ce7de003674b89a8d3e)
This commit is contained in:
parent
fca1430a1e
commit
aa33862e44
135
0250-fix-coredump-caused-by-lwip_get_socket_nouse.patch
Normal file
135
0250-fix-coredump-caused-by-lwip_get_socket_nouse.patch
Normal file
@ -0,0 +1,135 @@
|
||||
From f67317cc61f686bc68c79019a7e1686eab160c5e Mon Sep 17 00:00:00 2001
|
||||
From: Lemmy Huang <huangliming5@huawei.com>
|
||||
Date: Fri, 2 Jun 2023 14:35:16 +0800
|
||||
Subject: [PATCH] fix coredump caused by lwip_get_socket_nouse
|
||||
|
||||
Signed-off-by: Lemmy Huang <huangliming5@huawei.com>
|
||||
---
|
||||
src/lstack/api/lstack_epoll.c | 2 +-
|
||||
src/lstack/api/lstack_wrap.c | 2 +-
|
||||
src/lstack/core/lstack_lwip.c | 6 +++---
|
||||
src/lstack/core/lstack_protocol_stack.c | 15 +++++++++------
|
||||
4 files changed, 14 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c
|
||||
index 64c3600..621762d 100644
|
||||
--- a/src/lstack/api/lstack_epoll.c
|
||||
+++ b/src/lstack/api/lstack_epoll.c
|
||||
@@ -313,7 +313,7 @@ int32_t lstack_epoll_ctl(int32_t epfd, int32_t op, int32_t fd, struct epoll_even
|
||||
|
||||
struct wakeup_poll *wakeup = epoll_sock->wakeup;
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
- if (sock == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL) {
|
||||
return posix_api->epoll_ctl_fn(epfd, op, fd, event);
|
||||
}
|
||||
|
||||
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
|
||||
index 776646f..1f04ae2 100644
|
||||
--- a/src/lstack/api/lstack_wrap.c
|
||||
+++ b/src/lstack/api/lstack_wrap.c
|
||||
@@ -288,7 +288,7 @@ static int32_t do_connect(int32_t s, const struct sockaddr *name, socklen_t name
|
||||
}
|
||||
|
||||
sock = lwip_get_socket_nouse(s);
|
||||
- if (sock == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL) {
|
||||
return posix_api->connect_fn(s, name, namelen);
|
||||
}
|
||||
|
||||
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
|
||||
index 62b4838..2e40862 100644
|
||||
--- a/src/lstack/core/lstack_lwip.c
|
||||
+++ b/src/lstack/core/lstack_lwip.c
|
||||
@@ -173,7 +173,7 @@ void gazelle_init_sock(int32_t fd)
|
||||
static _Atomic uint32_t name_tick = 0;
|
||||
struct protocol_stack *stack = get_protocol_stack();
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
- if (sock == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -687,7 +687,7 @@ void stack_send(struct rpc_msg *msg)
|
||||
bool replenish_again;
|
||||
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
- if (sock == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL) {
|
||||
msg->result = -1;
|
||||
LSTACK_LOG(ERR, LSTACK, "stack_send: sock error!\n");
|
||||
rpc_msg_free(msg);
|
||||
@@ -1251,7 +1251,7 @@ int32_t gazelle_socket(int domain, int type, int protocol)
|
||||
gazelle_init_sock(fd);
|
||||
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
- if (sock == NULL || sock->stack == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL || sock->stack == NULL) {
|
||||
lwip_close(fd);
|
||||
gazelle_clean_sock(fd);
|
||||
posix_api->close_fn(fd);
|
||||
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
|
||||
index ce1c6de..8638cd5 100644
|
||||
--- a/src/lstack/core/lstack_protocol_stack.c
|
||||
+++ b/src/lstack/core/lstack_protocol_stack.c
|
||||
@@ -108,7 +108,7 @@ struct protocol_stack *get_protocol_stack(void)
|
||||
struct protocol_stack *get_protocol_stack_by_fd(int32_t fd)
|
||||
{
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
- if (sock == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -683,7 +683,7 @@ void stack_accept(struct rpc_msg *msg)
|
||||
}
|
||||
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(accept_fd);
|
||||
- if (sock == NULL || sock->stack == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL || sock->stack == NULL) {
|
||||
lwip_close(accept_fd);
|
||||
gazelle_clean_sock(accept_fd);
|
||||
posix_api->close_fn(accept_fd);
|
||||
@@ -815,7 +815,7 @@ int32_t stack_broadcast_close(int32_t fd)
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
int32_t ret = 0;
|
||||
|
||||
- if (sock == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -850,7 +850,7 @@ int32_t stack_broadcast_listen(int32_t fd, int32_t backlog)
|
||||
int32_t ret, clone_fd;
|
||||
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
- if (sock == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL) {
|
||||
LSTACK_LOG(ERR, LSTACK, "tid %ld, %d get sock null\n", get_stack_tid(), fd);
|
||||
GAZELLE_RETURN(EINVAL);
|
||||
}
|
||||
@@ -895,8 +895,11 @@ int32_t stack_broadcast_listen(int32_t fd, int32_t backlog)
|
||||
|
||||
static struct lwip_sock *get_min_accept_sock(int32_t fd)
|
||||
{
|
||||
- struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
struct lwip_sock *min_sock = NULL;
|
||||
+ struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
+ if (sock == NULL || sock->conn == NULL) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
|
||||
while (sock) {
|
||||
if (!NETCONN_IS_ACCEPTIN(sock)) {
|
||||
@@ -934,7 +937,7 @@ int32_t stack_broadcast_accept4(int32_t fd, struct sockaddr *addr, socklen_t *ad
|
||||
int32_t ret = -1;
|
||||
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
- if (sock == NULL) {
|
||||
+ if (sock == NULL || sock->conn == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
65
0251-fix-socket-init-and-clean.patch
Normal file
65
0251-fix-socket-init-and-clean.patch
Normal file
@ -0,0 +1,65 @@
|
||||
From 30d1ef00734485405c4babbf7d4cfe670ac8b52f Mon Sep 17 00:00:00 2001
|
||||
From: Lemmy Huang <huangliming5@huawei.com>
|
||||
Date: Fri, 2 Jun 2023 15:31:08 +0800
|
||||
Subject: [PATCH] fix socket init and clean
|
||||
|
||||
Signed-off-by: Lemmy Huang <huangliming5@huawei.com>
|
||||
---
|
||||
src/lstack/core/lstack_lwip.c | 6 +-----
|
||||
src/lstack/core/lstack_protocol_stack.c | 6 ------
|
||||
2 files changed, 1 insertion(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
|
||||
index 2e40862..ca63c22 100644
|
||||
--- a/src/lstack/core/lstack_lwip.c
|
||||
+++ b/src/lstack/core/lstack_lwip.c
|
||||
@@ -173,7 +173,7 @@ void gazelle_init_sock(int32_t fd)
|
||||
static _Atomic uint32_t name_tick = 0;
|
||||
struct protocol_stack *stack = get_protocol_stack();
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
- if (sock == NULL || sock->conn == NULL) {
|
||||
+ if (sock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1248,13 +1248,9 @@ int32_t gazelle_socket(int domain, int type, int protocol)
|
||||
return fd;
|
||||
}
|
||||
|
||||
- gazelle_init_sock(fd);
|
||||
-
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(fd);
|
||||
if (sock == NULL || sock->conn == NULL || sock->stack == NULL) {
|
||||
lwip_close(fd);
|
||||
- gazelle_clean_sock(fd);
|
||||
- posix_api->close_fn(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
|
||||
index 8638cd5..2fbe62c 100644
|
||||
--- a/src/lstack/core/lstack_protocol_stack.c
|
||||
+++ b/src/lstack/core/lstack_protocol_stack.c
|
||||
@@ -639,10 +639,6 @@ void stack_close(struct rpc_msg *msg)
|
||||
if (msg->result != 0) {
|
||||
LSTACK_LOG(ERR, LSTACK, "tid %ld, fd %d failed %ld\n", get_stack_tid(), msg->args[MSG_ARG_0].i, msg->result);
|
||||
}
|
||||
-
|
||||
- gazelle_clean_sock(fd);
|
||||
-
|
||||
- posix_api->close_fn(fd);
|
||||
}
|
||||
|
||||
void stack_bind(struct rpc_msg *msg)
|
||||
@@ -685,8 +681,6 @@ void stack_accept(struct rpc_msg *msg)
|
||||
struct lwip_sock *sock = lwip_get_socket_nouse(accept_fd);
|
||||
if (sock == NULL || sock->conn == NULL || sock->stack == NULL) {
|
||||
lwip_close(accept_fd);
|
||||
- gazelle_clean_sock(accept_fd);
|
||||
- posix_api->close_fn(accept_fd);
|
||||
LSTACK_LOG(ERR, LSTACK, "fd %d ret %d\n", fd, accept_fd);
|
||||
return;
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@ -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
|
||||
@ -264,6 +264,8 @@ Patch9246: 0246-cleancode-refactor-gazelle_hlist.h.patch
|
||||
Patch9247: 0247-cleancode-refactor-sys_now-and-lwip_ioctl.patch
|
||||
Patch9248: 0248-cleancode-refactor-memp.patch
|
||||
Patch9249: 0249-drop-netbuf-in-read_lwip_data-to-fix-mem-overflow.patch
|
||||
Patch9250: 0250-fix-coredump-caused-by-lwip_get_socket_nouse.patch
|
||||
Patch9251: 0251-fix-socket-init-and-clean.patch
|
||||
|
||||
%description
|
||||
%{name} is a high performance user-mode stack.
|
||||
@ -304,6 +306,10 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
|
||||
%config(noreplace) %{conf_path}/ltran.conf
|
||||
|
||||
%changelog
|
||||
* Fri Jun 2 2023 LemmyHuang <huangliming5@huawei.com> - 1.0.1-60
|
||||
- fix socket init and clean
|
||||
- fix coredump caused by lwip_get_socket_nouse
|
||||
|
||||
* Mon May 29 2023 LemmyHuang <huangliming5@huawei.com> - 1.0.1-59
|
||||
- drop netbuf in read_lwip_data to fix mem overflow
|
||||
- cleancode: refactor memp
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user