support gazelle feature
(cherry picked from commit 7f3a45da73fc327e843954804585091b4040b59f)
This commit is contained in:
parent
5e9bb7e40b
commit
ba943c7646
5569
0002-adapt-lstack.patch
Normal file
5569
0002-adapt-lstack.patch
Normal file
File diff suppressed because it is too large
Load Diff
63
0003-fix-the-occasional-coredump-when-the-lwip-exits.patch
Normal file
63
0003-fix-the-occasional-coredump-when-the-lwip-exits.patch
Normal file
@ -0,0 +1,63 @@
|
||||
From 0d5070b4a40912a7921e0101461a9c7d61919acd Mon Sep 17 00:00:00 2001
|
||||
From: HuangLiming <huangliming5@huawei.com>
|
||||
Date: Tue, 25 May 2021 03:08:33 -0400
|
||||
Subject: [PATCH] fix the occasional coredump when the lwip exits
|
||||
|
||||
Signed-off-by: HuangLiming <huangliming5@huawei.com>
|
||||
---
|
||||
src/api/sockets.c | 37 +++++++++----------------------------
|
||||
1 file changed, 9 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index d62e55b..658f762 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -4655,36 +4655,17 @@ void lwip_sock_init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
-//modify from lwip_close
|
||||
void lwip_exit(void)
|
||||
{
|
||||
- int i, is_tcp;
|
||||
- struct lwip_sock *sock;
|
||||
-
|
||||
- if (memp_pools[MEMP_SYS_MBOX] == NULL) {
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- for (i = 0; i < sockets_num; i++) {
|
||||
- sock = &sockets[i];
|
||||
- if (!sock->conn)
|
||||
- continue;
|
||||
-#if LWIP_IGMP
|
||||
- /* drop all possibly joined IGMP memberships */
|
||||
- lwip_socket_drop_registered_memberships(i);
|
||||
-#endif /* LWIP_IGMP */
|
||||
- /*
|
||||
- * process is exiting, call netconn_delete to
|
||||
- * close tcp connection, and ignore the return value
|
||||
- */
|
||||
- is_tcp = NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP;
|
||||
- netconn_delete(sock->conn);
|
||||
- free_socket(sock, is_tcp);
|
||||
- }
|
||||
-
|
||||
- free(sockets);
|
||||
- sockets = NULL;
|
||||
- sockets_num = 0;
|
||||
+ /*
|
||||
+ * LwIP has the following two parts of memory application, but
|
||||
+ * it is unnecessary to release all memory in sequentially,
|
||||
+ * which increases complexity. Therefore, we rely on the process
|
||||
+ * reclamation mechanism of the system to release memory.
|
||||
+ * 1. a sockets table of the process.
|
||||
+ * 2. a batch of hugepage memory of each thread.
|
||||
+ */
|
||||
+ return;
|
||||
}
|
||||
|
||||
#endif /* USE_LIBOS */
|
||||
--
|
||||
2.23.0
|
||||
|
||||
79
0004-fix-error-of-deleting-conn-table-in-connect.patch
Normal file
79
0004-fix-error-of-deleting-conn-table-in-connect.patch
Normal file
@ -0,0 +1,79 @@
|
||||
From ed999b65aac44fcb68fc533e8bd5a23cf2d09e7c Mon Sep 17 00:00:00 2001
|
||||
From: wuchangsheng <wuchangsheng2@huawei.com>
|
||||
Date: Wed, 26 May 2021 19:09:41 +0800
|
||||
Subject: [PATCH] fix-error-of-deleting-conn-table-in-connect
|
||||
|
||||
---
|
||||
src/include/lwip/priv/tcp_priv.h | 42 ++++++++++++++++++++++++++------
|
||||
1 file changed, 34 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h
|
||||
index 192edc4..599289f 100644
|
||||
--- a/src/include/lwip/priv/tcp_priv.h
|
||||
+++ b/src/include/lwip/priv/tcp_priv.h
|
||||
@@ -358,6 +358,28 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
|
||||
|
||||
return vdev_reg_xmit(reg_type, &qtuple);
|
||||
}
|
||||
+
|
||||
+/* TCP_RMV pcb whether to call vdev_reg_xmit to reg conn-sock table.
|
||||
+ fix the error of adding conn table in connect func and deleting conn table
|
||||
+ when moving pcb from tcp_bound_pcbs to tcp_listen_pcbs */
|
||||
+static inline int need_vdev_reg(struct tcp_pcb *pcb_list, const struct tcp_pcb *pcb)
|
||||
+{
|
||||
+ /* tw_pcbs_list and tcp_listen_pcbs will not change pcb to other list always reg */
|
||||
+ if ((pcb_list == tcp_tw_pcbs) || (pcb_list == tcp_listen_pcbs.pcbs)) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ /* tcp_active_pcbs in FIN_WAIT_1,FIN_WAIT_2,CLOSING state will change pcb to tw_pcbs_list don't reg.
|
||||
+ detail info see func tcp_process in tcp_in.c */
|
||||
+ if (pcb_list == tcp_active_pcbs) {
|
||||
+ if ((pcb->state != FIN_WAIT_1) && (pcb->state != FIN_WAIT_2) && (pcb->state != CLOSING)) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* tcp_bound_pcbs and others don't reg */
|
||||
+ return 0;
|
||||
+}
|
||||
#endif
|
||||
|
||||
/* Axioms about the above lists:
|
||||
@@ -392,10 +414,12 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
|
||||
tcp_timer_needed(); \
|
||||
} while(0)
|
||||
#define TCP_RMV(pcbs, npcb) do { \
|
||||
- if (pcb->state == LISTEN) \
|
||||
- vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
|
||||
- else \
|
||||
- vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb);\
|
||||
+ if (need_vdev_reg(*pcbs, npcb)) { \
|
||||
+ if (npcb->state == LISTEN) \
|
||||
+ vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
|
||||
+ else \
|
||||
+ vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb); \
|
||||
+ } \
|
||||
struct tcp_pcb *tcp_tmp_pcb; \
|
||||
LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \
|
||||
@@ -488,10 +512,12 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
|
||||
|
||||
#define TCP_RMV(pcbs, npcb) \
|
||||
do { \
|
||||
- if (pcb->state == LISTEN) \
|
||||
- vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
|
||||
- else \
|
||||
- vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb);\
|
||||
+ if (need_vdev_reg(*pcbs, npcb)) { \
|
||||
+ if (npcb->state == LISTEN) \
|
||||
+ vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
|
||||
+ else \
|
||||
+ vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb);\
|
||||
+ } \
|
||||
if(*(pcbs) == (npcb)) { \
|
||||
(*(pcbs)) = (*pcbs)->next; \
|
||||
if (*pcbs) \
|
||||
--
|
||||
2.23.0
|
||||
|
||||
27
0005-syn-rcvd-state-reg-conn-into-conntable.patch
Normal file
27
0005-syn-rcvd-state-reg-conn-into-conntable.patch
Normal file
@ -0,0 +1,27 @@
|
||||
From 19c51d7baf7eeeae72525f6b716253557be2b31c Mon Sep 17 00:00:00 2001
|
||||
From: wuchangsheng <wuchangsheng2@huawei.com>
|
||||
Date: Tue, 29 Jun 2021 14:12:25 +0800
|
||||
Subject: [PATCH] add-conn-check
|
||||
|
||||
---
|
||||
src/core/tcp_in.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
|
||||
index c3d1f54..57186c7 100644
|
||||
--- a/src/core/tcp_in.c
|
||||
+++ b/src/core/tcp_in.c
|
||||
@@ -752,6 +752,10 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
||||
#endif
|
||||
TCP_REG_ACTIVE(npcb);
|
||||
|
||||
+#if USE_LIBOS
|
||||
+ vdev_reg_done(REG_RING_TCP_CONNECT, npcb);
|
||||
+#endif
|
||||
+
|
||||
/* Parse any options in the SYN. */
|
||||
tcp_parseopt(npcb);
|
||||
npcb->snd_wnd = tcphdr->wnd;
|
||||
--
|
||||
2.23.0
|
||||
|
||||
29
0006-fix-coredump-in-etharp.patch
Normal file
29
0006-fix-coredump-in-etharp.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From a066306d783693d3f78b9c5e84feca7d690cf27a Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Fri, 2 Jul 2021 16:54:43 +0800
|
||||
Subject: [PATCH] fix coredump in etharp
|
||||
|
||||
---
|
||||
src/core/ipv4/etharp.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/core/ipv4/etharp.c b/src/core/ipv4/etharp.c
|
||||
index c3a5a10..effb7db 100644
|
||||
--- a/src/core/ipv4/etharp.c
|
||||
+++ b/src/core/ipv4/etharp.c
|
||||
@@ -102,10 +102,10 @@ struct etharp_entry {
|
||||
u8_t state;
|
||||
};
|
||||
|
||||
-static struct etharp_entry arp_table[ARP_TABLE_SIZE];
|
||||
+static PER_THREAD struct etharp_entry arp_table[ARP_TABLE_SIZE];
|
||||
|
||||
#if !LWIP_NETIF_HWADDRHINT
|
||||
-static netif_addr_idx_t etharp_cached_entry;
|
||||
+static PER_THREAD netif_addr_idx_t etharp_cached_entry;
|
||||
#endif /* !LWIP_NETIF_HWADDRHINT */
|
||||
|
||||
/** Try hard to create a new entry - we want the IP address to appear in
|
||||
--
|
||||
2.23.0
|
||||
|
||||
102
0007-gazelle-fix-epoll_ctl-EPOLLET-mode-error.patch
Normal file
102
0007-gazelle-fix-epoll_ctl-EPOLLET-mode-error.patch
Normal file
@ -0,0 +1,102 @@
|
||||
From b867f6901773def31884a9ae527a1282d274a85d Mon Sep 17 00:00:00 2001
|
||||
From: wuchangsheng <wuchangsheng2@huawei.com>
|
||||
Date: Sat, 10 Jul 2021 22:27:19 +0800
|
||||
Subject: [PATCH] fix epoll_ctl EPOLLET mode error
|
||||
---
|
||||
src/api/sockets.c | 33 +++++++++++++++++++++++----------
|
||||
1 file changed, 23 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index 658f762..eccc7f9 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -714,6 +714,13 @@ free_socket(struct lwip_sock *sock, int is_tcp)
|
||||
/* Protect socket array */
|
||||
SYS_ARCH_PROTECT(lev);
|
||||
|
||||
+#if USE_LIBOS
|
||||
+ sock->epoll = LIBOS_EPOLLNONE;
|
||||
+ sock->events = 0;
|
||||
+ sock->epoll_data = NULL;
|
||||
+ list_del_node_null(&sock->list);
|
||||
+#endif
|
||||
+
|
||||
freed = free_socket_locked(sock, is_tcp, &conn, &lastdata);
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
/* don't use 'sock' after this line, as another task might have allocated it */
|
||||
@@ -1003,13 +1010,6 @@ lwip_close(int s)
|
||||
return -1;
|
||||
}
|
||||
|
||||
-#if USE_LIBOS
|
||||
- sock->epoll = LIBOS_EPOLLNONE;
|
||||
- sock->events = 0;
|
||||
- sock->epoll_data = NULL;
|
||||
- list_del_node_null(&sock->list);
|
||||
-#endif
|
||||
-
|
||||
free_socket(sock, is_tcp);
|
||||
set_errno(0);
|
||||
return 0;
|
||||
@@ -1191,7 +1191,7 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
|
||||
if (sock->lastdata.pbuf) {
|
||||
p = sock->lastdata.pbuf;
|
||||
#if USE_LIBOS
|
||||
- if ((flags & MSG_PEEK) == 0) {
|
||||
+ if (((flags & MSG_PEEK) == 0) && ((sock->epoll & EPOLLET) == 0)) {
|
||||
if ((NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP)) {
|
||||
del_epoll_event(sock->conn, EPOLLIN);
|
||||
}
|
||||
@@ -2889,6 +2889,9 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
check_waiters = 0;
|
||||
}
|
||||
#if USE_LIBOS
|
||||
+ if (sock->epoll & EPOLLET) {
|
||||
+ list_del_node_null(&sock->list);
|
||||
+ }
|
||||
add_epoll_event(conn, EPOLLIN);
|
||||
#endif
|
||||
break;
|
||||
@@ -2896,7 +2899,9 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
sock->rcvevent--;
|
||||
check_waiters = 0;
|
||||
#if USE_LIBOS
|
||||
- del_epoll_event(conn, EPOLLIN);
|
||||
+ if ((sock->epoll & EPOLLET) == 0) {
|
||||
+ del_epoll_event(conn, EPOLLIN);
|
||||
+ }
|
||||
#endif
|
||||
break;
|
||||
case NETCONN_EVT_SENDPLUS:
|
||||
@@ -2905,6 +2910,9 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
}
|
||||
sock->sendevent = 1;
|
||||
#if USE_LIBOS
|
||||
+ if (sock->epoll & EPOLLET) {
|
||||
+ list_del_node_null(&sock->list);
|
||||
+ }
|
||||
add_epoll_event(conn, EPOLLOUT);
|
||||
#endif
|
||||
break;
|
||||
@@ -2912,12 +2920,17 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
sock->sendevent = 0;
|
||||
check_waiters = 0;
|
||||
#if USE_LIBOS
|
||||
- del_epoll_event(conn, EPOLLOUT);
|
||||
+ if ((sock->epoll & EPOLLET) == 0) {
|
||||
+ del_epoll_event(conn, EPOLLOUT);
|
||||
+ }
|
||||
#endif
|
||||
break;
|
||||
case NETCONN_EVT_ERROR:
|
||||
sock->errevent = 1;
|
||||
#if USE_LIBOS
|
||||
+ if (sock->epoll & EPOLLET) {
|
||||
+ list_del_node_null(&sock->list);
|
||||
+ }
|
||||
add_epoll_event(conn, EPOLLERR);
|
||||
#endif
|
||||
break;
|
||||
--
|
||||
2.23.0
|
||||
|
||||
25
0008-gazelle-fix-lwip_accept-memcpy-sockaddr-large.patch
Normal file
25
0008-gazelle-fix-lwip_accept-memcpy-sockaddr-large.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From bf1c7febb9f6c3a2336f18f658694393dea451ae Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Fri, 16 Jul 2021 14:44:03 +0800
|
||||
Subject: [PATCH] [Huawei]gazelle: fix lwip_accept memcpy sockaddr larger than
|
||||
actual
|
||||
---
|
||||
src/api/sockets.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index eccc7f9..e640945 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -860,6 +860,8 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
if (*addrlen > tempaddr.sa.sa_len) {
|
||||
*addrlen = tempaddr.sa.sa_len;
|
||||
}
|
||||
+#else
|
||||
+ *addrlen = LWIP_MIN(*addrlen, sizeof(tempaddr));
|
||||
#endif /* USE_LIBOS */
|
||||
MEMCPY(addr, &tempaddr, *addrlen);
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
35
0009-fix-stack-buffer-overflow-when-memcpy-addr.patch
Normal file
35
0009-fix-stack-buffer-overflow-when-memcpy-addr.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From d1f9ccd5da1712477f30bf2662e8888395ed95cd Mon Sep 17 00:00:00 2001
|
||||
From: wuchangsheng <wuchangsheng2@huawei.com>
|
||||
Date: Wed, 21 Jul 2021 20:01:47 +0800
|
||||
Subject: [PATCH] fix stack-buffer-overflow in lwip_sock_make_addr and
|
||||
lwip_getaddrname
|
||||
|
||||
---
|
||||
src/api/sockets.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index e640945..7ce9378 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -1319,6 +1319,8 @@ lwip_sock_make_addr(struct netconn *conn, ip_addr_t *fromaddr, u16_t port,
|
||||
} else if (*fromlen > saddr.sa.sa_len) {
|
||||
*fromlen = saddr.sa.sa_len;
|
||||
}
|
||||
+#else
|
||||
+ *fromlen = LWIP_MIN(*fromlen, sizeof(saddr));
|
||||
#endif
|
||||
MEMCPY(from, &saddr, *fromlen);
|
||||
return truncated;
|
||||
@@ -3133,6 +3135,8 @@ lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
|
||||
if (*namelen > saddr.sa.sa_len) {
|
||||
*namelen = saddr.sa.sa_len;
|
||||
}
|
||||
+#else
|
||||
+ *namelen = LWIP_MIN(*namelen, sizeof(saddr));
|
||||
#endif
|
||||
MEMCPY(name, &saddr, *namelen);
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
115
0010-fix-the-incomplete-release-of-the-conntable.patch
Normal file
115
0010-fix-the-incomplete-release-of-the-conntable.patch
Normal file
@ -0,0 +1,115 @@
|
||||
From 70a1cdd2618f117c9f7da17b111a6c51db242f4b Mon Sep 17 00:00:00 2001
|
||||
From: wuchangsheng <wuchangsheng2@huawei.com>
|
||||
Date: Tue, 3 Aug 2021 11:23:10 +0800
|
||||
Subject: [PATCH] fix-the-incomplete-release-of-the-conntable
|
||||
|
||||
---
|
||||
src/core/tcp.c | 12 +++++++++++
|
||||
src/include/lwip/priv/tcp_priv.h | 37 ++++++--------------------------
|
||||
2 files changed, 19 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/src/core/tcp.c b/src/core/tcp.c
|
||||
index 0aafa9b..2cfbce2 100644
|
||||
--- a/src/core/tcp.c
|
||||
+++ b/src/core/tcp.c
|
||||
@@ -235,6 +235,9 @@ tcp_init(void)
|
||||
void
|
||||
tcp_free(struct tcp_pcb *pcb)
|
||||
{
|
||||
+#if USE_LIBOS
|
||||
+ vdev_unreg_done(pcb);
|
||||
+#endif
|
||||
LWIP_ASSERT("tcp_free: LISTEN", pcb->state != LISTEN);
|
||||
#if LWIP_TCP_PCB_NUM_EXT_ARGS
|
||||
tcp_ext_arg_invoke_callbacks_destroyed(pcb->ext_args);
|
||||
@@ -943,6 +946,11 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
|
||||
#if LWIP_TCP_PCB_NUM_EXT_ARGS
|
||||
/* copy over ext_args to listening pcb */
|
||||
memcpy(&lpcb->ext_args, &pcb->ext_args, sizeof(pcb->ext_args));
|
||||
+#endif
|
||||
+#if USE_LIBOS
|
||||
+ /* pcb transfer to lpcb and reg into tcp_listen_pcbs. freeing pcb shouldn't release sock table in here.
|
||||
+ * local_port=0 avoid to release sock table in tcp_free */
|
||||
+ pcb->local_port = 0;
|
||||
#endif
|
||||
tcp_free(pcb);
|
||||
#if LWIP_CALLBACK_API
|
||||
@@ -2263,6 +2271,10 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
|
||||
LWIP_ASSERT("tcp_pcb_remove: invalid pcb", pcb != NULL);
|
||||
LWIP_ASSERT("tcp_pcb_remove: invalid pcblist", pcblist != NULL);
|
||||
|
||||
+#if USE_LIBOS
|
||||
+ vdev_unreg_done(pcb);
|
||||
+#endif
|
||||
+
|
||||
TCP_RMV(pcblist, pcb);
|
||||
|
||||
tcp_pcb_purge(pcb);
|
||||
diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h
|
||||
index 599289f..f771725 100644
|
||||
--- a/src/include/lwip/priv/tcp_priv.h
|
||||
+++ b/src/include/lwip/priv/tcp_priv.h
|
||||
@@ -358,27 +358,16 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
|
||||
|
||||
return vdev_reg_xmit(reg_type, &qtuple);
|
||||
}
|
||||
-
|
||||
-/* TCP_RMV pcb whether to call vdev_reg_xmit to reg conn-sock table.
|
||||
- fix the error of adding conn table in connect func and deleting conn table
|
||||
- when moving pcb from tcp_bound_pcbs to tcp_listen_pcbs */
|
||||
-static inline int need_vdev_reg(struct tcp_pcb *pcb_list, const struct tcp_pcb *pcb)
|
||||
+static inline void vdev_unreg_done(const struct tcp_pcb *pcb)
|
||||
{
|
||||
- /* tw_pcbs_list and tcp_listen_pcbs will not change pcb to other list always reg */
|
||||
- if ((pcb_list == tcp_tw_pcbs) || (pcb_list == tcp_listen_pcbs.pcbs)) {
|
||||
- return 1;
|
||||
+ if (pcb->local_port == 0) {
|
||||
+ return;
|
||||
}
|
||||
-
|
||||
- /* tcp_active_pcbs in FIN_WAIT_1,FIN_WAIT_2,CLOSING state will change pcb to tw_pcbs_list don't reg.
|
||||
- detail info see func tcp_process in tcp_in.c */
|
||||
- if (pcb_list == tcp_active_pcbs) {
|
||||
- if ((pcb->state != FIN_WAIT_1) && (pcb->state != FIN_WAIT_2) && (pcb->state != CLOSING)) {
|
||||
- return 1;
|
||||
- }
|
||||
+ if (pcb->state == LISTEN) {
|
||||
+ vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, pcb);
|
||||
+ } else {
|
||||
+ vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, pcb);
|
||||
}
|
||||
-
|
||||
- /* tcp_bound_pcbs and others don't reg */
|
||||
- return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -414,12 +403,6 @@ static inline int need_vdev_reg(struct tcp_pcb *pcb_list, const struct tcp_pcb *
|
||||
tcp_timer_needed(); \
|
||||
} while(0)
|
||||
#define TCP_RMV(pcbs, npcb) do { \
|
||||
- if (need_vdev_reg(*pcbs, npcb)) { \
|
||||
- if (npcb->state == LISTEN) \
|
||||
- vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
|
||||
- else \
|
||||
- vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb); \
|
||||
- } \
|
||||
struct tcp_pcb *tcp_tmp_pcb; \
|
||||
LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \
|
||||
@@ -512,12 +495,6 @@ static inline int need_vdev_reg(struct tcp_pcb *pcb_list, const struct tcp_pcb *
|
||||
|
||||
#define TCP_RMV(pcbs, npcb) \
|
||||
do { \
|
||||
- if (need_vdev_reg(*pcbs, npcb)) { \
|
||||
- if (npcb->state == LISTEN) \
|
||||
- vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
|
||||
- else \
|
||||
- vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb);\
|
||||
- } \
|
||||
if(*(pcbs) == (npcb)) { \
|
||||
(*(pcbs)) = (*pcbs)->next; \
|
||||
if (*pcbs) \
|
||||
--
|
||||
2.23.0
|
||||
|
||||
116
0011-remove-gazelle-tcp-conn-func.patch
Normal file
116
0011-remove-gazelle-tcp-conn-func.patch
Normal file
@ -0,0 +1,116 @@
|
||||
From fdccb3a2c430c6270ff5272220cf471bf760fda7 Mon Sep 17 00:00:00 2001
|
||||
From: wuchangsheng <wuchangsheng2@huawei.com>
|
||||
Date: Sat, 21 Aug 2021 15:22:52 +0800
|
||||
Subject: [PATCH] del tcp_conn
|
||||
|
||||
---
|
||||
src/core/tcp.c | 78 ------------------------------------------
|
||||
src/include/lwip/tcp.h | 3 --
|
||||
2 files changed, 81 deletions(-)
|
||||
|
||||
diff --git a/src/core/tcp.c b/src/core/tcp.c
|
||||
index 2cfbce2..0f3e830 100644
|
||||
--- a/src/core/tcp.c
|
||||
+++ b/src/core/tcp.c
|
||||
@@ -2484,84 +2484,6 @@ tcp_tcp_get_tcp_addrinfo(struct tcp_pcb *pcb, int local, ip_addr_t *addr, u16_t
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
-uint32_t tcp_get_conn_num(void)
|
||||
-{
|
||||
- struct tcp_pcb *pcb = NULL;
|
||||
- struct tcp_pcb_listen *pcbl = NULL;
|
||||
- uint32_t conn_num = 0;
|
||||
-
|
||||
- for (pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
- conn_num++;
|
||||
- }
|
||||
-
|
||||
- for (pcbl = tcp_listen_pcbs.listen_pcbs; pcbl != NULL; pcbl = pcbl->next) {
|
||||
- conn_num++;
|
||||
- }
|
||||
-
|
||||
- for (pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
- conn_num++;
|
||||
- }
|
||||
-
|
||||
- return conn_num;
|
||||
-}
|
||||
-
|
||||
-void tcp_get_conn(char *buf, int32_t len, uint32_t *conn_num)
|
||||
-{
|
||||
- int tmp_len = 0;
|
||||
- char *tmp_buf = buf;
|
||||
- struct tcp_pcb_dp tdp;
|
||||
- struct tcp_pcb *pcb = NULL;
|
||||
- struct tcp_pcb_listen *pcbl = NULL;
|
||||
-
|
||||
-#define COPY_TDP(b, l) \
|
||||
- do { \
|
||||
- if (l + sizeof(tdp) <= len) { \
|
||||
- memcpy(b, &tdp, sizeof(tdp)); \
|
||||
- b += sizeof(tdp); \
|
||||
- l += sizeof(tdp); \
|
||||
- *conn_num += 1; \
|
||||
- } else \
|
||||
- return; \
|
||||
- } while(0);
|
||||
-
|
||||
- *conn_num = 0;
|
||||
-
|
||||
- for (pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
- tdp.state = ACTIVE_LIST;
|
||||
- tdp.lip = pcb->local_ip.addr;
|
||||
- tdp.rip = pcb->remote_ip.addr;
|
||||
- tdp.l_port = pcb->local_port;
|
||||
- tdp.r_port = pcb->remote_port;
|
||||
- tdp.s_next = pcb->snd_queuelen;
|
||||
- /* lwip not cache rcv buf. Set it to 0. */
|
||||
- tdp.r_next = 0;
|
||||
- tdp.tcp_sub_state = pcb->state;
|
||||
- COPY_TDP(tmp_buf, tmp_len);
|
||||
- }
|
||||
-
|
||||
- for (pcbl = tcp_listen_pcbs.listen_pcbs; pcbl != NULL; pcbl = pcbl->next) {
|
||||
- tdp.state = LISTEN_LIST;
|
||||
- tdp.lip = pcbl->local_ip.addr;
|
||||
- tdp.rip = pcbl->remote_ip.addr;
|
||||
- tdp.l_port = pcbl->local_port;
|
||||
- tdp.tcp_sub_state = pcbl->state;
|
||||
- COPY_TDP(tmp_buf, tmp_len);
|
||||
- }
|
||||
-
|
||||
- for (pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||
- tdp.state = TIME_WAIT_LIST;
|
||||
- tdp.lip = pcb->local_ip.addr;
|
||||
- tdp.rip = pcb->remote_ip.addr;
|
||||
- tdp.l_port = pcb->local_port;
|
||||
- tdp.r_port = pcb->remote_port;
|
||||
- tdp.s_next = pcb->snd_queuelen;
|
||||
- /* lwip not cache rcv buf. Set it to 0. */
|
||||
- tdp.r_next = 0;
|
||||
- tdp.tcp_sub_state = pcb->state;
|
||||
- COPY_TDP(tmp_buf, tmp_len);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
#if TCP_QUEUE_OOSEQ
|
||||
/* Free all ooseq pbufs (and possibly reset SACK state) */
|
||||
void
|
||||
diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h
|
||||
index 4f86b46..b36bf33 100644
|
||||
--- a/src/include/lwip/tcp.h
|
||||
+++ b/src/include/lwip/tcp.h
|
||||
@@ -570,9 +570,6 @@ struct tcp_pcb_dp {
|
||||
uint32_t tcp_sub_state;
|
||||
};
|
||||
|
||||
-void tcp_get_conn(char *buf, int32_t len, uint32_t *conn_num);
|
||||
-uint32_t tcp_get_conn_num(void);
|
||||
-
|
||||
/* for compatibility with older implementation */
|
||||
#define tcp_new_ip6() tcp_new_ip_type(IPADDR_TYPE_V6)
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
49
0012-fix-incomplete-resource-release-in-lwip-close.patch
Normal file
49
0012-fix-incomplete-resource-release-in-lwip-close.patch
Normal file
@ -0,0 +1,49 @@
|
||||
From c5db70bef7f1ac6627b278fdf06be57bce0ef00b Mon Sep 17 00:00:00 2001
|
||||
From: wuchangsheng <wuchangsheng2@huawei.com>
|
||||
Date: Thu, 19 Aug 2021 14:53:14 +0800
|
||||
Subject: [PATCH] fix event.data.ptr double free due to socket don't free in
|
||||
lwip_close
|
||||
|
||||
---
|
||||
src/api/sockets.c | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index 7ce9378..ac4cccb 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -963,18 +963,20 @@ lwip_close(int s)
|
||||
struct lwip_sock *sock;
|
||||
int is_tcp = 0;
|
||||
err_t err;
|
||||
+ int ret = 0;
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
|
||||
|
||||
#if USE_LIBOS
|
||||
- int ret;
|
||||
if (posix_api->is_epfd(s)) {
|
||||
return posix_api->epoll_close_fn(s);
|
||||
}
|
||||
|
||||
+ /* No matter what the result of close, lwip_sock resources should release
|
||||
+ * to prevent the potential double freee problem caused by reporting events after the close */
|
||||
ret = posix_api->close_fn(s);
|
||||
- if (ret < 0)
|
||||
- return ret;
|
||||
+ if ((ret < 0) && (errno == EINTR))
|
||||
+ ret = posix_api->close_fn(s);
|
||||
if (posix_api->is_chld == 0)
|
||||
clean_host_fd(s);
|
||||
|
||||
@@ -1014,7 +1016,7 @@ lwip_close(int s)
|
||||
|
||||
free_socket(sock, is_tcp);
|
||||
set_errno(0);
|
||||
- return 0;
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
int
|
||||
--
|
||||
2.23.0
|
||||
126
0013-remove-gazelle-syscall-thread.patch
Normal file
126
0013-remove-gazelle-syscall-thread.patch
Normal file
@ -0,0 +1,126 @@
|
||||
From afd0d39d31196a74d6808120d1ca5664825d477c Mon Sep 17 00:00:00 2001
|
||||
From: wuchangsheng <wuchangsheng2@huawei.com>
|
||||
Date: Mon, 6 Sep 2021 22:52:41 +0800
|
||||
Subject: [PATCH] aaa
|
||||
|
||||
---
|
||||
src/api/sockets.c | 17 -----------------
|
||||
src/include/eventpoll.h | 1 -
|
||||
src/include/lwipopts.h | 17 -----------------
|
||||
src/include/lwipsock.h | 5 -----
|
||||
4 files changed, 40 deletions(-)
|
||||
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index ac4cccb..8719568 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -755,10 +755,6 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
sock = posix_api->get_socket(s);
|
||||
/*AF_UNIX case*/
|
||||
if (!sock) {
|
||||
- if (rearm_accept_fd(s) < 0) {
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG,
|
||||
- ("failed to rearm accept fd=%d errno=%d\n", s, errno));
|
||||
- }
|
||||
return posix_api->accept_fn(s, addr, addrlen);
|
||||
}
|
||||
|
||||
@@ -769,11 +765,6 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- if (rearm_accept_fd(s) < 0) {
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG,
|
||||
- ("failed to rearm accept fd=%d errno=%d\n", s, errno));
|
||||
- }
|
||||
-
|
||||
/* raise accept syscall in palce */
|
||||
newsock = posix_api->accept_fn(s, addr, addrlen);
|
||||
if (newsock >= 0) {
|
||||
@@ -977,8 +968,6 @@ lwip_close(int s)
|
||||
ret = posix_api->close_fn(s);
|
||||
if ((ret < 0) && (errno == EINTR))
|
||||
ret = posix_api->close_fn(s);
|
||||
- if (posix_api->is_chld == 0)
|
||||
- clean_host_fd(s);
|
||||
|
||||
sock = posix_api->get_socket(s);
|
||||
/*AF_UNIX case*/
|
||||
@@ -1481,9 +1470,6 @@ static inline enum KERNEL_LWIP_PATH select_path(int s)
|
||||
sock = posix_api->get_socket(s);
|
||||
/*AF_UNIX case*/
|
||||
if (!sock) {
|
||||
- if (rearm_host_fd(s) < 0) {
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG, ("failed to rearm fd=%d errno=%d\n", s, errno));
|
||||
- }
|
||||
return PATH_KERNEL;
|
||||
}
|
||||
|
||||
@@ -1494,9 +1480,6 @@ static inline enum KERNEL_LWIP_PATH select_path(int s)
|
||||
|
||||
/*for AF_INET, we can try erther linux or lwip*/
|
||||
if (CONN_TYPE_IS_HOST(sock->conn)) {
|
||||
- if (rearm_host_fd(s) < 0) {
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG, ("failed to rearm read fd=%d errno=%d\n", s, errno));
|
||||
- }
|
||||
return PATH_KERNEL;
|
||||
}
|
||||
|
||||
diff --git a/src/include/eventpoll.h b/src/include/eventpoll.h
|
||||
index 01f8d64..f525bc2 100644
|
||||
--- a/src/include/eventpoll.h
|
||||
+++ b/src/include/eventpoll.h
|
||||
@@ -57,7 +57,6 @@ struct event_array {
|
||||
|
||||
struct libos_epoll {
|
||||
struct event_queue *libos_queue;
|
||||
- struct event_array *host_queue;
|
||||
int num_hostfds;
|
||||
int hints;
|
||||
int fd; /* self fd */
|
||||
diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h
|
||||
index 8893a5f..e0364a2 100644
|
||||
--- a/src/include/lwipopts.h
|
||||
+++ b/src/include/lwipopts.h
|
||||
@@ -177,23 +177,6 @@
|
||||
|
||||
#define ARP_TABLE_SIZE 512
|
||||
|
||||
-/*
|
||||
- ---------------------------------------
|
||||
- ------- Syscall thread options --------
|
||||
- ---------------------------------------
|
||||
-*/
|
||||
-#define USE_SYSCALL_THREAD 1
|
||||
-
|
||||
-#define MAX_BLOCKING_ACCEPT_FD (100)
|
||||
-
|
||||
-#define MAX_BLOCKING_CONNECT_FD (100)
|
||||
-
|
||||
-#define MAX_BLOCKING_EPOLL_FD (100)
|
||||
-
|
||||
-#define MAX_SYSCALL_EVENTS (MAX_BLOCKING_ACCEPT_FD + MAX_BLOCKING_CONNECT_FD + MAX_BLOCKING_EPOLL_FD)
|
||||
-
|
||||
-#define MAX_HOST_FD (MAX_CLIENTS + RESERVED_CLIENTS)
|
||||
-
|
||||
#if USE_LIBOS
|
||||
#define PER_THREAD __thread
|
||||
#else
|
||||
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
|
||||
index dbc67b9..e9ffbb1 100644
|
||||
--- a/src/include/lwipsock.h
|
||||
+++ b/src/include/lwipsock.h
|
||||
@@ -146,10 +146,5 @@ void lwip_sock_init(void);
|
||||
void lwip_exit(void);
|
||||
|
||||
extern int is_host_ipv4(uint32_t ipv4);
|
||||
-extern int rearm_host_fd(int fd);
|
||||
-extern int rearm_accept_fd(int fd);
|
||||
-extern void unarm_host_fd(int fd);
|
||||
-extern void clean_host_fd(int fd);
|
||||
-extern int arm_host_fd(struct libos_epoll *ep, int op, int fd, struct epoll_event *event);
|
||||
|
||||
#endif /* __LWIPSOCK_H__ */
|
||||
--
|
||||
2.23.0
|
||||
|
||||
62
0014-fix-some-compile-errors.patch
Normal file
62
0014-fix-some-compile-errors.patch
Normal file
@ -0,0 +1,62 @@
|
||||
From 4970d00fecf52a472a28d55243f87142d3d08268 Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Tue, 4 Jan 2022 17:23:03 +0800
|
||||
Subject: [PATCH] fix some compile errors
|
||||
|
||||
---
|
||||
src/include/arch/cc.h | 4 ++--
|
||||
src/include/lwiplog.h | 2 +-
|
||||
src/include/posix_api.h | 2 +-
|
||||
3 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/include/arch/cc.h b/src/include/arch/cc.h
|
||||
index 33c24b4..222b0c9 100644
|
||||
--- a/src/include/arch/cc.h
|
||||
+++ b/src/include/arch/cc.h
|
||||
@@ -62,7 +62,7 @@ void alloc_memp_##name##_base(void) \
|
||||
memp_pools[MEMP_##name] = &memp_ ## name; \
|
||||
\
|
||||
char mpname[MEMZONE_NAMESIZE] = {0}; \
|
||||
- snprintf(mpname, MEMZONE_NAMESIZE, "%ld_%s", gettid(), #name); \
|
||||
+ snprintf(mpname, MEMZONE_NAMESIZE, "%d_%s", gettid(), #name); \
|
||||
memp_memory_##name##_base = \
|
||||
sys_hugepage_malloc(mpname, LWIP_MEM_ALIGN_BUFFER(__size)); \
|
||||
memp_pools[MEMP_##name]->base = memp_memory_##name##_base; \
|
||||
@@ -73,7 +73,7 @@ PER_THREAD uint8_t *variable_name; \
|
||||
void alloc_memory_##variable_name(void) \
|
||||
{ \
|
||||
char mpname[MEMZONE_NAMESIZE] = {0}; \
|
||||
- snprintf(mpname, MEMZONE_NAMESIZE, "%ld_%s", gettid(), #variable_name); \
|
||||
+ snprintf(mpname, MEMZONE_NAMESIZE, "%d_%s", gettid(), #variable_name); \
|
||||
(variable_name) = \
|
||||
sys_hugepage_malloc(mpname, LWIP_MEM_ALIGN_BUFFER(size)); \
|
||||
}
|
||||
diff --git a/src/include/lwiplog.h b/src/include/lwiplog.h
|
||||
index 363e516..6fccac8 100644
|
||||
--- a/src/include/lwiplog.h
|
||||
+++ b/src/include/lwiplog.h
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include "lwipopts.h"
|
||||
|
||||
-#define gettid() syscall(__NR_gettid)
|
||||
+extern int gettid(void);
|
||||
|
||||
#if USE_DPDK_LOG
|
||||
|
||||
diff --git a/src/include/posix_api.h b/src/include/posix_api.h
|
||||
index 8aa8516..0dca8eb 100644
|
||||
--- a/src/include/posix_api.h
|
||||
+++ b/src/include/posix_api.h
|
||||
@@ -79,7 +79,7 @@ typedef struct {
|
||||
int is_chld;
|
||||
} posix_api_t;
|
||||
|
||||
-posix_api_t *posix_api;
|
||||
+extern posix_api_t *posix_api;
|
||||
|
||||
int posix_api_init(void);
|
||||
void posix_api_free(void);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
36
0015-fix-tcp-port-alloc-issue.patch
Normal file
36
0015-fix-tcp-port-alloc-issue.patch
Normal file
@ -0,0 +1,36 @@
|
||||
From bd0fdaf755544da1a276820a7cc3f664a2765194 Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Tue, 18 Jan 2022 10:34:42 +0800
|
||||
Subject: [PATCH] fix tcp port alloc issue
|
||||
|
||||
---
|
||||
src/core/tcp.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/core/tcp.c b/src/core/tcp.c
|
||||
index a9a91fd..b65ab33 100644
|
||||
--- a/src/core/tcp.c
|
||||
+++ b/src/core/tcp.c
|
||||
@@ -1062,6 +1062,7 @@ tcp_new_port(void)
|
||||
{
|
||||
u8_t i;
|
||||
u16_t n = 0;
|
||||
+ u16_t tmp_port;
|
||||
struct tcp_pcb *pcb;
|
||||
|
||||
pthread_mutex_lock(&g_tcp_port_mutex);
|
||||
@@ -1082,9 +1083,10 @@ again:
|
||||
}
|
||||
}
|
||||
}
|
||||
+ tmp_port = tcp_port;
|
||||
pthread_mutex_unlock(&g_tcp_port_mutex);
|
||||
|
||||
- return tcp_port;
|
||||
+ return tmp_port;
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
943
0016-lstack-support-mysql-mode.patch
Normal file
943
0016-lstack-support-mysql-mode.patch
Normal file
@ -0,0 +1,943 @@
|
||||
From 1f0f3742019e2fa62ba1669c5a880fb63a3fee12 Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Thu, 24 Feb 2022 20:08:46 +0800
|
||||
Subject: [PATCH] lstack support mysql mode
|
||||
|
||||
---
|
||||
src/api/api_msg.c | 26 +--
|
||||
src/api/posix_api.c | 5 +-
|
||||
src/api/sockets.c | 350 ++-----------------------------
|
||||
src/api/sys_arch.c | 12 +-
|
||||
src/core/tcp_out.c | 13 ++
|
||||
src/include/eventpoll.h | 6 +-
|
||||
src/include/lwip/priv/tcp_priv.h | 2 +-
|
||||
src/include/lwip/sockets.h | 2 +-
|
||||
src/include/lwipsock.h | 29 ++-
|
||||
src/include/posix_api.h | 2 +-
|
||||
src/include/reg_sock.h | 8 +-
|
||||
11 files changed, 85 insertions(+), 370 deletions(-)
|
||||
|
||||
diff --git a/src/api/api_msg.c b/src/api/api_msg.c
|
||||
index d5a738f..3072dd9 100644
|
||||
--- a/src/api/api_msg.c
|
||||
+++ b/src/api/api_msg.c
|
||||
@@ -342,6 +342,12 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||
#endif /* LWIP_SO_RCVBUF */
|
||||
/* Register event with callback */
|
||||
API_EVENT(conn, NETCONN_EVT_RCVPLUS, len);
|
||||
+#if USE_LIBOS
|
||||
+ if (conn->state == NETCONN_WRITE || conn->state == NETCONN_CLOSE ||
|
||||
+ conn->state == NETCONN_CONNECT) {
|
||||
+ add_recv_list(conn->socket);
|
||||
+ }
|
||||
+#endif
|
||||
}
|
||||
|
||||
return ERR_OK;
|
||||
@@ -457,14 +463,6 @@ err_tcp(void *arg, err_t err)
|
||||
old_state = conn->state;
|
||||
conn->state = NETCONN_NONE;
|
||||
|
||||
-#if USE_LIBOS
|
||||
- if (CONN_TYPE_IS_HOST(conn)) {
|
||||
- LWIP_DEBUGF(API_MSG_DEBUG,
|
||||
- ("linux localhost connection already success, ignore lwip err_tcp fd=%d\n", conn->socket));
|
||||
- return;
|
||||
- }
|
||||
-#endif /* USE_LIBOS */
|
||||
-
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
|
||||
/* Notify the user layer about a connection error. Used to signal select. */
|
||||
@@ -479,6 +477,12 @@ err_tcp(void *arg, err_t err)
|
||||
if (NETCONN_MBOX_VALID(conn, &conn->recvmbox)) {
|
||||
/* use trypost to prevent deadlock */
|
||||
sys_mbox_trypost(&conn->recvmbox, mbox_msg);
|
||||
+#if USE_LIBOS
|
||||
+ if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) ||
|
||||
+ (old_state == NETCONN_CONNECT)) {
|
||||
+ add_recv_list(conn->socket);
|
||||
+ }
|
||||
+#endif
|
||||
}
|
||||
/* pass error message to acceptmbox to wake up pending accept */
|
||||
if (NETCONN_MBOX_VALID(conn, &conn->acceptmbox)) {
|
||||
@@ -1344,11 +1348,7 @@ lwip_netconn_do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
int s = conn->socket;
|
||||
struct lwip_sock *sock = get_socket_without_errno(s);
|
||||
|
||||
- if (!!sock && !!sock->epoll_data) {
|
||||
- struct epoll_event ee = {0};
|
||||
- ee.data.fd = s;
|
||||
- ee.events |= EPOLLIN | EPOLLOUT | EPOLLERR;
|
||||
- posix_api->epoll_ctl_fn(sock->epoll_data->fd, EPOLL_CTL_DEL, s, &ee);
|
||||
+ if (!!sock) {
|
||||
posix_api->shutdown_fn(s, SHUT_RDWR);
|
||||
LWIP_DEBUGF(API_MSG_DEBUG,
|
||||
("linux outgoing connection abort fd=%d\n", s));
|
||||
diff --git a/src/api/posix_api.c b/src/api/posix_api.c
|
||||
index a917cea..eff9f46 100644
|
||||
--- a/src/api/posix_api.c
|
||||
+++ b/src/api/posix_api.c
|
||||
@@ -143,11 +143,10 @@ int posix_api_init(void)
|
||||
|
||||
/* lstack helper api */
|
||||
posix_api->get_socket = get_socket;
|
||||
- posix_api->is_epfd = lwip_is_epfd;
|
||||
- posix_api->epoll_close_fn = lwip_epoll_close;
|
||||
+ posix_api->epoll_close_fn = lstack_epoll_close;
|
||||
|
||||
/* support fork */
|
||||
- posix_api->is_chld = 0;
|
||||
+ posix_api->is_chld = 1;
|
||||
return ERR_OK;
|
||||
|
||||
err_out:
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index f44c34f..b032ce9 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -90,14 +90,6 @@
|
||||
#define API_SELECT_CB_VAR_ALLOC(name, retblock) API_VAR_ALLOC_EXT(struct lwip_select_cb, MEMP_SELECT_CB, name, retblock)
|
||||
#define API_SELECT_CB_VAR_FREE(name) API_VAR_FREE(MEMP_SELECT_CB, name)
|
||||
|
||||
-#if USE_LIBOS
|
||||
-enum KERNEL_LWIP_PATH {
|
||||
- PATH_KERNEL = 0,
|
||||
- PATH_LWIP,
|
||||
- PATH_ERR,
|
||||
-};
|
||||
-#endif
|
||||
-
|
||||
#if LWIP_IPV4
|
||||
#if USE_LIBOS
|
||||
#define IP4ADDR_PORT_TO_SOCKADDR(sin, ipaddr, port) do { \
|
||||
@@ -604,8 +596,6 @@ alloc_socket(struct netconn *newconn, int accepted)
|
||||
* (unless it has been created by accept()). */
|
||||
sockets[i].sendevent = (NETCONNTYPE_GROUP(newconn->type) == NETCONN_TCP ? (accepted != 0) : 1);
|
||||
sockets[i].errevent = 0;
|
||||
- sockets[i].epoll_data = NULL;
|
||||
- init_list_node_null(&sockets[i].list);
|
||||
return i + LWIP_SOCKET_OFFSET;
|
||||
}
|
||||
|
||||
@@ -714,13 +704,6 @@ free_socket(struct lwip_sock *sock, int is_tcp)
|
||||
/* Protect socket array */
|
||||
SYS_ARCH_PROTECT(lev);
|
||||
|
||||
-#if USE_LIBOS
|
||||
- sock->epoll = LIBOS_EPOLLNONE;
|
||||
- sock->events = 0;
|
||||
- sock->epoll_data = NULL;
|
||||
- list_del_node_null(&sock->list);
|
||||
-#endif
|
||||
-
|
||||
freed = free_socket_locked(sock, is_tcp, &conn, &lastdata);
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
/* don't use 'sock' after this line, as another task might have allocated it */
|
||||
@@ -749,34 +732,11 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
SYS_ARCH_DECL_PROTECT(lev);
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s));
|
||||
-#if USE_LIBOS
|
||||
- int sys_errno = 0;
|
||||
-
|
||||
- sock = posix_api->get_socket(s);
|
||||
- /*AF_UNIX case*/
|
||||
- if (!sock) {
|
||||
- return posix_api->accept_fn(s, addr, addrlen);
|
||||
- }
|
||||
-
|
||||
- /*for AF_INET, we may try both linux and lwip*/
|
||||
- if (!CONN_TYPE_HAS_LIBOS_AND_HOST(sock->conn)) {
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG, ("conn->type has libos and host bits"));
|
||||
- set_errno(EINVAL);
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- /* raise accept syscall in palce */
|
||||
- newsock = posix_api->accept_fn(s, addr, addrlen);
|
||||
- if (newsock >= 0) {
|
||||
- return newsock;
|
||||
- }
|
||||
- sys_errno = errno;
|
||||
-#else
|
||||
+
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
-#endif
|
||||
|
||||
/* wait for a new connection */
|
||||
err = netconn_accept(sock->conn, &newconn);
|
||||
@@ -790,9 +750,6 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
sock_set_errno(sock, err_to_errno(err));
|
||||
}
|
||||
done_socket(sock);
|
||||
-#if USE_LIBOS
|
||||
- set_errno(sys_errno);
|
||||
-#endif /* USE_LIBOS */
|
||||
return -1;
|
||||
}
|
||||
LWIP_ASSERT("newconn != NULL", newconn != NULL);
|
||||
@@ -875,24 +832,11 @@ lwip_bind(int s, const struct sockaddr *name, socklen_t namelen)
|
||||
ip_addr_t local_addr;
|
||||
u16_t local_port;
|
||||
err_t err;
|
||||
-#if USE_LIBOS
|
||||
- sock = posix_api->get_socket(s);
|
||||
- /*AF_UNIX case*/
|
||||
- if (!sock) {
|
||||
- return posix_api->bind_fn(s, name, namelen);
|
||||
- }
|
||||
- /*for AF_INET, we may try both linux and lwip*/
|
||||
- if (!CONN_TYPE_HAS_LIBOS_AND_HOST(sock->conn)) {
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG, ("conn->type has libos and host bits"));
|
||||
- set_errno(EINVAL);
|
||||
- return -1;
|
||||
- }
|
||||
-#else
|
||||
+
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
-#endif
|
||||
|
||||
if (!SOCK_ADDR_TYPE_MATCH(name, sock)) {
|
||||
/* sockaddr does not match socket type (IPv4/IPv6) */
|
||||
@@ -912,18 +856,6 @@ lwip_bind(int s, const struct sockaddr *name, socklen_t namelen)
|
||||
ip_addr_debug_print_val(SOCKETS_DEBUG, local_addr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", local_port));
|
||||
|
||||
-#if USE_LIBOS
|
||||
- /* Supports kernel NIC IP address. */
|
||||
- int ret = posix_api->bind_fn(s, name, namelen);
|
||||
- if (ret < 0) {
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG, ("bind syscall failed\n"));
|
||||
- /* bind must succeed on both linux and libos */
|
||||
- if (!is_host_ipv4(local_addr.addr)) {
|
||||
- return ret;
|
||||
- }
|
||||
- }
|
||||
-#endif /* USE_LIBOS */
|
||||
-
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
/* Dual-stack: Unmap IPv4 mapped IPv6 addresses */
|
||||
if (IP_IS_V6_VAL(local_addr) && ip6_addr_isipv4mappedipv6(ip_2_ip6(&local_addr))) {
|
||||
@@ -953,32 +885,13 @@ lwip_close(int s)
|
||||
struct lwip_sock *sock;
|
||||
int is_tcp = 0;
|
||||
err_t err;
|
||||
- int ret = 0;
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
|
||||
|
||||
-#if USE_LIBOS
|
||||
- if (posix_api->is_epfd(s)) {
|
||||
- return posix_api->epoll_close_fn(s);
|
||||
- }
|
||||
-
|
||||
- /* No matter what the result of close, lwip_sock resources should release
|
||||
- * to prevent the potential double freee problem caused by reporting events after the close */
|
||||
- ret = posix_api->close_fn(s);
|
||||
- if ((ret < 0) && (errno == EINTR))
|
||||
- ret = posix_api->close_fn(s);
|
||||
-
|
||||
- sock = posix_api->get_socket(s);
|
||||
- /*AF_UNIX case*/
|
||||
- if (!sock) {
|
||||
- return ret;
|
||||
- }
|
||||
-#else
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
-#endif /* USE_LIBOS */
|
||||
|
||||
if (sock->conn != NULL) {
|
||||
is_tcp = NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP;
|
||||
@@ -1004,7 +917,7 @@ lwip_close(int s)
|
||||
|
||||
free_socket(sock, is_tcp);
|
||||
set_errno(0);
|
||||
- return ret;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -1013,28 +926,10 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t namelen)
|
||||
struct lwip_sock *sock;
|
||||
err_t err;
|
||||
|
||||
-#if USE_LIBOS
|
||||
- int ret;
|
||||
-
|
||||
- sock = posix_api->get_socket(s);
|
||||
- if (!sock) {
|
||||
- return posix_api->connect_fn(s, name, namelen);
|
||||
- }
|
||||
-
|
||||
- /* raise connect syscall in place */
|
||||
- ADD_CONN_TYPE_INPRG(sock->conn);
|
||||
- ret = posix_api->connect_fn(s, name, namelen);
|
||||
- if (!ret) {
|
||||
- SET_CONN_TYPE_HOST(sock->conn);
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG, ("linux connect succeed fd=%d\n", s));
|
||||
- return ret;
|
||||
- }
|
||||
-#else
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
-#endif
|
||||
|
||||
if (!SOCK_ADDR_TYPE_MATCH_OR_UNSPEC(name, sock)) {
|
||||
/* sockaddr does not match socket type (IPv4/IPv6) */
|
||||
@@ -1106,29 +1001,10 @@ lwip_listen(int s, int backlog)
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog));
|
||||
|
||||
-#if USE_LIBOS
|
||||
- int ret;
|
||||
-
|
||||
- sock = posix_api->get_socket(s);
|
||||
- /*AF_UNIX case*/
|
||||
- if (!sock) {
|
||||
- return posix_api->listen_fn(s, backlog);
|
||||
- }
|
||||
- /*for AF_INET, we may try both linux and lwip*/
|
||||
- if (!CONN_TYPE_HAS_LIBOS_AND_HOST(sock->conn)) {
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG, ("conn->type has libos and host bits"));
|
||||
- set_errno(EADDRINUSE);
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- if ((ret = posix_api->listen_fn(s, backlog)) == -1)
|
||||
- return ret;
|
||||
-#else
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
-#endif
|
||||
|
||||
/* limit the "backlog" parameter to fit in an u8_t */
|
||||
backlog = LWIP_MIN(LWIP_MAX(backlog, 0), 0xff);
|
||||
@@ -1160,11 +1036,12 @@ static ssize_t
|
||||
lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
|
||||
{
|
||||
u8_t apiflags = NETCONN_NOAUTORCVD;
|
||||
+ ssize_t recvd = 0;
|
||||
#if USE_LIBOS
|
||||
apiflags = 0;
|
||||
-#endif
|
||||
- ssize_t recvd = 0;
|
||||
+#else
|
||||
ssize_t recv_left = (len <= SSIZE_MAX) ? (ssize_t)len : SSIZE_MAX;
|
||||
+#endif
|
||||
|
||||
LWIP_ASSERT("no socket given", sock != NULL);
|
||||
LWIP_ASSERT("this should be checked internally", NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP);
|
||||
@@ -1173,6 +1050,7 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
|
||||
apiflags |= NETCONN_DONTBLOCK;
|
||||
}
|
||||
|
||||
+#if !USE_LIBOS
|
||||
do {
|
||||
struct pbuf *p;
|
||||
err_t err;
|
||||
@@ -1182,13 +1060,6 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
|
||||
/* Check if there is data left from the last recv operation. */
|
||||
if (sock->lastdata.pbuf) {
|
||||
p = sock->lastdata.pbuf;
|
||||
-#if USE_LIBOS
|
||||
- if (((flags & MSG_PEEK) == 0) && ((sock->epoll & EPOLLET) == 0)) {
|
||||
- if ((NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP)) {
|
||||
- del_epoll_event(sock->conn, EPOLLIN);
|
||||
- }
|
||||
- }
|
||||
-#endif
|
||||
} else {
|
||||
/* No data was left from the previous operation, so we try to get
|
||||
some from the network. */
|
||||
@@ -1258,23 +1129,21 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
|
||||
apiflags |= NETCONN_DONTBLOCK | NETCONN_NOFIN;
|
||||
/* @todo: do we need to support peeking more than one pbuf? */
|
||||
} while ((recv_left > 0) && !(flags & MSG_PEEK));
|
||||
+
|
||||
lwip_recv_tcp_done:
|
||||
-#if USE_LIBOS
|
||||
- if (apiflags & NETCONN_NOAUTORCVD)
|
||||
-#endif
|
||||
- {
|
||||
+#else /* USE_LIBOS */
|
||||
+ recvd = read_lwip_data(sock, flags, apiflags);
|
||||
+ if (recvd <= 0) {
|
||||
+ return recvd;
|
||||
+ }
|
||||
+#endif /* USE_LIBOS */
|
||||
+ if (apiflags & NETCONN_NOAUTORCVD) {
|
||||
if ((recvd > 0) && !(flags & MSG_PEEK)) {
|
||||
/* ensure window update after copying all data */
|
||||
netconn_tcp_recvd(sock->conn, (size_t)recvd);
|
||||
}
|
||||
}
|
||||
-#if USE_LIBOS
|
||||
- if ((flags & MSG_PEEK) == 0) {
|
||||
- if (((NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP)) && sock->lastdata.pbuf) {
|
||||
- add_epoll_event(sock->conn, EPOLLIN);
|
||||
- }
|
||||
- }
|
||||
-#endif
|
||||
+
|
||||
sock_set_errno(sock, 0);
|
||||
return recvd;
|
||||
}
|
||||
@@ -1461,37 +1330,6 @@ lwip_recvfrom_udp_raw(struct lwip_sock *sock, int flags, struct msghdr *msg, u16
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
-#if USE_LIBOS
|
||||
-static inline enum KERNEL_LWIP_PATH select_path(int s)
|
||||
-{
|
||||
- struct lwip_sock *sock;
|
||||
-
|
||||
- sock = posix_api->get_socket(s);
|
||||
- /*AF_UNIX case*/
|
||||
- if (!sock) {
|
||||
- return PATH_KERNEL;
|
||||
- }
|
||||
-
|
||||
- if (CONN_TYPE_HAS_INPRG(sock->conn)) {
|
||||
- set_errno(EWOULDBLOCK);
|
||||
- return PATH_ERR;
|
||||
- }
|
||||
-
|
||||
- /*for AF_INET, we can try erther linux or lwip*/
|
||||
- if (CONN_TYPE_IS_HOST(sock->conn)) {
|
||||
- return PATH_KERNEL;
|
||||
- }
|
||||
-
|
||||
- if (!CONN_TYPE_IS_LIBOS(sock->conn)) {
|
||||
- LWIP_DEBUGF(SOCKETS_DEBUG, ("conn->type is not libos bit type=%x", netconn_type(sock->conn)));
|
||||
- set_errno(EINVAL);
|
||||
- return PATH_ERR;
|
||||
- }
|
||||
-
|
||||
- return PATH_LWIP;
|
||||
-}
|
||||
-#endif
|
||||
-
|
||||
ssize_t
|
||||
lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen)
|
||||
@@ -1499,15 +1337,6 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
struct lwip_sock *sock;
|
||||
ssize_t ret;
|
||||
|
||||
-#if USE_LIBOS
|
||||
- enum KERNEL_LWIP_PATH path = select_path(s);
|
||||
- if (path == PATH_ERR) {
|
||||
- return -1;
|
||||
- } else if (path == PATH_KERNEL) {
|
||||
- return posix_api->recv_from(s, mem, len, flags, from, fromlen);
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %"SZT_F", 0x%x, ..)\n", s, mem, len, flags));
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
@@ -1557,14 +1386,6 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
ssize_t
|
||||
lwip_read(int s, void *mem, size_t len)
|
||||
{
|
||||
-#if USE_LIBOS
|
||||
- enum KERNEL_LWIP_PATH path = select_path(s);
|
||||
- if (path == PATH_ERR) {
|
||||
- return -1;
|
||||
- } else if (path == PATH_KERNEL) {
|
||||
- return posix_api->read_fn(s, mem, len);
|
||||
- }
|
||||
-#endif
|
||||
return lwip_recvfrom(s, mem, len, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -1598,15 +1419,6 @@ lwip_recvmsg(int s, struct msghdr *message, int flags)
|
||||
int i;
|
||||
ssize_t buflen;
|
||||
|
||||
-#if USE_LIBOS
|
||||
- enum KERNEL_LWIP_PATH path = select_path(s);
|
||||
- if (path == PATH_ERR) {
|
||||
- return -1;
|
||||
- } else if (path == PATH_KERNEL) {
|
||||
- return posix_api->recv_msg(s, message, flags);
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvmsg(%d, message=%p, flags=0x%x)\n", s, (void *)message, flags));
|
||||
LWIP_ERROR("lwip_recvmsg: invalid message pointer", message != NULL, return ERR_ARG;);
|
||||
LWIP_ERROR("lwip_recvmsg: unsupported flags", (flags & ~(MSG_PEEK|MSG_DONTWAIT)) == 0,
|
||||
@@ -1751,15 +1563,6 @@ lwip_sendmsg(int s, const struct msghdr *msg, int flags)
|
||||
#endif
|
||||
err_t err = ERR_OK;
|
||||
|
||||
-#if USE_LIBOS
|
||||
- enum KERNEL_LWIP_PATH path = select_path(s);
|
||||
- if (path == PATH_ERR) {
|
||||
- return -1;
|
||||
- } else if (path == PATH_KERNEL) {
|
||||
- return posix_api->send_msg(s, msg, flags);
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
@@ -1923,15 +1726,6 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
|
||||
u16_t remote_port;
|
||||
struct netbuf buf;
|
||||
|
||||
-#if USE_LIBOS
|
||||
- enum KERNEL_LWIP_PATH path = select_path(s);
|
||||
- if (path == PATH_ERR) {
|
||||
- return -1;
|
||||
- } else if (path == PATH_KERNEL) {
|
||||
- return posix_api->send_to(s, data, size, flags, to, tolen);
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
@@ -2030,11 +1824,6 @@ lwip_socket(int domain, int type, int protocol)
|
||||
|
||||
LWIP_UNUSED_ARG(domain); /* @todo: check this */
|
||||
|
||||
-#if USE_LIBOS
|
||||
- if ((domain != AF_INET && domain != AF_UNSPEC) || posix_api->is_chld)
|
||||
- return posix_api->socket_fn(domain, type, protocol);
|
||||
-#endif
|
||||
-
|
||||
/* create a netconn */
|
||||
switch (type) {
|
||||
case SOCK_RAW:
|
||||
@@ -2091,14 +1880,6 @@ lwip_socket(int domain, int type, int protocol)
|
||||
ssize_t
|
||||
lwip_write(int s, const void *data, size_t size)
|
||||
{
|
||||
-#if USE_LIBOS
|
||||
- enum KERNEL_LWIP_PATH path = select_path(s);
|
||||
- if (path == PATH_ERR) {
|
||||
- return -1;
|
||||
- } else if (path == PATH_KERNEL) {
|
||||
- return posix_api->write_fn(s, data, size);
|
||||
- }
|
||||
-#endif
|
||||
return lwip_send(s, data, size, 0);
|
||||
}
|
||||
|
||||
@@ -2884,20 +2665,16 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
check_waiters = 0;
|
||||
}
|
||||
#if USE_LIBOS
|
||||
- if (sock->epoll & EPOLLET) {
|
||||
- list_del_node_null(&sock->list);
|
||||
+ if (conn->state == NETCONN_LISTEN) {
|
||||
+ add_epoll_event(conn, EPOLLIN);
|
||||
+ } else {
|
||||
+ add_recv_list(conn->socket);
|
||||
}
|
||||
- add_epoll_event(conn, EPOLLIN);
|
||||
#endif
|
||||
break;
|
||||
case NETCONN_EVT_RCVMINUS:
|
||||
sock->rcvevent--;
|
||||
check_waiters = 0;
|
||||
-#if USE_LIBOS
|
||||
- if ((sock->epoll & EPOLLET) == 0) {
|
||||
- del_epoll_event(conn, EPOLLIN);
|
||||
- }
|
||||
-#endif
|
||||
break;
|
||||
case NETCONN_EVT_SENDPLUS:
|
||||
if (sock->sendevent) {
|
||||
@@ -2905,27 +2682,16 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
}
|
||||
sock->sendevent = 1;
|
||||
#if USE_LIBOS
|
||||
- if (sock->epoll & EPOLLET) {
|
||||
- list_del_node_null(&sock->list);
|
||||
- }
|
||||
add_epoll_event(conn, EPOLLOUT);
|
||||
#endif
|
||||
break;
|
||||
case NETCONN_EVT_SENDMINUS:
|
||||
sock->sendevent = 0;
|
||||
check_waiters = 0;
|
||||
-#if USE_LIBOS
|
||||
- if ((sock->epoll & EPOLLET) == 0) {
|
||||
- del_epoll_event(conn, EPOLLOUT);
|
||||
- }
|
||||
-#endif
|
||||
break;
|
||||
case NETCONN_EVT_ERROR:
|
||||
sock->errevent = 1;
|
||||
#if USE_LIBOS
|
||||
- if (sock->epoll & EPOLLET) {
|
||||
- list_del_node_null(&sock->list);
|
||||
- }
|
||||
add_epoll_event(conn, EPOLLERR);
|
||||
#endif
|
||||
break;
|
||||
@@ -3139,41 +2905,12 @@ lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
|
||||
int
|
||||
lwip_getpeername(int s, struct sockaddr *name, socklen_t *namelen)
|
||||
{
|
||||
-#if USE_LIBOS
|
||||
- struct lwip_sock *sock;
|
||||
-
|
||||
- sock = posix_api->get_socket(s);
|
||||
- if (!sock) {
|
||||
- return posix_api->getpeername_fn(s, name, namelen);
|
||||
- }
|
||||
- /*for AF_INET, if has only host type bit, just call linux api,
|
||||
- *if has libos and host type bits, it's a not connected fd, call
|
||||
- *linux api and return -1(errno == ENOTCONN) is also ok*/
|
||||
- if (CONN_TYPE_HAS_HOST(sock->conn)) {
|
||||
- return posix_api->getpeername_fn(s, name, namelen);
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
return lwip_getaddrname(s, name, namelen, 0);
|
||||
}
|
||||
|
||||
int
|
||||
lwip_getsockname(int s, struct sockaddr *name, socklen_t *namelen)
|
||||
{
|
||||
-#if USE_LIBOS
|
||||
- struct lwip_sock *sock;
|
||||
-
|
||||
- sock = posix_api->get_socket(s);
|
||||
- if (!sock) {
|
||||
- return posix_api->getsockname_fn(s, name, namelen);
|
||||
- }
|
||||
- /*for AF_INET, if has only host type bit, just call linux api,
|
||||
- *if has libos and host type bits, also call linux api*/
|
||||
- if (CONN_TYPE_HAS_HOST(sock->conn)) {
|
||||
- return posix_api->getsockname_fn(s, name, namelen);
|
||||
- }
|
||||
-#endif
|
||||
-
|
||||
return lwip_getaddrname(s, name, namelen, 1);
|
||||
}
|
||||
|
||||
@@ -3186,23 +2923,11 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
|
||||
LWIP_SETGETSOCKOPT_DATA_VAR_DECLARE(data);
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
-#if USE_LIBOS
|
||||
- struct lwip_sock *sock = posix_api->get_socket(s);
|
||||
-
|
||||
- if (!sock) {
|
||||
- return posix_api->getsockopt_fn(s, level, optname, optval, optlen);
|
||||
- }
|
||||
- /*for AF_INET, we return linux result? */
|
||||
- if (CONN_TYPE_HAS_HOST(sock->conn)) {
|
||||
- return posix_api->getsockopt_fn(s, level, optname, optval, optlen);
|
||||
- }
|
||||
-#else
|
||||
struct lwip_sock *sock = get_socket(s);
|
||||
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
-#endif /* USE_LIBOS */
|
||||
|
||||
if ((NULL == optval) || (NULL == optlen)) {
|
||||
sock_set_errno(sock, EFAULT);
|
||||
@@ -3645,25 +3370,11 @@ lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t opt
|
||||
LWIP_SETGETSOCKOPT_DATA_VAR_DECLARE(data);
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
-#if USE_LIBOS
|
||||
- struct lwip_sock *sock = posix_api->get_socket(s);
|
||||
-
|
||||
- if (!sock) {
|
||||
- return posix_api->setsockopt_fn(s, level, optname, optval, optlen);
|
||||
- }
|
||||
- /*for AF_INET, we may try both linux and lwip*/
|
||||
- if (CONN_TYPE_HAS_HOST(sock->conn)) {
|
||||
- if (posix_api->setsockopt_fn(s, level, optname, optval, optlen) < 0) {
|
||||
- return -1;
|
||||
- }
|
||||
- }
|
||||
-#else
|
||||
struct lwip_sock *sock = get_socket(s);
|
||||
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
-#endif /* USE_LIBOS */
|
||||
|
||||
if (NULL == optval) {
|
||||
sock_set_errno(sock, EFAULT);
|
||||
@@ -4308,26 +4019,6 @@ lwip_ioctl(int s, long cmd, void *argp)
|
||||
* the flag O_NONBLOCK is implemented for F_SETFL.
|
||||
*/
|
||||
int
|
||||
-#if USE_LIBOS
|
||||
-lwip_fcntl(int s, int cmd, ...)
|
||||
-{
|
||||
- struct lwip_sock *sock = posix_api->get_socket(s);
|
||||
- int val, ret = -1;
|
||||
- int op_mode = 0;
|
||||
- va_list ap;
|
||||
-
|
||||
- va_start(ap, cmd);
|
||||
- val = va_arg(ap, int);
|
||||
- va_end(ap);
|
||||
-
|
||||
- if (!sock) {
|
||||
- return posix_api->fcntl_fn(s, cmd, val);
|
||||
- }
|
||||
- if (CONN_TYPE_HAS_HOST(sock->conn)) {
|
||||
- if ((ret = posix_api->fcntl_fn(s, cmd, val)) == -1)
|
||||
- return ret;
|
||||
- }
|
||||
-#else /* USE_LIBOS */
|
||||
lwip_fcntl(int s, int cmd, int val)
|
||||
{
|
||||
struct lwip_sock *sock = get_socket(s);
|
||||
@@ -4337,7 +4028,6 @@ lwip_fcntl(int s, int cmd, int val)
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
-#endif /* USE_LIBOS */
|
||||
|
||||
switch (cmd) {
|
||||
case F_GETFL:
|
||||
diff --git a/src/api/sys_arch.c b/src/api/sys_arch.c
|
||||
index 55561b1..9a92143 100644
|
||||
--- a/src/api/sys_arch.c
|
||||
+++ b/src/api/sys_arch.c
|
||||
@@ -76,8 +76,8 @@ struct sys_mem_stats {
|
||||
|
||||
static PER_THREAD struct sys_mem_stats hugepage_stats;
|
||||
|
||||
-static PER_THREAD uint64_t cycles_per_ms __attribute__((aligned(64)));
|
||||
-static PER_THREAD uint64_t sys_start_ms __attribute__((aligned(64)));
|
||||
+static uint64_t cycles_per_ms __attribute__((aligned(64)));
|
||||
+static uint64_t sys_start_ms __attribute__((aligned(64)));
|
||||
|
||||
/*
|
||||
* Mailbox
|
||||
@@ -337,8 +337,12 @@ void sys_calibrate_tsc(void)
|
||||
#define MS_PER_SEC 1E3
|
||||
uint64_t freq = rte_get_tsc_hz();
|
||||
|
||||
- cycles_per_ms = (freq + MS_PER_SEC - 1) / MS_PER_SEC;
|
||||
- sys_start_ms = rte_rdtsc() / cycles_per_ms;
|
||||
+ if (cycles_per_ms == 0) {
|
||||
+ cycles_per_ms = (freq + MS_PER_SEC - 1) / MS_PER_SEC;
|
||||
+ }
|
||||
+ if (sys_start_ms == 0) {
|
||||
+ sys_start_ms = rte_rdtsc() / cycles_per_ms;
|
||||
+ }
|
||||
}
|
||||
|
||||
uint32_t sys_now(void)
|
||||
diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
|
||||
index dac498e..b99974d 100644
|
||||
--- a/src/core/tcp_out.c
|
||||
+++ b/src/core/tcp_out.c
|
||||
@@ -472,6 +472,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
|
||||
* pos records progress as data is segmented.
|
||||
*/
|
||||
|
||||
+#if !USE_LIBOS
|
||||
/* Find the tail of the unsent queue. */
|
||||
if (pcb->unsent != NULL) {
|
||||
u16_t space;
|
||||
@@ -587,6 +588,13 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
|
||||
pcb->unsent_oversize == 0);
|
||||
#endif /* TCP_OVERSIZE */
|
||||
}
|
||||
+#else /* USE_LIBOS */
|
||||
+ if (pcb->unsent != NULL) {
|
||||
+ /* @todo: this could be sped up by keeping last_unsent in the pcb */
|
||||
+ for (last_unsent = pcb->unsent; last_unsent->next != NULL;
|
||||
+ last_unsent = last_unsent->next);
|
||||
+ }
|
||||
+#endif /* USE_LIBOS */
|
||||
|
||||
/*
|
||||
* Phase 3: Create new segments.
|
||||
@@ -604,6 +612,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
|
||||
u8_t chksum_swapped = 0;
|
||||
#endif /* TCP_CHECKSUM_ON_COPY */
|
||||
|
||||
+#if !USE_LIBOS
|
||||
if (apiflags & TCP_WRITE_FLAG_COPY) {
|
||||
/* If copy is set, memory should be allocated and data copied
|
||||
* into pbuf */
|
||||
@@ -650,6 +659,10 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
|
||||
/* Concatenate the headers and data pbufs together. */
|
||||
pbuf_cat(p/*header*/, p2/*data*/);
|
||||
}
|
||||
+#else /* USE_LIBOS */
|
||||
+ p = (struct pbuf *)arg;
|
||||
+ seglen = p->len;
|
||||
+#endif /* USE_LIBOS */
|
||||
|
||||
queuelen += pbuf_clen(p);
|
||||
|
||||
diff --git a/src/include/eventpoll.h b/src/include/eventpoll.h
|
||||
index f525bc2..aacc1d2 100644
|
||||
--- a/src/include/eventpoll.h
|
||||
+++ b/src/include/eventpoll.h
|
||||
@@ -63,9 +63,7 @@ struct libos_epoll {
|
||||
int efd; /* eventfd */
|
||||
};
|
||||
|
||||
-extern int add_epoll_event(struct netconn*, uint32_t);
|
||||
-extern int del_epoll_event(struct netconn*, uint32_t);
|
||||
-extern int lwip_epoll_close(int);
|
||||
-extern int lwip_is_epfd(int);
|
||||
+extern void add_epoll_event(struct netconn*, uint32_t);
|
||||
+extern int32_t lstack_epoll_close(int32_t);
|
||||
|
||||
#endif /* __EVENTPOLL_H__ */
|
||||
diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h
|
||||
index f771725..83208bf 100644
|
||||
--- a/src/include/lwip/priv/tcp_priv.h
|
||||
+++ b/src/include/lwip/priv/tcp_priv.h
|
||||
@@ -349,7 +349,7 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
|
||||
{
|
||||
LWIP_ASSERT("Invalid parameter", pcb != NULL);
|
||||
|
||||
- struct libnet_quintuple qtuple;
|
||||
+ struct gazelle_quintuple qtuple;
|
||||
qtuple.protocol = 0;
|
||||
qtuple.src_ip = pcb->local_ip.addr;
|
||||
qtuple.src_port = lwip_htons(pcb->local_port);
|
||||
diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h
|
||||
index 345e26c..4e7e671 100644
|
||||
--- a/src/include/lwip/sockets.h
|
||||
+++ b/src/include/lwip/sockets.h
|
||||
@@ -647,7 +647,7 @@ int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||
|
||||
#if USE_LIBOS
|
||||
int lwip_ioctl(int s, long cmd, ...);
|
||||
-int lwip_fcntl(int s, int cmd, ...);
|
||||
+int lwip_fcntl(int s, int cmd, int val);
|
||||
#else
|
||||
int lwip_ioctl(int s, long cmd, void *argp);
|
||||
int lwip_fcntl(int s, int cmd, int val);
|
||||
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
|
||||
index e9ffbb1..069cdcb 100644
|
||||
--- a/src/include/lwipsock.h
|
||||
+++ b/src/include/lwipsock.h
|
||||
@@ -60,6 +60,10 @@ union lwip_sock_lastdata {
|
||||
struct pbuf *pbuf;
|
||||
};
|
||||
|
||||
+#if USE_LIBOS
|
||||
+struct protocol_stack;
|
||||
+struct weakup_poll;
|
||||
+#endif
|
||||
/** Contains all internal pointers and states used for a socket */
|
||||
struct lwip_sock {
|
||||
/** sockets currently are built on netconns, each socket has one netconn */
|
||||
@@ -88,14 +92,19 @@ struct lwip_sock {
|
||||
#endif
|
||||
|
||||
#if USE_LIBOS
|
||||
- struct list_node list;
|
||||
- /* registered events */
|
||||
- uint32_t epoll;
|
||||
- /* available events */
|
||||
- uint32_t events;
|
||||
+ uint32_t epoll_events; /* registered events */
|
||||
+ uint32_t events; /* available events */
|
||||
+ int32_t in_event; /* avoid recurring events */
|
||||
epoll_data_t ep_data;
|
||||
- /* libos_epoll pointer in use */
|
||||
- struct libos_epoll *epoll_data;
|
||||
+ struct weakup_poll *weakup;
|
||||
+ struct protocol_stack *stack;
|
||||
+ void *recv_ring;
|
||||
+ struct pbuf *recv_lastdata; /* unread data in one pbuf */
|
||||
+ struct pbuf *send_lastdata; /* unread data in one pbuf */
|
||||
+ void *send_ring;
|
||||
+ int32_t recv_flags;
|
||||
+ int32_t nextfd; /* listenfd list */
|
||||
+ struct list_node recv_list;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -138,6 +147,10 @@ get_socket_without_errno(int s)
|
||||
|
||||
return sock;
|
||||
}
|
||||
+
|
||||
+extern void add_recv_list(int32_t fd);
|
||||
+extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags);
|
||||
+extern void gazelle_clean_sock(int32_t fd);
|
||||
#endif /* USE_LIBOS */
|
||||
|
||||
struct lwip_sock *get_socket(int s);
|
||||
@@ -145,6 +158,4 @@ struct lwip_sock *get_socket_by_fd(int s);
|
||||
void lwip_sock_init(void);
|
||||
void lwip_exit(void);
|
||||
|
||||
-extern int is_host_ipv4(uint32_t ipv4);
|
||||
-
|
||||
#endif /* __LWIPSOCK_H__ */
|
||||
diff --git a/src/include/posix_api.h b/src/include/posix_api.h
|
||||
index 0dca8eb..2afd266 100644
|
||||
--- a/src/include/posix_api.h
|
||||
+++ b/src/include/posix_api.h
|
||||
@@ -34,7 +34,7 @@
|
||||
#define __POSIX_API_H__
|
||||
|
||||
#include <signal.h>
|
||||
-#include <poll.h>
|
||||
+#include <sys/poll.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
diff --git a/src/include/reg_sock.h b/src/include/reg_sock.h
|
||||
index 76d4c48..76673da 100644
|
||||
--- a/src/include/reg_sock.h
|
||||
+++ b/src/include/reg_sock.h
|
||||
@@ -41,7 +41,7 @@ enum reg_ring_type {
|
||||
RING_REG_MAX,
|
||||
};
|
||||
|
||||
-struct libnet_quintuple {
|
||||
+struct gazelle_quintuple {
|
||||
uint32_t protocol;
|
||||
/* net byte order */
|
||||
uint16_t src_port;
|
||||
@@ -54,9 +54,9 @@ struct reg_ring_msg {
|
||||
enum reg_ring_type type;
|
||||
|
||||
uint32_t tid;
|
||||
- struct libnet_quintuple qtuple;
|
||||
+ struct gazelle_quintuple qtuple;
|
||||
};
|
||||
|
||||
-extern int vdev_reg_xmit(enum reg_ring_type type, struct libnet_quintuple *qtuple);
|
||||
+extern int vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple);
|
||||
|
||||
-#endif /* __REG_SOCK_H__ */
|
||||
\ No newline at end of file
|
||||
+#endif /* __REG_SOCK_H__ */
|
||||
--
|
||||
2.30.0
|
||||
|
||||
58
0017-support-REUSEPOR-option.patch
Normal file
58
0017-support-REUSEPOR-option.patch
Normal file
@ -0,0 +1,58 @@
|
||||
From 670f888704c7bbb1121e63bc380ca34b83c43464 Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Thu, 3 Mar 2022 17:06:03 +0800
|
||||
Subject: [PATCH] support REUSEPOR option fix rpc msg too much
|
||||
fix recurring events
|
||||
|
||||
---
|
||||
src/api/sockets.c | 4 ++++
|
||||
src/include/lwipsock.h | 10 ++++++++--
|
||||
2 files changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index b032ce9..4b682f3 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -3029,6 +3029,10 @@ lwip_sockopt_to_ipopt(int optname)
|
||||
return SOF_KEEPALIVE;
|
||||
case SO_REUSEADDR:
|
||||
return SOF_REUSEADDR;
|
||||
+#if USE_LIBOS
|
||||
+ case SO_REUSEPORT:
|
||||
+ return SO_REUSEPORT;
|
||||
+#endif
|
||||
default:
|
||||
LWIP_ASSERT("Unknown socket option", 0);
|
||||
return 0;
|
||||
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
|
||||
index 069cdcb..e2519ff 100644
|
||||
--- a/src/include/lwipsock.h
|
||||
+++ b/src/include/lwipsock.h
|
||||
@@ -94,7 +94,8 @@ struct lwip_sock {
|
||||
#if USE_LIBOS
|
||||
uint32_t epoll_events; /* registered events */
|
||||
uint32_t events; /* available events */
|
||||
- int32_t in_event; /* avoid recurring events */
|
||||
+ volatile bool have_event; /* avoid recurring events */
|
||||
+ volatile bool have_rpc_send; /* avoid recurring rpc_send */
|
||||
epoll_data_t ep_data;
|
||||
struct weakup_poll *weakup;
|
||||
struct protocol_stack *stack;
|
||||
@@ -103,8 +104,13 @@ struct lwip_sock {
|
||||
struct pbuf *send_lastdata; /* unread data in one pbuf */
|
||||
void *send_ring;
|
||||
int32_t recv_flags;
|
||||
- int32_t nextfd; /* listenfd list */
|
||||
+ bool wait_close;
|
||||
+ int32_t attach_fd;
|
||||
+ struct lwip_sock *shadowed_sock;
|
||||
+ struct list_node attach_list;
|
||||
+ struct list_node listen_list;
|
||||
struct list_node recv_list;
|
||||
+ int32_t nextfd; /* listenfd list */
|
||||
#endif
|
||||
};
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
37
0018-exec-gazelle_init_sock-before-read-event.patch
Normal file
37
0018-exec-gazelle_init_sock-before-read-event.patch
Normal file
@ -0,0 +1,37 @@
|
||||
From 544bf45ec99c853ad5e9ec2607669df01b4e0572 Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Mon, 7 Mar 2022 21:06:39 +0800
|
||||
Subject: [PATCH] exec gazelle_init_sock() before read event
|
||||
|
||||
---
|
||||
src/api/sockets.c | 1 +
|
||||
src/include/lwipsock.h | 1 +
|
||||
2 files changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index 4b682f3..21de5d9 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -763,6 +763,7 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
}
|
||||
#if USE_LIBOS
|
||||
LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < sockets_num + LWIP_SOCKET_OFFSET));
|
||||
+ gazelle_init_sock(newsock);
|
||||
#else
|
||||
LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < NUM_SOCKETS + LWIP_SOCKET_OFFSET));
|
||||
#endif /* USE_LIBOS */
|
||||
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
|
||||
index e2519ff..355bf47 100644
|
||||
--- a/src/include/lwipsock.h
|
||||
+++ b/src/include/lwipsock.h
|
||||
@@ -157,6 +157,7 @@ get_socket_without_errno(int s)
|
||||
extern void add_recv_list(int32_t fd);
|
||||
extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags);
|
||||
extern void gazelle_clean_sock(int32_t fd);
|
||||
+extern void gazelle_init_sock(int32_t fd);
|
||||
#endif /* USE_LIBOS */
|
||||
|
||||
struct lwip_sock *get_socket(int s);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
50
0019-gazelle-reduce-copy-in-send.patch
Normal file
50
0019-gazelle-reduce-copy-in-send.patch
Normal file
@ -0,0 +1,50 @@
|
||||
From 05bfdb54fc744d835c8b3b50b54d220fe7e87277 Mon Sep 17 00:00:00 2001
|
||||
From: wuchangsheng <wuchangsheng2@huawei.com>
|
||||
Date: Mon, 7 Mar 2022 21:10:06 +0800
|
||||
Subject: [PATCH] reduce copy in send
|
||||
|
||||
---
|
||||
src/core/pbuf.c | 5 +++++
|
||||
src/include/lwip/pbuf.h | 3 +++
|
||||
2 files changed, 8 insertions(+)
|
||||
|
||||
diff --git a/src/core/pbuf.c b/src/core/pbuf.c
|
||||
index 27afc28..cd6b558 100644
|
||||
--- a/src/core/pbuf.c
|
||||
+++ b/src/core/pbuf.c
|
||||
@@ -281,6 +281,10 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
||||
}
|
||||
|
||||
/* If pbuf is to be allocated in RAM, allocate memory for it. */
|
||||
+#if USE_LIBOS
|
||||
+ /* alloc mbuf to reduce copy in sending */
|
||||
+ p = lwip_alloc_pbuf(layer, length, type);
|
||||
+#else
|
||||
p = (struct pbuf *)mem_malloc(alloc_len);
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
@@ -289,6 +293,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
||||
length, length, type, 0);
|
||||
LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned",
|
||||
((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0);
|
||||
+#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
diff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h
|
||||
index e5daf96..3894574 100644
|
||||
--- a/src/include/lwip/pbuf.h
|
||||
+++ b/src/include/lwip/pbuf.h
|
||||
@@ -272,6 +272,9 @@ void pbuf_free_ooseq(void);
|
||||
/* Initializes the pbuf module. This call is empty for now, but may not be in future. */
|
||||
#define pbuf_init()
|
||||
|
||||
+#if USE_LIBOS
|
||||
+struct pbuf *lwip_alloc_pbuf(pbuf_layer l, u16_t length, pbuf_type type);
|
||||
+#endif
|
||||
struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
|
||||
struct pbuf *pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type);
|
||||
#if LWIP_SUPPORT_CUSTOM_PBUF
|
||||
--
|
||||
2.30.0
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
From 970d9d6fd15c433af20bbbd7418c5e9773d58471 Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Mon, 7 Mar 2022 21:08:13 +0800
|
||||
Subject: [PATCH] remove chose_dlsym_handle function, set handle to RTLD_NEXT
|
||||
|
||||
---
|
||||
src/api/posix_api.c | 33 +--------------------------------
|
||||
1 file changed, 1 insertion(+), 32 deletions(-)
|
||||
|
||||
diff --git a/src/api/posix_api.c b/src/api/posix_api.c
|
||||
index eff9f46..bce07f5 100644
|
||||
--- a/src/api/posix_api.c
|
||||
+++ b/src/api/posix_api.c
|
||||
@@ -64,33 +64,6 @@ void posix_api_fork(void)
|
||||
posix_api->get_socket = chld_get_socket;
|
||||
}
|
||||
|
||||
-static int chose_dlsym_handle(void *__restrict* khandle)
|
||||
-{
|
||||
- void *dlhandle;
|
||||
- int (*gazelle_epoll_create)(int size);
|
||||
- dlhandle = dlopen ("liblstack.so", RTLD_LAZY);
|
||||
- if (dlhandle == NULL) {
|
||||
- return ERR_IF;
|
||||
- }
|
||||
-
|
||||
- gazelle_epoll_create = dlsym(dlhandle, "epoll_create");
|
||||
- if (gazelle_epoll_create == NULL) {
|
||||
- return ERR_MEM;
|
||||
- }
|
||||
-
|
||||
- dlclose(dlhandle);
|
||||
-
|
||||
- *khandle = RTLD_NEXT;
|
||||
- if (dlsym(*khandle, "epoll_create") == gazelle_epoll_create) {
|
||||
- RTE_LOG(ERR, EAL, "posix api use RTLD_DEFAULT\n");
|
||||
- *khandle = RTLD_DEFAULT;
|
||||
- } else {
|
||||
- RTE_LOG(ERR, EAL, "posix api use RTLD_NEXT\n");
|
||||
- }
|
||||
-
|
||||
- return ERR_OK;
|
||||
-}
|
||||
-
|
||||
int posix_api_init(void)
|
||||
{
|
||||
/* the symbol we use here won't be NULL, so we don't need dlerror()
|
||||
@@ -102,11 +75,7 @@ int posix_api_init(void)
|
||||
|
||||
posix_api = &posix_api_val;
|
||||
|
||||
- void *__restrict handle;
|
||||
- int ret = chose_dlsym_handle(&handle);
|
||||
- if (ret != ERR_OK) {
|
||||
- return ret;
|
||||
- }
|
||||
+ void *__restrict handle = RTLD_NEXT;
|
||||
|
||||
/* glibc standard api */
|
||||
CHECK_DLSYM_RET_RETURN(posix_api->socket_fn = dlsym(handle, "socket"));
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
From b7faf0800631668d4d23cb497f1ceeb5948e4a41 Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Tue, 15 Mar 2022 19:22:22 +0800
|
||||
Subject: [PATCH] refactor event, if ring is full, the node is added to list
|
||||
|
||||
---
|
||||
src/include/lwipsock.h | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
|
||||
index 355bf47..36bcaed 100644
|
||||
--- a/src/include/lwipsock.h
|
||||
+++ b/src/include/lwipsock.h
|
||||
@@ -104,12 +104,16 @@ struct lwip_sock {
|
||||
struct pbuf *send_lastdata; /* unread data in one pbuf */
|
||||
void *send_ring;
|
||||
int32_t recv_flags;
|
||||
+ int32_t send_flags;
|
||||
bool wait_close;
|
||||
int32_t attach_fd;
|
||||
struct lwip_sock *shadowed_sock;
|
||||
struct list_node attach_list;
|
||||
struct list_node listen_list;
|
||||
struct list_node recv_list;
|
||||
+ struct list_node event_list;
|
||||
+ struct list_node wakeup_list;
|
||||
+ struct list_node send_list;
|
||||
int32_t nextfd; /* listenfd list */
|
||||
#endif
|
||||
};
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
56
0022-notify-app-that-sock-state-changes-to-CLOSE_WAIT.patch
Normal file
56
0022-notify-app-that-sock-state-changes-to-CLOSE_WAIT.patch
Normal file
@ -0,0 +1,56 @@
|
||||
From 05159c41efdc2f07ddbe3520330faf2675baa3d6 Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Tue, 15 Mar 2022 20:10:07 +0800
|
||||
Subject: [PATCH] notify app that sock changes to CLOSE_WAAIT
|
||||
|
||||
---
|
||||
src/core/tcp_in.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
|
||||
index 1652b86..0d3a2f1 100644
|
||||
--- a/src/core/tcp_in.c
|
||||
+++ b/src/core/tcp_in.c
|
||||
@@ -58,6 +58,9 @@
|
||||
#if LWIP_ND6_TCP_REACHABILITY_HINTS
|
||||
#include "lwip/nd6.h"
|
||||
#endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */
|
||||
+#if USE_LIBOS
|
||||
+#include "lwip/api.h"
|
||||
+#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -1032,6 +1035,9 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
if (recv_flags & TF_GOT_FIN) {
|
||||
tcp_ack_now(pcb);
|
||||
pcb->state = CLOSE_WAIT;
|
||||
+#if USE_LIBOS
|
||||
+ API_EVENT(((struct netconn *)pcb->callback_arg), NETCONN_EVT_ERROR, 0);
|
||||
+#endif
|
||||
}
|
||||
} else {
|
||||
/* incorrect ACK number, send RST */
|
||||
@@ -1050,6 +1056,9 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
if (recv_flags & TF_GOT_FIN) { /* passive close */
|
||||
tcp_ack_now(pcb);
|
||||
pcb->state = CLOSE_WAIT;
|
||||
+#if USE_LIBOS
|
||||
+ API_EVENT(((struct netconn *)pcb->callback_arg), NETCONN_EVT_ERROR, 0);
|
||||
+#endif
|
||||
}
|
||||
break;
|
||||
case FIN_WAIT_1:
|
||||
@@ -1676,6 +1685,9 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
recv_flags |= TF_GOT_FIN;
|
||||
if (pcb->state == ESTABLISHED) { /* force passive close or we can move to active close */
|
||||
pcb->state = CLOSE_WAIT;
|
||||
+#if USE_LIBOS
|
||||
+ API_EVENT(((struct netconn *)pcb->callback_arg), NETCONN_EVT_ERROR, 0);
|
||||
+#endif
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
704
0023-refactor-event-and-checksum-offload-support.patch
Normal file
704
0023-refactor-event-and-checksum-offload-support.patch
Normal file
@ -0,0 +1,704 @@
|
||||
From bf0f60d944d39a737d18931afbd86103a0344e8c Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng12@huawei.com>
|
||||
Date: Tue, 29 Mar 2022 21:33:17 +0800
|
||||
Subject: [PATCH] 23patch
|
||||
|
||||
---
|
||||
src/api/api_msg.c | 9 ++++
|
||||
src/api/posix_api.c | 2 +
|
||||
src/api/sockets.c | 4 +-
|
||||
src/core/ipv4/icmp.c | 13 ++++++
|
||||
src/core/ipv4/ip4.c | 24 ++++++++++-
|
||||
src/core/ipv4/ip4_frag.c | 23 ++++++++++
|
||||
src/core/pbuf.c | 2 +-
|
||||
src/core/tcp_in.c | 17 ++++++++
|
||||
src/core/tcp_out.c | 72 ++++++++++++++++++++++++++++++-
|
||||
src/include/dpdk_cksum.h | 107 +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
src/include/lwip/pbuf.h | 11 ++++-
|
||||
src/include/lwipopts.h | 30 +++++++++----
|
||||
src/include/lwipsock.h | 18 ++++----
|
||||
src/netif/ethernet.c | 8 ++++
|
||||
14 files changed, 314 insertions(+), 26 deletions(-)
|
||||
create mode 100644 src/include/dpdk_cksum.h
|
||||
|
||||
diff --git a/src/api/api_msg.c b/src/api/api_msg.c
|
||||
index 88b0bc2..36a914b 100644
|
||||
--- a/src/api/api_msg.c
|
||||
+++ b/src/api/api_msg.c
|
||||
@@ -57,6 +57,7 @@
|
||||
#if USE_LIBOS
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwipsock.h"
|
||||
+#include "posix_api.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
@@ -1755,7 +1756,15 @@ lwip_netconn_do_writemore(struct netconn *conn WRITE_DELAYED_PARAM)
|
||||
} else {
|
||||
write_more = 0;
|
||||
}
|
||||
+#if USE_LIBOS
|
||||
+ /* vector->ptr is private arg sock */
|
||||
+ LWIP_UNUSED_ARG(dataptr);
|
||||
+ write_more = 0;
|
||||
+ err = tcp_write(conn->pcb.tcp, conn->current_msg->msg.w.vector->ptr, len, apiflags);
|
||||
+ conn->current_msg->msg.w.len = len;
|
||||
+#else
|
||||
err = tcp_write(conn->pcb.tcp, dataptr, len, apiflags);
|
||||
+#endif
|
||||
if (err == ERR_OK) {
|
||||
conn->current_msg->msg.w.offset += len;
|
||||
conn->current_msg->msg.w.vector_off += len;
|
||||
diff --git a/src/api/posix_api.c b/src/api/posix_api.c
|
||||
index bce07f5..3f85bad 100644
|
||||
--- a/src/api/posix_api.c
|
||||
+++ b/src/api/posix_api.c
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwipsock.h"
|
||||
+#include "posix_api.h"
|
||||
|
||||
posix_api_t *posix_api;
|
||||
posix_api_t posix_api_val;
|
||||
@@ -64,6 +65,7 @@ void posix_api_fork(void)
|
||||
posix_api->get_socket = chld_get_socket;
|
||||
}
|
||||
|
||||
+
|
||||
int posix_api_init(void)
|
||||
{
|
||||
/* the symbol we use here won't be NULL, so we don't need dlerror()
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index 597ce15..cebe9de 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -65,6 +65,7 @@
|
||||
#if USE_LIBOS
|
||||
#include <stdarg.h>
|
||||
#include "lwipsock.h"
|
||||
+#include "posix_api.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
@@ -2676,9 +2677,6 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
check_waiters = 0;
|
||||
}
|
||||
sock->sendevent = 1;
|
||||
-#if USE_LIBOS
|
||||
- add_epoll_event(conn, EPOLLOUT);
|
||||
-#endif
|
||||
break;
|
||||
case NETCONN_EVT_SENDMINUS:
|
||||
sock->sendevent = 0;
|
||||
@@ -4371,6 +4371,16 @@ void lwip_exit(void)
|
||||
return;
|
||||
}
|
||||
|
||||
+static PER_THREAD int g_stack_tid = 0;
|
||||
+int gettid(void)
|
||||
+{
|
||||
+ if (g_stack_tid == 0) {
|
||||
+ g_stack_tid = syscall(__NR_gettid);
|
||||
+ }
|
||||
+
|
||||
+ return (int)g_stack_tid;
|
||||
+}
|
||||
+
|
||||
#endif /* USE_LIBOS */
|
||||
|
||||
#endif /* LWIP_SOCKET */
|
||||
|
||||
diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c
|
||||
index a462ccd..d471b02 100644
|
||||
--- a/src/core/ipv4/icmp.c
|
||||
+++ b/src/core/ipv4/icmp.c
|
||||
@@ -51,6 +51,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
+#if USE_LIBOS && CHECKSUM_GEN_IP_HW
|
||||
+#include "dpdk_cksum.h"
|
||||
+#endif
|
||||
+
|
||||
#ifdef LWIP_HOOK_FILENAME
|
||||
#include LWIP_HOOK_FILENAME
|
||||
#endif
|
||||
@@ -236,7 +240,16 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
IPH_CHKSUM_SET(iphdr, 0);
|
||||
#if CHECKSUM_GEN_IP
|
||||
IF__NETIF_CHECKSUM_ENABLED(inp, NETIF_CHECKSUM_GEN_IP) {
|
||||
+#if CHECKSUM_GEN_IP_HW
|
||||
+ if (get_eth_params_tx_ol() & DEV_TX_OFFLOAD_IPV4_CKSUM) {
|
||||
+ iph_cksum_set(p, hlen, 1);
|
||||
+ } else {
|
||||
+ iph_cksum_set(p, hlen, 0);
|
||||
+ IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, hlen));
|
||||
+ }
|
||||
+#else
|
||||
IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, hlen));
|
||||
+#endif
|
||||
}
|
||||
#endif /* CHECKSUM_GEN_IP */
|
||||
|
||||
diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c
|
||||
index c83afbe..1334cdc 100644
|
||||
--- a/src/core/ipv4/ip4.c
|
||||
+++ b/src/core/ipv4/ip4.c
|
||||
@@ -59,6 +59,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
+#if USE_LIBOS && (CHECKSUM_CHECK_IP_HW || CHECKSUM_GEN_IP_HW)
|
||||
+#include "dpdk_cksum.h"
|
||||
+#endif
|
||||
+
|
||||
#ifdef LWIP_HOOK_FILENAME
|
||||
#include LWIP_HOOK_FILENAME
|
||||
#endif
|
||||
@@ -503,8 +507,17 @@ ip4_input(struct pbuf *p, struct netif *inp)
|
||||
/* verify checksum */
|
||||
#if CHECKSUM_CHECK_IP
|
||||
IF__NETIF_CHECKSUM_ENABLED(inp, NETIF_CHECKSUM_CHECK_IP) {
|
||||
+#if CHECKSUM_CHECK_IP_HW
|
||||
+ u64_t ret;
|
||||
+ if (get_eth_params_rx_ol() & DEV_RX_OFFLOAD_IPV4_CKSUM) {
|
||||
+ ret = is_cksum_ipbad(p);
|
||||
+ } else {
|
||||
+ ret = (u64_t)inet_chksum(iphdr, iphdr_hlen);
|
||||
+ }
|
||||
+ if (ret != 0) {
|
||||
+#else
|
||||
if (inet_chksum(iphdr, iphdr_hlen) != 0) {
|
||||
-
|
||||
+#endif
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
|
||||
("Checksum (0x%"X16_F") failed, IP packet dropped.\n", inet_chksum(iphdr, iphdr_hlen)));
|
||||
ip4_debug_print(p);
|
||||
@@ -972,7 +985,16 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d
|
||||
IPH_CHKSUM_SET(iphdr, 0);
|
||||
#if CHECKSUM_GEN_IP
|
||||
IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_IP) {
|
||||
+#if CHECKSUM_GEN_IP_HW
|
||||
+ if (get_eth_params_tx_ol() & DEV_TX_OFFLOAD_IPV4_CKSUM) {
|
||||
+ iph_cksum_set(p, ip_hlen, 1);
|
||||
+ } else {
|
||||
+ iph_cksum_set(p, ip_hlen, 0);
|
||||
+ IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, ip_hlen));
|
||||
+ }
|
||||
+#else
|
||||
IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, ip_hlen));
|
||||
+#endif
|
||||
}
|
||||
#endif /* CHECKSUM_GEN_IP */
|
||||
#endif /* CHECKSUM_GEN_IP_INLINE */
|
||||
diff --git a/src/core/ipv4/ip4_frag.c b/src/core/ipv4/ip4_frag.c
|
||||
index a445530..17a4ccd 100644
|
||||
--- a/src/core/ipv4/ip4_frag.c
|
||||
+++ b/src/core/ipv4/ip4_frag.c
|
||||
@@ -51,6 +51,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
+#if USE_LIBOS && CHECKSUM_GEN_IP_HW
|
||||
+#include "dpdk_cksum.h"
|
||||
+#endif
|
||||
+
|
||||
#if IP_REASSEMBLY
|
||||
/**
|
||||
* The IP reassembly code currently has the following limitations:
|
||||
@@ -632,8 +636,17 @@ ip4_reass(struct pbuf *p)
|
||||
/* @todo: do we need to set/calculate the correct checksum? */
|
||||
#if CHECKSUM_GEN_IP
|
||||
IF__NETIF_CHECKSUM_ENABLED(ip_current_input_netif(), NETIF_CHECKSUM_GEN_IP) {
|
||||
+#if CHECKSUM_GEN_IP_HW
|
||||
+ if (get_eth_params_tx_ol() & DEV_TX_OFFLOAD_IPV4_CKSUM) {
|
||||
+ iph_cksum_set(p, IP_HLEN, 1);
|
||||
+ } else {
|
||||
+ iph_cksum_set(p, IP_HLEN, 0);
|
||||
IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN));
|
||||
}
|
||||
+#else
|
||||
+ IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN));
|
||||
+#endif
|
||||
+ }
|
||||
#endif /* CHECKSUM_GEN_IP */
|
||||
|
||||
p = ipr->p;
|
||||
@@ -862,8 +875,18 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
|
||||
IPH_CHKSUM_SET(iphdr, 0);
|
||||
#if CHECKSUM_GEN_IP
|
||||
IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_IP) {
|
||||
+#if CHECKSUM_GEN_IP_HW
|
||||
+ if (get_eth_params_tx_ol() & DEV_TX_OFFLOAD_IPV4_CKSUM) {
|
||||
+ iph_cksum_set(p, IP_HLEN, 1);
|
||||
+ } else {
|
||||
+ iph_cksum_set(p, IP_HLEN, 0);
|
||||
IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN));
|
||||
}
|
||||
+
|
||||
+#else
|
||||
+ IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN));
|
||||
+#endif
|
||||
+ }
|
||||
#endif /* CHECKSUM_GEN_IP */
|
||||
|
||||
/* No need for separate header pbuf - we allowed room for it in rambuf
|
||||
diff --git a/src/core/pbuf.c b/src/core/pbuf.c
|
||||
index 3a5f375..4687284 100644
|
||||
--- a/src/core/pbuf.c
|
||||
+++ b/src/core/pbuf.c
|
||||
@@ -282,7 +282,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
||||
|
||||
/* If pbuf is to be allocated in RAM, allocate memory for it. */
|
||||
#if USE_LIBOS
|
||||
- /* alloc mbuf to reduce copy in sending */
|
||||
+ /* alloc mbuf avoid send copy */
|
||||
p = lwip_alloc_pbuf(layer, length, type);
|
||||
#else
|
||||
p = (struct pbuf *)mem_malloc(alloc_len);
|
||||
diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
|
||||
index ce6a8a5..f4897f5 100644
|
||||
--- a/src/core/tcp_in.c
|
||||
+++ b/src/core/tcp_in.c
|
||||
@@ -64,6 +64,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
+#if USE_LIBOS && CHECKSUM_CHECK_TCP_HW
|
||||
+#include <dpdk_cksum.h>
|
||||
+#endif /* CHECKSUM_CHECK_TCP_HW */
|
||||
+
|
||||
#ifdef LWIP_HOOK_FILENAME
|
||||
#include LWIP_HOOK_FILENAME
|
||||
#endif
|
||||
@@ -172,11 +176,24 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
||||
#if CHECKSUM_CHECK_TCP
|
||||
IF__NETIF_CHECKSUM_ENABLED(inp, NETIF_CHECKSUM_CHECK_TCP) {
|
||||
/* Verify TCP checksum. */
|
||||
+#if CHECKSUM_CHECK_TCP_HW
|
||||
+ u64_t ret;
|
||||
+ if (get_eth_params_rx_ol() & DEV_RX_OFFLOAD_TCP_CKSUM) {
|
||||
+ ret = is_cksum_tcpbad(p);
|
||||
+ } else {
|
||||
+ ret = (u64_t)ip_chksum_pseudo(p, IP_PROTO_TCP, p->tot_len,
|
||||
+ ip_current_src_addr(), ip_current_dest_addr());
|
||||
+
|
||||
+ }
|
||||
+ if (ret != 0) {
|
||||
+ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum\n"));
|
||||
+#else
|
||||
u16_t chksum = ip_chksum_pseudo(p, IP_PROTO_TCP, p->tot_len,
|
||||
ip_current_src_addr(), ip_current_dest_addr());
|
||||
if (chksum != 0) {
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04"X16_F"\n",
|
||||
chksum));
|
||||
+#endif
|
||||
tcp_debug_print(tcphdr);
|
||||
TCP_STATS_INC(tcp.chkerr);
|
||||
goto dropped;
|
||||
diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
|
||||
index 6617851..2d341b3 100644
|
||||
--- a/src/core/tcp_out.c
|
||||
+++ b/src/core/tcp_out.c
|
||||
@@ -80,6 +80,13 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
+#if USE_LIBOS
|
||||
+#include "lwipsock.h"
|
||||
+#if CHECKSUM_GEN_TCP_HW
|
||||
+#include "dpdk_cksum.h"
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
#ifdef LWIP_HOOK_FILENAME
|
||||
#include LWIP_HOOK_FILENAME
|
||||
#endif
|
||||
@@ -660,8 +667,11 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
|
||||
pbuf_cat(p/*header*/, p2/*data*/);
|
||||
}
|
||||
#else /* USE_LIBOS */
|
||||
- p = (struct pbuf *)arg;
|
||||
- seglen = p->len;
|
||||
+ p = write_lwip_data((struct lwip_sock *)arg, len - pos, &apiflags);
|
||||
+ if (p == NULL) {
|
||||
+ break;
|
||||
+ }
|
||||
+ seglen = p->tot_len;
|
||||
#endif /* USE_LIBOS */
|
||||
|
||||
queuelen += pbuf_clen(p);
|
||||
@@ -789,8 +799,13 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
|
||||
/*
|
||||
* Finally update the pcb state.
|
||||
*/
|
||||
+#if USE_LIBOS
|
||||
+ pcb->snd_lbb += pos;
|
||||
+ pcb->snd_buf -= pos;
|
||||
+#else
|
||||
pcb->snd_lbb += len;
|
||||
pcb->snd_buf -= len;
|
||||
+#endif
|
||||
pcb->snd_queuelen = queuelen;
|
||||
|
||||
LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_write: %"S16_F" (after enqueued)\n",
|
||||
@@ -1584,6 +1599,11 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif
|
||||
|
||||
#if CHECKSUM_GEN_TCP
|
||||
IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_TCP) {
|
||||
+#if CHECKSUM_GEN_TCP_HW
|
||||
+ if (get_eth_params_tx_ol() & DEV_TX_OFFLOAD_TCP_CKSUM) {
|
||||
+ tcph_cksum_set(seg->p, TCP_HLEN);
|
||||
+ seg->tcphdr->chksum = ip_chksum_pseudo_offload(IP_PROTO_TCP,seg->p->tot_len, &pcb->local_ip, &pcb->remote_ip);
|
||||
+ } else {
|
||||
#if TCP_CHECKSUM_ON_COPY
|
||||
u32_t acc;
|
||||
#if TCP_CHECKSUM_ON_COPY_SANITY_CHECK
|
||||
@@ -1618,6 +1638,44 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif
|
||||
seg->tcphdr->chksum = ip_chksum_pseudo(seg->p, IP_PROTO_TCP,
|
||||
seg->p->tot_len, &pcb->local_ip, &pcb->remote_ip);
|
||||
#endif /* TCP_CHECKSUM_ON_COPY */
|
||||
+
|
||||
+ }
|
||||
+#else
|
||||
+#if TCP_CHECKSUM_ON_COPY
|
||||
+ u32_t acc;
|
||||
+#if TCP_CHECKSUM_ON_COPY_SANITY_CHECK
|
||||
+ u16_t chksum_slow = ip_chksum_pseudo(seg->p, IP_PROTO_TCP,
|
||||
+ seg->p->tot_len, &pcb->local_ip, &pcb->remote_ip);
|
||||
+#endif /* TCP_CHECKSUM_ON_COPY_SANITY_CHECK */
|
||||
+ if ((seg->flags & TF_SEG_DATA_CHECKSUMMED) == 0) {
|
||||
+ LWIP_ASSERT("data included but not checksummed",
|
||||
+ seg->p->tot_len == TCPH_HDRLEN_BYTES(seg->tcphdr));
|
||||
+ }
|
||||
+
|
||||
+ /* rebuild TCP header checksum (TCP header changes for retransmissions!) */
|
||||
+ acc = ip_chksum_pseudo_partial(seg->p, IP_PROTO_TCP,
|
||||
+ seg->p->tot_len, TCPH_HDRLEN_BYTES(seg->tcphdr), &pcb->local_ip, &pcb->remote_ip);
|
||||
+ /* add payload checksum */
|
||||
+ if (seg->chksum_swapped) {
|
||||
+ seg_chksum_was_swapped = 1;
|
||||
+ seg->chksum = SWAP_BYTES_IN_WORD(seg->chksum);
|
||||
+ seg->chksum_swapped = 0;
|
||||
+ }
|
||||
+ acc = (u16_t)~acc + seg->chksum;
|
||||
+ seg->tcphdr->chksum = (u16_t)~FOLD_U32T(acc);
|
||||
+#if TCP_CHECKSUM_ON_COPY_SANITY_CHECK
|
||||
+ if (chksum_slow != seg->tcphdr->chksum) {
|
||||
+ TCP_CHECKSUM_ON_COPY_SANITY_CHECK_FAIL(
|
||||
+ ("tcp_output_segment: calculated checksum is %"X16_F" instead of %"X16_F"\n",
|
||||
+ seg->tcphdr->chksum, chksum_slow));
|
||||
+ seg->tcphdr->chksum = chksum_slow;
|
||||
+ }
|
||||
+#endif /* TCP_CHECKSUM_ON_COPY_SANITY_CHECK */
|
||||
+#else /* TCP_CHECKSUM_ON_COPY */
|
||||
+ seg->tcphdr->chksum = ip_chksum_pseudo(seg->p, IP_PROTO_TCP,
|
||||
+ seg->p->tot_len, &pcb->local_ip, &pcb->remote_ip);
|
||||
+#endif /* TCP_CHECKSUM_ON_COPY */
|
||||
+#endif /* CHECKSUM_GEN_TCP_HW */
|
||||
}
|
||||
#endif /* CHECKSUM_GEN_TCP */
|
||||
TCP_STATS_INC(tcp.xmit);
|
||||
@@ -1959,8 +2017,18 @@ tcp_output_control_segment(const struct tcp_pcb *pcb, struct pbuf *p,
|
||||
#if CHECKSUM_GEN_TCP
|
||||
IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_TCP) {
|
||||
struct tcp_hdr *tcphdr = (struct tcp_hdr *)p->payload;
|
||||
+#if CHECKSUM_GEN_TCP_HW
|
||||
+ if (get_eth_params_tx_ol() & DEV_TX_OFFLOAD_TCP_CKSUM) {
|
||||
+ tcph_cksum_set(p, TCP_HLEN);
|
||||
+ tcphdr->chksum = ip_chksum_pseudo_offload(IP_PROTO_TCP, p->tot_len, src, dst);
|
||||
+ } else {
|
||||
+ tcphdr->chksum = ip_chksum_pseudo(p, IP_PROTO_TCP, p->tot_len,
|
||||
+ src, dst);
|
||||
+ }
|
||||
+#else
|
||||
tcphdr->chksum = ip_chksum_pseudo(p, IP_PROTO_TCP, p->tot_len,
|
||||
src, dst);
|
||||
+#endif
|
||||
}
|
||||
#endif
|
||||
if (pcb != NULL) {
|
||||
diff --git a/src/include/dpdk_cksum.h b/src/include/dpdk_cksum.h
|
||||
new file mode 100644
|
||||
index 0000000..e57be4d
|
||||
--- /dev/null
|
||||
+++ b/src/include/dpdk_cksum.h
|
||||
@@ -0,0 +1,108 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
+ * All rights reserved.
|
||||
+ *
|
||||
+ * Redistribution and use in source and binary forms, with or without modification,
|
||||
+ * are permitted provided that the following conditions are met:
|
||||
+ *
|
||||
+ * 1. Redistributions of source code must retain the above copyright notice,
|
||||
+ * this list of conditions and the following disclaimer.
|
||||
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
+ * this list of conditions and the following disclaimer in the documentation
|
||||
+ * and/or other materials provided with the distribution.
|
||||
+ * 3. The name of the author may not be used to endorse or promote products
|
||||
+ * derived from this software without specific prior written permission.
|
||||
+ *
|
||||
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
+ * OF SUCH DAMAGE.
|
||||
+ *
|
||||
+ * This file is part of the lwIP TCP/IP stack.
|
||||
+ *
|
||||
+ * Author: Huawei Technologies
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#ifndef __DPDK_CKSUM_H__
|
||||
+#define __DPDK_CKSUM_H__
|
||||
+
|
||||
+#include "lwipopts.h"
|
||||
+#if USE_LIBOS
|
||||
+#include <stdbool.h>
|
||||
+#include <rte_ethdev.h>
|
||||
+
|
||||
+#if CHECKSUM_OFFLOAD_ALL
|
||||
+#include <rte_mbuf_core.h>
|
||||
+#include "lwip/pbuf.h"
|
||||
+#endif
|
||||
+
|
||||
+extern uint64_t get_eth_params_rx_ol(void);
|
||||
+extern uint64_t get_eth_params_tx_ol(void);
|
||||
+#if CHECKSUM_CHECK_IP_HW
|
||||
+// for ip4_input
|
||||
+static inline u64_t is_cksum_ipbad(struct pbuf *p) {
|
||||
+ return p->ol_flags & (PKT_RX_IP_CKSUM_BAD);
|
||||
+}
|
||||
+#endif /* CHECKSUM_CHECK_IP_HW */
|
||||
+
|
||||
+#if CHECKSUM_CHECK_TCP_HW
|
||||
+// for tcp_input
|
||||
+static inline u64_t is_cksum_tcpbad(struct pbuf *p) {
|
||||
+ return p->ol_flags & (PKT_RX_L4_CKSUM_BAD);
|
||||
+}
|
||||
+#endif /* CHECKSUM_CHECK_TCP_HW */
|
||||
+
|
||||
+#if CHECKSUM_GEN_IP_HW
|
||||
+static inline void ethh_cksum_set(struct pbuf *p, u16_t len) {
|
||||
+ p->l2_len = len;
|
||||
+}
|
||||
+
|
||||
+// replaces IPH_CHKSUM_SET
|
||||
+static inline void iph_cksum_set(struct pbuf *p, u16_t len, bool do_ipcksum) {
|
||||
+ p->ol_flags |= PKT_TX_IPV4;
|
||||
+ if (do_ipcksum) {
|
||||
+ p->ol_flags |= PKT_TX_IP_CKSUM;
|
||||
+ }
|
||||
+ p->l3_len = len;
|
||||
+}
|
||||
+#endif /* CHECKSUM_GEN_IP_HW */
|
||||
+
|
||||
+// replace ip_chksum_pseudo
|
||||
+#if CHECKSUM_GEN_TCP_HW
|
||||
+#include <rte_ip.h>
|
||||
+
|
||||
+static inline void tcph_cksum_set(struct pbuf *p, u16_t len) {
|
||||
+ (void)len;
|
||||
+ p->ol_flags |= PKT_TX_TCP_CKSUM;
|
||||
+}
|
||||
+
|
||||
+static inline u16_t ip_chksum_pseudo_offload(u8_t proto, u16_t proto_len,
|
||||
+ const ip_addr_t *src, const ip_addr_t *dst)
|
||||
+{
|
||||
+ struct ipv4_psd_header {
|
||||
+ uint32_t src_addr; /* IP address of source host. */
|
||||
+ uint32_t dst_addr; /* IP address of destination host. */
|
||||
+ uint8_t zero; /* zero. */
|
||||
+ uint8_t proto; /* L4 protocol type. */
|
||||
+ uint16_t len; /* L4 length. */
|
||||
+ } psd_hdr;
|
||||
+
|
||||
+ psd_hdr.src_addr = ip4_addr_get_u32(src);
|
||||
+ psd_hdr.dst_addr = ip4_addr_get_u32(dst);
|
||||
+ psd_hdr.proto = proto;
|
||||
+ psd_hdr.len = lwip_htons(proto_len);
|
||||
+ psd_hdr.zero = 0;
|
||||
+
|
||||
+ return rte_raw_cksum(&psd_hdr, sizeof(psd_hdr));
|
||||
+}
|
||||
+#endif /* CHECKSUM_GEN_TCP_HW */
|
||||
+
|
||||
+#endif /* USE_LIBOS */
|
||||
+#endif /* __DPDK_CKSUM_H__ */
|
||||
diff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h
|
||||
index ef2f61a..e68d0bf 100644
|
||||
--- a/src/include/lwip/pbuf.h
|
||||
+++ b/src/include/lwip/pbuf.h
|
||||
@@ -219,6 +219,14 @@ struct pbuf {
|
||||
|
||||
/** For incoming packets, this contains the input netif's index */
|
||||
u8_t if_idx;
|
||||
+#if USE_LIBOS && CHECKSUM_OFFLOAD_ALL
|
||||
+ /** checksum offload ol_flags */
|
||||
+ u64_t ol_flags;
|
||||
+ /** checksum offload l2_len */
|
||||
+ u64_t l2_len:7;
|
||||
+ /** checksum offload l3_len */
|
||||
+ u64_t l3_len:9;
|
||||
+#endif /* USE_LIBOS CHECKSUM_OFFLOAD_SWITCH */
|
||||
};
|
||||
|
||||
|
||||
@@ -268,9 +276,8 @@ void pbuf_free_ooseq(void);
|
||||
|
||||
/* Initializes the pbuf module. This call is empty for now, but may not be in future. */
|
||||
#define pbuf_init()
|
||||
-
|
||||
#if USE_LIBOS
|
||||
-struct pbuf *lwip_alloc_pbuf(pbuf_layer l, u16_t length, pbuf_type type);
|
||||
+struct pbuf *lwip_alloc_pbuf(pbuf_layer layer, uint16_t length, pbuf_type type);
|
||||
#endif
|
||||
struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
|
||||
struct pbuf *pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type);
|
||||
diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h
|
||||
index e0364a2..df587c0 100644
|
||||
--- a/src/include/lwipopts.h
|
||||
+++ b/src/include/lwipopts.h
|
||||
@@ -129,14 +129,6 @@
|
||||
|
||||
#define LWIP_STATS_DISPLAY 1
|
||||
|
||||
-#define CHECKSUM_GEN_IP 1 /* master switch */
|
||||
-
|
||||
-#define CHECKSUM_GEN_TCP 1 /* master switch */
|
||||
-
|
||||
-#define CHECKSUM_CHECK_IP 1 /* master switch */
|
||||
-
|
||||
-#define CHECKSUM_CHECK_TCP 1 /* master switch */
|
||||
-
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
|
||||
#define USE_LIBOS 1
|
||||
@@ -177,6 +169,28 @@
|
||||
|
||||
#define ARP_TABLE_SIZE 512
|
||||
|
||||
+/* ---------------------------------------
|
||||
+ * ------- NIC offloads --------
|
||||
+ * ---------------------------------------
|
||||
+ */
|
||||
+#define LWIP_CHECKSUM_CTRL_PER_NETIF 1 /* checksum ability check before checksum*/
|
||||
+
|
||||
+// rx cksum
|
||||
+#define CHECKSUM_CHECK_IP 1 /* master switch */
|
||||
+#define CHECKSUM_CHECK_TCP 1 /* master switch */
|
||||
+// tx cksum
|
||||
+#define CHECKSUM_GEN_IP 1 /* master switch */
|
||||
+#define CHECKSUM_GEN_TCP 1 /* master switch */
|
||||
+
|
||||
+// rx offload cksum
|
||||
+#define CHECKSUM_CHECK_IP_HW (1 && CHECKSUM_CHECK_IP) /* hardware switch */
|
||||
+#define CHECKSUM_CHECK_TCP_HW (1 && CHECKSUM_CHECK_TCP) /* hardware switch */
|
||||
+// tx offload cksum
|
||||
+#define CHECKSUM_GEN_IP_HW (1 && CHECKSUM_GEN_IP) /* hardware switch */
|
||||
+#define CHECKSUM_GEN_TCP_HW (1 && CHECKSUM_GEN_TCP) /* hardware switch */
|
||||
+
|
||||
+#define CHECKSUM_OFFLOAD_ALL (CHECKSUM_GEN_IP_HW || CHECKSUM_GEN_TCP_HW || CHECKSUM_CHECK_IP_HW || CHECKSUM_CHECK_TCP_HW)
|
||||
+
|
||||
#if USE_LIBOS
|
||||
#define PER_THREAD __thread
|
||||
#else
|
||||
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
|
||||
index 36bcaed..eec4e8e 100644
|
||||
--- a/src/include/lwipsock.h
|
||||
+++ b/src/include/lwipsock.h
|
||||
@@ -36,7 +36,7 @@
|
||||
+#include <stdbool.h>
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/api.h"
|
||||
|
||||
-#include "posix_api.h"
|
||||
#include "eventpoll.h"
|
||||
|
||||
/* move some definitions to the lwipsock.h for libnet to use, and
|
||||
@@ -62,7 +61,8 @@ union lwip_sock_lastdata {
|
||||
|
||||
#if USE_LIBOS
|
||||
struct protocol_stack;
|
||||
-struct weakup_poll;
|
||||
+struct wakeup_poll;
|
||||
+struct rte_ring;
|
||||
#endif
|
||||
/** Contains all internal pointers and states used for a socket */
|
||||
struct lwip_sock {
|
||||
@@ -93,16 +93,16 @@ struct lwip_sock {
|
||||
|
||||
#if USE_LIBOS
|
||||
uint32_t epoll_events; /* registered events */
|
||||
- uint32_t events; /* available events */
|
||||
- volatile bool have_event; /* avoid recurring events */
|
||||
- volatile bool have_rpc_send; /* avoid recurring rpc_send */
|
||||
+ volatile uint32_t events; /* available events */
|
||||
epoll_data_t ep_data;
|
||||
- struct weakup_poll *weakup;
|
||||
+ struct wakeup_poll *wakeup;
|
||||
struct protocol_stack *stack;
|
||||
- void *recv_ring;
|
||||
+ struct rte_ring *recv_ring;
|
||||
+ struct rte_ring *recv_wait_free;
|
||||
struct pbuf *recv_lastdata; /* unread data in one pbuf */
|
||||
struct pbuf *send_lastdata; /* unread data in one pbuf */
|
||||
- void *send_ring;
|
||||
+ struct rte_ring *send_ring;
|
||||
+ struct rte_ring *send_idle_ring;
|
||||
int32_t recv_flags;
|
||||
int32_t send_flags;
|
||||
bool wait_close;
|
||||
@@ -112,7 +112,6 @@ struct lwip_sock {
|
||||
struct list_node listen_list;
|
||||
struct list_node recv_list;
|
||||
struct list_node event_list;
|
||||
- struct list_node wakeup_list;
|
||||
struct list_node send_list;
|
||||
int32_t nextfd; /* listenfd list */
|
||||
#endif
|
||||
@@ -160,6 +159,7 @@ get_socket_without_errno(int s)
|
||||
|
||||
extern void add_recv_list(int32_t fd);
|
||||
extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags);
|
||||
+extern struct pbuf *write_lwip_data(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags);
|
||||
extern void gazelle_clean_sock(int32_t fd);
|
||||
extern void gazelle_init_sock(int32_t fd);
|
||||
#endif /* USE_LIBOS */
|
||||
diff --git a/src/netif/ethernet.c b/src/netif/ethernet.c
|
||||
index dd171e2..ab976a8 100644
|
||||
--- a/src/netif/ethernet.c
|
||||
+++ b/src/netif/ethernet.c
|
||||
@@ -56,6 +56,10 @@
|
||||
#include "netif/ppp/pppoe.h"
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
+#if USE_LIBOS && (CHECKSUM_GEN_TCP_HW || CHECKSUM_GEN_IP_HW)
|
||||
+#include "dpdk_cksum.h"
|
||||
+#endif
|
||||
+
|
||||
#ifdef LWIP_HOOK_FILENAME
|
||||
#include LWIP_HOOK_FILENAME
|
||||
#endif
|
||||
@@ -308,6 +312,10 @@ ethernet_output(struct netif * netif, struct pbuf * p,
|
||||
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE,
|
||||
("ethernet_output: sending packet %p\n", (void *)p));
|
||||
|
||||
+#if CHECKSUM_GEN_IP_HW || CHECKSUM_GEN_TCP_HW
|
||||
+ ethh_cksum_set(p, sizeof(*ethhdr));
|
||||
+#endif
|
||||
+
|
||||
/* send the packet */
|
||||
return netif->linkoutput(netif, p);
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,33 +1,34 @@
|
||||
From ffbe075d5623c44bbf37618cce78d09ccd4e6760 Mon Sep 17 00:00:00 2001
|
||||
From: Florent Matignon <florent.matignon@gmail.com>
|
||||
Date: Thu, 20 Sep 2018 16:40:34 +0200
|
||||
Subject: [PATCH] bug #54700: Unexpected expiry of pending ARP table entry
|
||||
New etharp queries should restart the 5 second timeout on the ARP
|
||||
table entry if it is still pending.
|
||||
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
|
||||
Conflict: NA
|
||||
Reference: https://git.savannah.gnu.org/cgit/lwip.git/commit/?id=ffbe075d5623c44bbf37618cce78d09ccd4e6760
|
||||
---
|
||||
src/core/ipv4/etharp.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
diff --git a/src/core/ipv4/etharp.c b/src/core/ipv4/etharp.c
|
||||
index b3b7c73c..9d7bf299 100644
|
||||
--- a/src/core/ipv4/etharp.c
|
||||
+++ b/src/core/ipv4/etharp.c
|
||||
@@ -984,6 +984,14 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
|
||||
/* We don't re-send arp request in etharp_tmr, but we still queue packets,
|
||||
since this failure could be temporary, and the next packet calling
|
||||
etharp_query again could lead to sending the queued packets. */
|
||||
+ } else {
|
||||
+ /* ARP request successfully sent */
|
||||
+ if ((arp_table[i].state == ETHARP_STATE_PENDING) && !is_new_entry) {
|
||||
+ /* A new ARP request has been sent for a pending entry. Reset the ctime to
|
||||
+ not let it expire too fast. */
|
||||
+ LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: reset ctime for entry %"S16_F"\n", (s16_t)i));
|
||||
+ arp_table[i].ctime = 0;
|
||||
+ }
|
||||
}
|
||||
if (q == NULL) {
|
||||
return result;
|
||||
--
|
||||
2.28.0.windows.1
|
||||
From ffbe075d5623c44bbf37618cce78d09ccd4e6760 Mon Sep 17 00:00:00 2001
|
||||
From: Florent Matignon <florent.matignon@gmail.com>
|
||||
Date: Thu, 20 Sep 2018 16:40:34 +0200
|
||||
Subject: [PATCH] bug #54700: Unexpected expiry of pending ARP table entry
|
||||
New etharp queries should restart the 5 second timeout on the ARP
|
||||
table entry if it is still pending.
|
||||
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
|
||||
Conflict: NA
|
||||
Reference: https://git.savannah.gnu.org/cgit/lwip.git/commit/?id=ffbe075d5623c44bbf37618cce78d09ccd4e6760
|
||||
---
|
||||
src/core/ipv4/etharp.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
diff --git a/src/core/ipv4/etharp.c b/src/core/ipv4/etharp.c
|
||||
index 442aac0..c3a5a10 100644
|
||||
--- a/src/core/ipv4/etharp.c
|
||||
+++ b/src/core/ipv4/etharp.c
|
||||
@@ -983,6 +983,14 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
|
||||
/* We don't re-send arp request in etharp_tmr, but we still queue packets,
|
||||
since this failure could be temporary, and the next packet calling
|
||||
etharp_query again could lead to sending the queued packets. */
|
||||
+ } else {
|
||||
+ /* ARP request successfully sent */
|
||||
+ if ((arp_table[i].state == ETHARP_STATE_PENDING) && !is_new_entry) {
|
||||
+ /* A new ARP request has been sent for a pending entry. Reset the ctime to
|
||||
+ not let it expire too fast. */
|
||||
+ LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: reset ctime for entry %"S16_F"\n", (s16_t)i));
|
||||
+ arp_table[i].ctime = 0;
|
||||
+ }
|
||||
}
|
||||
if (q == NULL) {
|
||||
return result;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
|
||||
74
lwip.spec
74
lwip.spec
@ -4,18 +4,41 @@
|
||||
Summary: lwip is a small independent implementation of the TCP/IP protocol suite
|
||||
Name: lwip
|
||||
Version: 2.1.2
|
||||
Release: 2
|
||||
Release: 3
|
||||
License: BSD
|
||||
URL: http://savannah.nongnu.org/projects/lwip/
|
||||
Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip
|
||||
|
||||
Patch0: 0001-add-makefile.patch
|
||||
Patch1: backport-bug-54700-Unexpected-expiry-of-pending-ARP-table-ent.patch
|
||||
Patch2: backport-tcp-Fix-double-free-in-tcp_split_unsent_seg.patch
|
||||
Patch3: backport-tcp-fix-sequence-number-comparison.patch
|
||||
Patch4: backport-tcp-tighten-up-checks-for-received-SYN.patch
|
||||
Patch6001: backport-bug-54700-Unexpected-expiry-of-pending-ARP-table-ent.patch
|
||||
Patch6002: backport-tcp-Fix-double-free-in-tcp_split_unsent_seg.patch
|
||||
Patch6003: backport-tcp-fix-sequence-number-comparison.patch
|
||||
Patch6004: backport-tcp-tighten-up-checks-for-received-SYN.patch
|
||||
|
||||
BuildRequires: gcc-c++ dos2unix
|
||||
Patch9001: 0001-add-makefile.patch
|
||||
Patch9002: 0002-adapt-lstack.patch
|
||||
Patch9003: 0003-fix-the-occasional-coredump-when-the-lwip-exits.patch
|
||||
Patch9004: 0004-fix-error-of-deleting-conn-table-in-connect.patch
|
||||
Patch9005: 0005-syn-rcvd-state-reg-conn-into-conntable.patch
|
||||
Patch9006: 0006-fix-coredump-in-etharp.patch
|
||||
Patch9007: 0007-gazelle-fix-epoll_ctl-EPOLLET-mode-error.patch
|
||||
Patch9008: 0008-gazelle-fix-lwip_accept-memcpy-sockaddr-large.patch
|
||||
Patch9009: 0009-fix-stack-buffer-overflow-when-memcpy-addr.patch
|
||||
Patch9010: 0010-fix-the-incomplete-release-of-the-conntable.patch
|
||||
Patch9011: 0011-remove-gazelle-tcp-conn-func.patch
|
||||
Patch9012: 0012-fix-incomplete-resource-release-in-lwip-close.patch
|
||||
Patch9013: 0013-remove-gazelle-syscall-thread.patch
|
||||
Patch9014: 0014-fix-some-compile-errors.patch
|
||||
Patch9015: 0015-fix-tcp-port-alloc-issue.patch
|
||||
Patch9016: 0016-lstack-support-mysql-mode.patch
|
||||
Patch9017: 0017-support-REUSEPOR-option.patch
|
||||
Patch9018: 0018-exec-gazelle_init_sock-before-read-event.patch
|
||||
Patch9019: 0019-gazelle-reduce-copy-in-send.patch
|
||||
Patch9020: 0020-remove-chose_dlsym_handle-function-set-handle-to-RTL.patch
|
||||
Patch9021: 0021-refactor-event-if-ring-is-full-the-node-is-added-to-.patch
|
||||
Patch9022: 0022-notify-app-that-sock-state-changes-to-CLOSE_WAIT.patch
|
||||
Patch9023: 0023-refactor-event-and-checksum-offload-support.patch
|
||||
|
||||
BuildRequires: gcc-c++ dos2unix dpdk-devel
|
||||
|
||||
#Requires:
|
||||
|
||||
@ -28,11 +51,33 @@ lwip is a small independent implementation of the TCP/IP protocol suite.
|
||||
%setup -n %{name}-%{version} -q
|
||||
find %{_builddir}/%{name}-%{version} -type f -exec dos2unix -q {} \;
|
||||
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch6001 -p1
|
||||
%patch6002 -p1
|
||||
%patch6003 -p1
|
||||
%patch6004 -p1
|
||||
%patch9001 -p1
|
||||
%patch9002 -p1
|
||||
%patch9003 -p1
|
||||
%patch9004 -p1
|
||||
%patch9005 -p1
|
||||
%patch9006 -p1
|
||||
%patch9007 -p1
|
||||
%patch9008 -p1
|
||||
%patch9009 -p1
|
||||
%patch9010 -p1
|
||||
%patch9011 -p1
|
||||
%patch9012 -p1
|
||||
%patch9013 -p1
|
||||
%patch9014 -p1
|
||||
%patch9015 -p1
|
||||
%patch9016 -p1
|
||||
%patch9017 -p1
|
||||
%patch9018 -p1
|
||||
%patch9019 -p1
|
||||
%patch9020 -p1
|
||||
%patch9021 -p1
|
||||
%patch9022 -p1
|
||||
%patch9023 -p1
|
||||
|
||||
%build
|
||||
cd %{_builddir}/%{name}-%{version}/src
|
||||
@ -48,7 +93,10 @@ cd %{_builddir}/%{name}-%{version}/src
|
||||
%{_libdir}/liblwip.a
|
||||
|
||||
%changelog
|
||||
* Mon Sep 06 2020 jiangheng<jiangheng12@huawei.com> - 2.1.2-2
|
||||
* Tue Jun 07 2022 xiusailong<xiusailong@huawei.com> - 2.1.2-3
|
||||
- support gazelle feature
|
||||
|
||||
* Mon Sep 06 2021 jiangheng<jiangheng12@huawei.com> - 2.1.2-2
|
||||
- backport some patches from community
|
||||
|
||||
* Mon Nov 30 2020 peanut_huang<huangliming5@huawei.com> - 2.1.2-1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user