diff --git a/0088-modify-log-info-err.patch b/0088-modify-log-info-err.patch new file mode 100644 index 0000000000000000000000000000000000000000..43bafbfe6dbc4371aa4379b1ca1506a6ca9b0aef --- /dev/null +++ b/0088-modify-log-info-err.patch @@ -0,0 +1,82 @@ +From f1b954fd737ca0e7571019f88b18a926ce849e6b Mon Sep 17 00:00:00 2001 +From: hantwofish +Date: Tue, 5 Dec 2023 10:57:46 +0800 +Subject: [PATCH] modify log info err + +--- + src/core/tcp.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/src/core/tcp.c b/src/core/tcp.c +index 3c7bbd0..2cfee11 100644 +--- a/src/core/tcp.c ++++ b/src/core/tcp.c +@@ -1397,17 +1397,17 @@ tcp_slowtmr_start: + + if (pcb->state == SYN_SENT && pcb->nrtx >= TCP_SYNMAXRTX) { + ++pcb_remove; +- LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: max SYN retries reached loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); ++ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: max SYN retries reached local_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); + } else if (pcb->nrtx >= TCP_MAXRTX) { + ++pcb_remove; +- LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: max DATA retries reached loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); ++ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: max DATA retries reached local_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); + } else { + if (pcb->persist_backoff > 0) { + LWIP_ASSERT("tcp_slowtimr: persist ticking with in-flight data", pcb->unacked == NULL); + LWIP_ASSERT("tcp_slowtimr: persist ticking with empty send buffer", pcb->unsent != NULL); + if (pcb->persist_probe >= TCP_MAXRTX) { + ++pcb_remove; /* max probes reached */ +- LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: persist_probe is greater TCP_MAXRTX loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); ++ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: persist_probe is greater TCP_MAXRTX local_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); + } else { + u8_t backoff_cnt = tcp_persist_backoff[pcb->persist_backoff - 1]; + if (pcb->persist_cnt < backoff_cnt) { +@@ -1491,7 +1491,7 @@ tcp_slowtmr_start: + if ((u32_t)(tcp_ticks - pcb->tmr) > + TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { + ++pcb_remove; +- LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2 loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); ++ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2 local_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); + } + } + } +@@ -1502,7 +1502,7 @@ tcp_slowtmr_start: + (pcb->state == CLOSE_WAIT))) { + if ((u32_t)(tcp_ticks - pcb->tmr) > + (pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL) { +- LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); ++ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to local_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); + ip_addr_debug_print_val(TCP_DEBUG, pcb->remote_ip); + LWIP_DEBUGF(TCP_DEBUG, ("\n")); + +@@ -1524,7 +1524,7 @@ tcp_slowtmr_start: + #if TCP_QUEUE_OOSEQ + if (pcb->ooseq != NULL && + (tcp_ticks - pcb->tmr >= (u32_t)pcb->rto * TCP_OOSEQ_TIMEOUT)) { +- LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: dropping OOSEQ queued data loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); ++ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: dropping OOSEQ queued data local_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); + tcp_free_ooseq(pcb); + } + #endif /* TCP_QUEUE_OOSEQ */ +@@ -1534,7 +1534,7 @@ tcp_slowtmr_start: + if ((u32_t)(tcp_ticks - pcb->tmr) > + TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) { + ++pcb_remove; +- LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); ++ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD local_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); + } + } + +@@ -1542,7 +1542,7 @@ tcp_slowtmr_start: + if (pcb->state == LAST_ACK) { + if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { + ++pcb_remove; +- LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: removing pcb stuck in LAST-ACK loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); ++ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: removing pcb stuck in LAST-ACK local_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); + } + } + +-- +2.33.0 + diff --git a/0089-add-struct-gz-addr.patch b/0089-add-struct-gz-addr.patch new file mode 100644 index 0000000000000000000000000000000000000000..09729fd66cc26c5ee52f7ea4ab3b7c3de98bab02 --- /dev/null +++ b/0089-add-struct-gz-addr.patch @@ -0,0 +1,97 @@ +diff -Nur lwip-org/src/core/tcp.c lwip-gz-addr/src/core/tcp.c +--- lwip-org/src/core/tcp.c 2023-12-04 14:10:25.364481010 +0800 ++++ lwip-gz-addr/src/core/tcp.c 2023-12-04 14:33:31.712481010 +0800 +@@ -1161,7 +1161,7 @@ + + if (__atomic_load_n(&port_state[tcp_port - TCP_LOCAL_PORT_RANGE_START], __ATOMIC_ACQUIRE) == 0) { + #if GAZELLE_ENABLE +- if (port_in_stack_queue(pcb->remote_ip, pcb->local_ip, pcb->remote_port, tcp_port)) { ++ if (port_in_stack_queue((gz_addr_t *)&pcb->remote_ip, (gz_addr_t *)&pcb->local_ip, pcb->remote_port, tcp_port)) { + tmp_port = tcp_port; + __atomic_store_n(&port_state[tcp_port - TCP_LOCAL_PORT_RANGE_START], 1, __ATOMIC_RELEASE); + break; +diff -Nur lwip-org/src/core/udp.c lwip-gz-addr/src/core/udp.c +--- lwip-org/src/core/udp.c 2023-12-04 14:10:25.364481010 +0800 ++++ lwip-gz-addr/src/core/udp.c 2023-12-04 14:19:58.832481010 +0800 +@@ -132,7 +132,7 @@ + } + + if (__atomic_load_n(&port_state[udp_port - UDP_LOCAL_PORT_RANGE_START], __ATOMIC_ACQUIRE) == 0) { +- if (port_in_stack_queue(dst_pcb->remote_ip, dst_pcb->local_ip, dst_pcb->remote_port, udp_port)) { ++ if (port_in_stack_queue((gz_addr_t *)&dst_pcb->remote_ip, (gz_addr_t *)&dst_pcb->local_ip, dst_pcb->remote_port, udp_port)) { + tmp_port = udp_port; + __atomic_store_n(&port_state[udp_port - UDP_LOCAL_PORT_RANGE_START], 1, __ATOMIC_RELEASE); + break; +diff -Nur lwip-org/src/include/lwipopts.h lwip-gz-addr/src/include/lwipopts.h +--- lwip-org/src/include/lwipopts.h 2023-12-04 14:10:25.368481010 +0800 ++++ lwip-gz-addr/src/include/lwipopts.h 2023-12-06 19:29:24.520481010 +0800 +@@ -184,6 +184,7 @@ + */ + #define LWIP_IPV6 1 + #define IP6_HLEN 40 ++#define LWIP_IPV6_SCOPES 1 + + /* + --------------------------------- +diff -Nur lwip-org/src/include/reg_sock.h lwip-gz-addr/src/include/reg_sock.h +--- lwip-org/src/include/reg_sock.h 2023-12-04 14:10:25.368481010 +0800 ++++ lwip-gz-addr/src/include/reg_sock.h 2023-12-06 19:41:19.792481010 +0800 +@@ -34,7 +34,35 @@ + #define __REG_SOCK_H__ + + #include +-#include "lwip/ip_addr.h" ++ ++#include "lwipopts.h" ++ ++/* compatible with ip4_addr_t */ ++struct gz_ip4 { ++ uint32_t addr; ++}; ++ ++/* compatible with ip6_addr_t */ ++#if LWIP_IPV6 ++struct gz_ip6 { ++ uint32_t addr[4]; ++#if LWIP_IPV6_SCOPES ++ uint8_t zone; ++#endif /* LWIP_IPV6_SCOPES */ ++}; ++#endif /* LWIP_IPV6 */ ++ ++/* gazelle ip address, compatible with ip_addr_t */ ++typedef struct gz_addr { ++ union { ++#if LWIP_IPV6 ++ struct gz_ip6 ip6; ++#endif /* LWIP_IPV6 */ ++ struct gz_ip4 ip4; ++ } u_addr; ++ /** @ref lwip_ip_addr_type */ ++ uint8_t type; ++} gz_addr_t; + + enum reg_ring_type { + REG_RING_TCP_LISTEN = 0, +@@ -45,10 +73,12 @@ + }; + + struct gazelle_quintuple { +- uint32_t protocol; ++ uint32_t protocol; + /* net byte order */ + uint16_t src_port; + uint16_t dst_port; ++ ++ /* TODO: replace with gz_addr_t */ + uint32_t src_ip; + uint32_t dst_ip; + #if LWIP_IPV6 +@@ -65,6 +95,6 @@ + }; + + extern int vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple); +-extern bool port_in_stack_queue(ip_addr_t src_ip, ip_addr_t dst_ip, uint16_t src_port, uint16_t dst_port); ++extern bool port_in_stack_queue(gz_addr_t *src_ip, gz_addr_t *dst_ip, uint16_t src_port, uint16_t dst_port); + + #endif /* __REG_SOCK_H__ */ diff --git a/0090-frag-fix-coredump-when-get-netif.patch b/0090-frag-fix-coredump-when-get-netif.patch new file mode 100644 index 0000000000000000000000000000000000000000..e5159c4bf173823709269632aad1f4adac803ed6 --- /dev/null +++ b/0090-frag-fix-coredump-when-get-netif.patch @@ -0,0 +1,28 @@ +From 5e5195ad88819a77d59038ec49004d1e11801d08 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Fri, 8 Dec 2023 11:14:15 +0800 +Subject: [PATCH] frag: fix coredump when get netif + +--- + src/core/ipv4/ip4_frag.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/core/ipv4/ip4_frag.c b/src/core/ipv4/ip4_frag.c +index f63a99e..b4a183a 100644 +--- a/src/core/ipv4/ip4_frag.c ++++ b/src/core/ipv4/ip4_frag.c +@@ -640,9 +640,9 @@ ip4_reass(struct pbuf *p) + IPH_CHKSUM_SET(fraghdr, 0); + /* @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__NETIF_CHECKSUM_ENABLED(netif_default, NETIF_CHECKSUM_GEN_IP) { + #if CHECKSUM_GEN_IP_HW +- if (netif_get_txol_flags(ip_current_input_netif()) & DEV_TX_OFFLOAD_IPV4_CKSUM) { ++ if (netif_get_txol_flags(netif_default) & DEV_TX_OFFLOAD_IPV4_CKSUM) { + iph_cksum_set(p, IP_HLEN, 1); + } else { + iph_cksum_set(p, IP_HLEN, 0); +-- +2.27.0 + diff --git a/0091-add-fd-log-info-and-fix-wrong-port-log-info.patch b/0091-add-fd-log-info-and-fix-wrong-port-log-info.patch new file mode 100644 index 0000000000000000000000000000000000000000..a2a8f9dd79ca18cd3cd1741fea126223eac13d5b --- /dev/null +++ b/0091-add-fd-log-info-and-fix-wrong-port-log-info.patch @@ -0,0 +1,85 @@ +From 9ef6e86cbbd7bff2d1980f9b88f3b6f9ec1457b5 Mon Sep 17 00:00:00 2001 +From: yangchen +Date: Wed, 6 Dec 2023 08:43:23 +0800 +Subject: [PATCH] add fd log info and fix wrong port log info + +--- + src/api/sockets.c | 2 +- + src/core/tcp_in.c | 20 ++++++++++---------- + 2 files changed, 11 insertions(+), 11 deletions(-) + +diff --git a/src/api/sockets.c b/src/api/sockets.c +index 65c69d4..d488b5b 100644 +--- a/src/api/sockets.c ++++ b/src/api/sockets.c +@@ -2797,7 +2797,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) + #endif + break; + case NETCONN_EVT_ERROR: +- LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("event_callback: have errevent, err=%d\n", conn->pending_err)); ++ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("event_callback: have errevent, err=%d, fd=%d\n", conn->pending_err, conn->socket)); + sock->errevent = 1; + #if GAZELLE_ENABLE + if (netif_is_rtc_mode(netif_default)) { +diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c +index 8ed91b5..24706c1 100644 +--- a/src/core/tcp_in.c ++++ b/src/core/tcp_in.c +@@ -688,8 +688,8 @@ aborted: + TCP_STATS_INC(tcp.proterr); + TCP_STATS_INC(tcp.drop); + LWIP_DEBUGF(TCP_RST_DEBUG | GAZELLE_DEBUG_SERIOUS, +- ("tcp_input: no PCB match found, send RST, dest port=%d, src port=%d\n", +- lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src))); ++ ("tcp_input: no PCB match found, send RST, local_port=%d, remote_port=%d\n", ++ tcphdr->src, tcphdr->dest)); + tcp_rst(NULL, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + } +@@ -765,8 +765,8 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) + /* For incoming segments with the ACK flag set, respond with a + RST. */ + LWIP_DEBUGF(TCP_RST_DEBUG | GAZELLE_DEBUG_SERIOUS, +- ("tcp_listen_input: ACK in LISTEN, send reset, dest port=%d, src port=%d\n", +- lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src))); ++ ("tcp_listen_input: ACK in LISTEN, send reset, local_port=%d, remote_port=%d\n", ++ tcphdr->src, tcphdr->dest)); + tcp_rst((const struct tcp_pcb *)pcb, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + } else if (flags & TCP_SYN) { +@@ -902,8 +902,8 @@ tcp_timewait_input(struct tcp_pcb *pcb) + if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd)) { + /* If the SYN is in the window it is an error, send a reset */ + LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, +- ("tcp_timewait_input: SYN in TIME_WAIT, send RST, dest port=%d, src port=%d\n", +- lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src))); ++ ("tcp_timewait_input: SYN in TIME_WAIT, send RST, local_port=%d, remote_port=%d\n", ++ tcphdr->src, tcphdr->dest)); + tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + return; +@@ -1072,8 +1072,8 @@ tcp_process(struct tcp_pcb *pcb) + /* received ACK? possibly a half-open connection */ + else if (flags & TCP_ACK) { + /* send a RST to bring the other side in a non-synchronized state. */ +- LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("tcp_process: ACK in SYN_SENT, send RST, dest port=%d, src port=%d\n", +- lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src))); ++ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("tcp_process: ACK in SYN_SENT, send RST, local_port=%d, remote_port=%d\n", ++ tcphdr->src, tcphdr->dest)); + tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + /* Resend SYN immediately (don't wait for rto timeout) to establish +@@ -1145,8 +1145,8 @@ tcp_process(struct tcp_pcb *pcb) + } else { + /* incorrect ACK number, send RST */ + LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, +- ("tcp_process: incorrect ACK number in SYN_RCVD, send RST, ackno=%d, lastack=%d, snd_nxt=%d, dest port=%d, src port=%d\n", +- ackno, pcb->lastack, pcb->snd_nxt, lwip_ntohs(tcphdr->dest), lwip_ntohs(tcphdr->src))); ++ ("tcp_process: incorrect ACK number in SYN_RCVD, send RST, ackno=%d, lastack=%d, snd_nxt=%d, local_port=%d, remote_port=%d\n", ++ ackno, pcb->lastack, pcb->snd_nxt, tcphdr->src, tcphdr->dest)); + tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + } +-- +2.33.0 + diff --git a/0092-fix-the-coredump-issue-when-UDP-traffic-is-sent.patch b/0092-fix-the-coredump-issue-when-UDP-traffic-is-sent.patch new file mode 100644 index 0000000000000000000000000000000000000000..5da581984ebb91554f0190115dca074344994db3 --- /dev/null +++ b/0092-fix-the-coredump-issue-when-UDP-traffic-is-sent.patch @@ -0,0 +1,30 @@ +From defef8f57ee35b510c4a542e54237f664ac31d5d Mon Sep 17 00:00:00 2001 +From: root +Date: Sat, 9 Dec 2023 16:54:47 +0800 +Subject: [PATCH] fix the coredump issue when UDP traffic is sent + +--- + src/api/sockets.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/api/sockets.c b/src/api/sockets.c +index d488b5b..a9d39ae 100644 +--- a/src/api/sockets.c ++++ b/src/api/sockets.c +@@ -1865,7 +1865,13 @@ lwip_sendto(int s, const void *data, size_t size, int flags, + } else + #endif /* LWIP_CHECKSUM_ON_COPY */ + { ++#if GAZELLE_ENABLE ++ /* In the gazelle scenario, the payload is stored in send_ring, ++ and the payload stores the sock pointer information. */ ++ buf.p->payload = (void *)sock; ++#else + MEMCPY(buf.p->payload, data, short_size); ++#endif + } + err = ERR_OK; + } +-- +2.30.0 + diff --git a/0093-modfiy-accept-null-pointer-when-new-conn-receive-RST-packet-in-listening.patch b/0093-modfiy-accept-null-pointer-when-new-conn-receive-RST-packet-in-listening.patch new file mode 100644 index 0000000000000000000000000000000000000000..df7ee1c22586f33c643f868efb23c0bc42b90147 --- /dev/null +++ b/0093-modfiy-accept-null-pointer-when-new-conn-receive-RST-packet-in-listening.patch @@ -0,0 +1,37 @@ +From dcdd7d73c6083a63fe966a68f11eddcafa3fd743 Mon Sep 17 00:00:00 2001 +From: hantwofish +Date: Thu, 14 Dec 2023 14:51:37 +0800 +Subject: [PATCH] resove null pointer + +--- + src/api/sockets.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/api/sockets.c b/src/api/sockets.c +index a9d39ae..0b3e4ea 100644 +--- a/src/api/sockets.c ++++ b/src/api/sockets.c +@@ -801,15 +801,17 @@ lwip_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) + #endif /* GAZELLE_ENABLE */ + nsock = &sockets[newsock - LWIP_SOCKET_OFFSET]; + #if GAZELLE_ENABLE ++ int ret = 0; + struct tcp_pcb *pcb = newconn->pcb.tcp; +- if (pcb->client_rx_ring != NULL && pcb->client_tx_ring != NULL) { +- if (find_same_node_memzone(pcb, nsock) != 0) { ++ if (pcb != NULL && pcb->client_rx_ring != NULL && pcb->client_tx_ring != NULL) { ++ ret = find_same_node_memzone(pcb, nsock); ++ } ++ if (pcb == NULL || ret != 0) { + netconn_delete(newconn); + free_socket(nsock, 1); + sock_set_errno(sock, ENOTCONN); + done_socket(sock); + return -1; +- } + } + #endif + +-- +2.33.0 + diff --git a/0094-lwip-log-fix-reversed-port-in-tcp_input.patch b/0094-lwip-log-fix-reversed-port-in-tcp_input.patch new file mode 100644 index 0000000000000000000000000000000000000000..1168db771bf8ca67a0fb58e7f0e7d9b241a8d818 --- /dev/null +++ b/0094-lwip-log-fix-reversed-port-in-tcp_input.patch @@ -0,0 +1,61 @@ +From ce3debdf4c4cd6701cdb323377477539a5fd13fa Mon Sep 17 00:00:00 2001 +From: yangchen +Date: Fri, 15 Dec 2023 17:21:54 +0800 +Subject: [PATCH] lwip log: fix reversed port in tcp_input + +--- + src/core/tcp_in.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c +index 24706c1..c76c114 100644 +--- a/src/core/tcp_in.c ++++ b/src/core/tcp_in.c +@@ -689,7 +689,7 @@ aborted: + TCP_STATS_INC(tcp.drop); + LWIP_DEBUGF(TCP_RST_DEBUG | GAZELLE_DEBUG_SERIOUS, + ("tcp_input: no PCB match found, send RST, local_port=%d, remote_port=%d\n", +- tcphdr->src, tcphdr->dest)); ++ tcphdr->dest, tcphdr->src)); + tcp_rst(NULL, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + } +@@ -766,7 +766,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) + RST. */ + LWIP_DEBUGF(TCP_RST_DEBUG | GAZELLE_DEBUG_SERIOUS, + ("tcp_listen_input: ACK in LISTEN, send reset, local_port=%d, remote_port=%d\n", +- tcphdr->src, tcphdr->dest)); ++ tcphdr->dest, tcphdr->src)); + tcp_rst((const struct tcp_pcb *)pcb, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + } else if (flags & TCP_SYN) { +@@ -903,7 +903,7 @@ tcp_timewait_input(struct tcp_pcb *pcb) + /* If the SYN is in the window it is an error, send a reset */ + LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, + ("tcp_timewait_input: SYN in TIME_WAIT, send RST, local_port=%d, remote_port=%d\n", +- tcphdr->src, tcphdr->dest)); ++ tcphdr->dest, tcphdr->src)); + tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + return; +@@ -1073,7 +1073,7 @@ tcp_process(struct tcp_pcb *pcb) + else if (flags & TCP_ACK) { + /* send a RST to bring the other side in a non-synchronized state. */ + LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("tcp_process: ACK in SYN_SENT, send RST, local_port=%d, remote_port=%d\n", +- tcphdr->src, tcphdr->dest)); ++ tcphdr->dest, tcphdr->src)); + tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + /* Resend SYN immediately (don't wait for rto timeout) to establish +@@ -1146,7 +1146,7 @@ tcp_process(struct tcp_pcb *pcb) + /* incorrect ACK number, send RST */ + LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, + ("tcp_process: incorrect ACK number in SYN_RCVD, send RST, ackno=%d, lastack=%d, snd_nxt=%d, local_port=%d, remote_port=%d\n", +- ackno, pcb->lastack, pcb->snd_nxt, tcphdr->src, tcphdr->dest)); ++ ackno, pcb->lastack, pcb->snd_nxt, tcphdr->dest, tcphdr->src)); + tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + } +-- +2.33.0 + diff --git a/0095-event_callback-del-errevent-log-if-err-is-ERR_OK.patch b/0095-event_callback-del-errevent-log-if-err-is-ERR_OK.patch new file mode 100644 index 0000000000000000000000000000000000000000..9260abc01b63aeca3ffeae55be0b592a5dad76ef --- /dev/null +++ b/0095-event_callback-del-errevent-log-if-err-is-ERR_OK.patch @@ -0,0 +1,27 @@ +From db1929c5698a672200bf96d7ece992f10a98a80c Mon Sep 17 00:00:00 2001 +From: yangchen +Date: Wed, 20 Dec 2023 17:37:42 +0800 +Subject: [PATCH] event_callback: del errevent log if err is ERR_OK + +--- + src/api/sockets.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/api/sockets.c b/src/api/sockets.c +index 0b3e4ea..f5b8ea6 100644 +--- a/src/api/sockets.c ++++ b/src/api/sockets.c +@@ -2805,7 +2805,9 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) + #endif + break; + case NETCONN_EVT_ERROR: +- LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("event_callback: have errevent, err=%d, fd=%d\n", conn->pending_err, conn->socket)); ++ if (conn->pending_err != ERR_OK) { ++ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("event_callback: have errevent, err=%d, fd=%d\n", conn->pending_err, conn->socket)); ++ } + sock->errevent = 1; + #if GAZELLE_ENABLE + if (netif_is_rtc_mode(netif_default)) { +-- +2.33.0 + diff --git a/0096-tcp_send_fin-add-the-fin-to-the-last-unsent-segment.patch b/0096-tcp_send_fin-add-the-fin-to-the-last-unsent-segment.patch new file mode 100644 index 0000000000000000000000000000000000000000..2e77f0eca1f65698626cacfa882ef72343abee05 --- /dev/null +++ b/0096-tcp_send_fin-add-the-fin-to-the-last-unsent-segment.patch @@ -0,0 +1,27 @@ +From c91f1d05c65526fe250cf5e5c32f9038721bc1d5 Mon Sep 17 00:00:00 2001 +From: yangchen +Date: Mon, 25 Dec 2023 12:39:56 +0800 +Subject: [PATCH] tcp_send_fin: add the fin to the last unsent segment + +--- + src/core/tcp_out.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c +index 137e3cf..e5c407e 100644 +--- a/src/core/tcp_out.c ++++ b/src/core/tcp_out.c +@@ -1195,8 +1195,8 @@ tcp_send_fin(struct tcp_pcb *pcb) + LWIP_ASSERT("tcp_send_fin: invalid pcb", pcb != NULL); + + /* first, try to add the fin to the last unsent segment */ +- if (pcb->unsent != NULL) { +- struct tcp_seg *last_unsent = pcb->unsent; ++ if (pcb->last_unsent != NULL) { ++ struct tcp_seg *last_unsent = pcb->last_unsent; + + if ((TCPH_FLAGS(last_unsent->tcphdr) & (TCP_SYN | TCP_FIN | TCP_RST)) == 0) { + /* no SYN/FIN/RST flag in the header, we can add the FIN flag */ +-- +2.33.0 + diff --git a/0097-Mod-the-issue-that-2w-connection-unable-to-establish.patch b/0097-Mod-the-issue-that-2w-connection-unable-to-establish.patch new file mode 100644 index 0000000000000000000000000000000000000000..764a155d3f1cc1a373d8d14e2bea8477ac8549c7 --- /dev/null +++ b/0097-Mod-the-issue-that-2w-connection-unable-to-establish.patch @@ -0,0 +1,275 @@ +From 212198780662639e0422419a25d28ff2bb0d421e Mon Sep 17 00:00:00 2001 +From: hantwofish +Date: Mon, 25 Dec 2023 15:36:45 +0800 +Subject: [PATCH] Mod the issue that 2w connection unable to establish in + Redis. + +--- + src/api/api_lib.c | 2 +- + src/api/api_msg.c | 2 +- + src/api/sockets.c | 19 ++++++++++++------- + src/core/init.c | 4 ++-- + src/core/tcp.c | 4 ++-- + src/core/tcp_in.c | 2 +- + src/include/lwip/api.h | 2 +- + src/include/lwip/opt.h | 2 +- + src/include/lwip/priv/api_msg.h | 2 +- + src/include/lwip/tcp.h | 8 ++++---- + src/include/lwipopts.h | 4 ++-- + 11 files changed, 28 insertions(+), 23 deletions(-) + +diff --git a/src/api/api_lib.c b/src/api/api_lib.c +index e73b81e..30e3422 100644 +--- a/src/api/api_lib.c ++++ b/src/api/api_lib.c +@@ -431,7 +431,7 @@ netconn_disconnect(struct netconn *conn) + * don't return any error (yet?)) + */ + err_t +-netconn_listen_with_backlog(struct netconn *conn, u8_t backlog) ++netconn_listen_with_backlog(struct netconn *conn, u16_t backlog) + { + #if LWIP_TCP + API_MSG_VAR_DECLARE(msg); +diff --git a/src/api/api_msg.c b/src/api/api_msg.c +index 531da40..91b8590 100644 +--- a/src/api/api_msg.c ++++ b/src/api/api_msg.c +@@ -1499,7 +1499,7 @@ lwip_netconn_do_listen(void *m) + /* connection is not closed, cannot listen */ + err = ERR_VAL; + } else { +- u8_t backlog; ++ u16_t backlog; + #if TCP_LISTEN_BACKLOG + backlog = msg->msg.lb.backlog; + #else /* TCP_LISTEN_BACKLOG */ +diff --git a/src/api/sockets.c b/src/api/sockets.c +index f5b8ea6..b7ee304 100644 +--- a/src/api/sockets.c ++++ b/src/api/sockets.c +@@ -447,7 +447,7 @@ tryget_socket_unconn_nouse(int fd) + if ((s < 0) || (s >= NUM_SOCKETS)) + #endif /* GAZELLE_ENABLE */ + { +- LWIP_DEBUGF(SOCKETS_DEBUG, ("tryget_socket_unconn(%d): invalid\n", fd)); ++ LWIP_DEBUGF(SOCKETS_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tryget_socket_unconn(%d): invalid\n", fd)); + return NULL; + } + return &sockets[s]; +@@ -521,7 +521,7 @@ get_socket(int fd) + struct lwip_sock *sock = tryget_socket(fd); + if (!sock) { + if ((fd < LWIP_SOCKET_OFFSET) || (fd >= (LWIP_SOCKET_OFFSET + NUM_SOCKETS))) { +- LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", fd)); ++ LWIP_DEBUGF(SOCKETS_DEBUG | GAZELLE_DEBUG_SERIOUS, ("get_socket(%d): invalid\n", fd)); + } + set_errno(EBADF); + return NULL; +@@ -588,6 +588,7 @@ alloc_socket(struct netconn *newconn, int accepted, int flags) + SYS_ARCH_PROTECT(lev); + i = posix_api->socket_fn(domain, type, protocol); + if (i == -1) { ++ LWIP_DEBUGF(SOCKETS_DEBUG | GAZELLE_DEBUG_SERIOUS, ("posix_api->socket_fn fail socket is -1")); + goto err; + } + +@@ -596,6 +597,7 @@ alloc_socket(struct netconn *newconn, int accepted, int flags) + } + + if ((i < LWIP_SOCKET_OFFSET) || (i >= sockets_num + LWIP_SOCKET_OFFSET)) { ++ LWIP_DEBUGF(SOCKETS_DEBUG | GAZELLE_DEBUG_SERIOUS, ("posix_api->socket_fn socket is %d, illegal\n", i)); + goto err; + } + +@@ -767,13 +769,14 @@ lwip_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) + + sock = get_socket(s); + if (!sock) { ++ LWIP_DEBUGF(SOCKETS_DEBUG | GAZELLE_DEBUG_SERIOUS, ("get_socket sock is null\n")); + return -1; + } + + /* wait for a new connection */ + err = netconn_accept(sock->conn, &newconn); + if (err != ERR_OK) { +- LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_acept failed, err=%d\n", s, err)); ++ LWIP_DEBUGF(SOCKETS_DEBUG | GAZELLE_DEBUG_SERIOUS, ("lwip_accept(%d): netconn_acept failed, err=%d\n", s, err)); + if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_TCP) { + sock_set_errno(sock, EOPNOTSUPP); + } else if (err == ERR_CLSD) { +@@ -788,6 +791,7 @@ lwip_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) + + newsock = alloc_socket(newconn, 1, flags); + if (newsock == -1) { ++ LWIP_DEBUGF(SOCKETS_DEBUG | GAZELLE_DEBUG_SERIOUS, ("alloc_socket fail newsock is -1\n")); + netconn_delete(newconn); + sock_set_errno(sock, ENFILE); + done_socket(sock); +@@ -807,6 +811,7 @@ lwip_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) + ret = find_same_node_memzone(pcb, nsock); + } + if (pcb == NULL || ret != 0) { ++ LWIP_DEBUGF(SOCKETS_DEBUG | GAZELLE_DEBUG_SERIOUS, ("alloc_socket fail pcb null flag=%u, ret=%d \n", (pcb == NULL), ret)); + netconn_delete(newconn); + free_socket(nsock, 1); + sock_set_errno(sock, ENOTCONN); +@@ -842,7 +847,7 @@ lwip_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) + /* get the IP address and port of the remote host */ + err = netconn_peer(newconn, &naddr, &port); + if (err != ERR_OK) { +- LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_peer failed, err=%d\n", s, err)); ++ LWIP_DEBUGF(SOCKETS_DEBUG | GAZELLE_DEBUG_SERIOUS, ("lwip_accept(%d): netconn_peer failed, err=%d\n", s, err)); + free_socket(nsock, 1); + sock_set_errno(sock, err_to_errno(err)); + done_socket(sock); +@@ -1059,10 +1064,10 @@ lwip_listen(int s, int backlog) + return -1; + } + +- /* limit the "backlog" parameter to fit in an u8_t */ +- backlog = LWIP_MIN(LWIP_MAX(backlog, 0), 0xff); ++ /* limit the "backlog" parameter to fit in an u16_t */ ++ backlog = LWIP_MIN(LWIP_MAX(backlog, 0), 0xffff); + +- err = netconn_listen_with_backlog(sock->conn, (u8_t)backlog); ++ err = netconn_listen_with_backlog(sock->conn, (u16_t)backlog); + + if (err != ERR_OK) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err)); +diff --git a/src/core/init.c b/src/core/init.c +index 6880fd3..8c59a7c 100644 +--- a/src/core/init.c ++++ b/src/core/init.c +@@ -160,8 +160,8 @@ PACK_STRUCT_END + #if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12))) + #error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h" + #endif +-#if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff))) +-#error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t" ++#if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xffff))) ++#error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u16_t" + #endif + #if (LWIP_TCP && LWIP_TCP_SACK_OUT && !TCP_QUEUE_OOSEQ) + #error "To use LWIP_TCP_SACK_OUT, TCP_QUEUE_OOSEQ needs to be enabled" +diff --git a/src/core/tcp.c b/src/core/tcp.c +index ca70a85..76f0ffd 100644 +--- a/src/core/tcp.c ++++ b/src/core/tcp.c +@@ -903,7 +903,7 @@ tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err) + * tpcb = tcp_listen_with_backlog(tpcb, backlog); + */ + struct tcp_pcb * +-tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) ++tcp_listen_with_backlog(struct tcp_pcb *pcb, u16_t backlog) + { + LWIP_ASSERT_CORE_LOCKED(); + return tcp_listen_with_backlog_and_err(pcb, backlog, NULL); +@@ -926,7 +926,7 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) + * tpcb = tcp_listen_with_backlog_and_err(tpcb, backlog, &err); + */ + struct tcp_pcb * +-tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err) ++tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u16_t backlog, err_t *err) + { + struct tcp_pcb_listen *lpcb = NULL; + err_t res; +diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c +index c76c114..e9ab96f 100644 +--- a/src/core/tcp_in.c ++++ b/src/core/tcp_in.c +@@ -785,7 +785,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) + SYN at a time when we have more memory available. */ + if (npcb == NULL) { + err_t err; +- LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n")); ++ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_listen_input: could not allocate PCB\n")); + TCP_STATS_INC(tcp.memerr); + TCP_EVENT_ACCEPT(pcb, NULL, pcb->callback_arg, ERR_MEM, err); + LWIP_UNUSED_ARG(err); /* err not useful here */ +diff --git a/src/include/lwip/api.h b/src/include/lwip/api.h +index ed237c7..a986cd4 100644 +--- a/src/include/lwip/api.h ++++ b/src/include/lwip/api.h +@@ -366,7 +366,7 @@ err_t netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port); + err_t netconn_bind_if(struct netconn *conn, u8_t if_idx); + err_t netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port); + err_t netconn_disconnect (struct netconn *conn); +-err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog); ++err_t netconn_listen_with_backlog(struct netconn *conn, u16_t backlog); + /** @ingroup netconn_tcp */ + #define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) + err_t netconn_accept(struct netconn *conn, struct netconn **new_conn); +diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h +index 57a1a53..6332d51 100644 +--- a/src/include/lwip/opt.h ++++ b/src/include/lwip/opt.h +@@ -1428,7 +1428,7 @@ + * 0xff is the maximum (u8_t). + */ + #if !defined TCP_DEFAULT_LISTEN_BACKLOG || defined __DOXYGEN__ +-#define TCP_DEFAULT_LISTEN_BACKLOG 0xff ++#define TCP_DEFAULT_LISTEN_BACKLOG 0xffff + #endif + + /** +diff --git a/src/include/lwip/priv/api_msg.h b/src/include/lwip/priv/api_msg.h +index 9e8ffc9..b36f00a 100644 +--- a/src/include/lwip/priv/api_msg.h ++++ b/src/include/lwip/priv/api_msg.h +@@ -145,7 +145,7 @@ struct api_msg { + #endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ + #if TCP_LISTEN_BACKLOG + struct { +- u8_t backlog; ++ u16_t backlog; + } lb; + #endif /* TCP_LISTEN_BACKLOG */ + } msg; +diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h +index 91a86c9..741e58f 100644 +--- a/src/include/lwip/tcp.h ++++ b/src/include/lwip/tcp.h +@@ -249,8 +249,8 @@ struct tcp_pcb_listen { + #endif /* LWIP_CALLBACK_API */ + + #if TCP_LISTEN_BACKLOG +- u8_t backlog; +- u8_t accepts_pending; ++ u16_t backlog; ++ u16_t accepts_pending; + #endif /* TCP_LISTEN_BACKLOG */ + + #if GAZELLE_TCP_REUSE_IPPORT +@@ -575,8 +575,8 @@ void tcp_bind_netif(struct tcp_pcb *pcb, const struct netif *netif); + err_t tcp_connect (struct tcp_pcb *pcb, const ip_addr_t *ipaddr, + u16_t port, tcp_connected_fn connected); + +-struct tcp_pcb * tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err); +-struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog); ++struct tcp_pcb * tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u16_t backlog, err_t *err); ++struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u16_t backlog); + /** @ingroup tcp_raw */ + #define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG) + +diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h +index 82cf881..44ed80f 100644 +--- a/src/include/lwipopts.h ++++ b/src/include/lwipopts.h +@@ -210,11 +210,11 @@ + + #define TCP_HLEN 20 + +-#define DEFAULT_ACCEPTMBOX_SIZE 1024 ++#define DEFAULT_ACCEPTMBOX_SIZE 4096 + #define DEFAULT_TCP_RECVMBOX_SIZE 4096 + + #define TCP_LISTEN_BACKLOG 1 +-#define TCP_DEFAULT_LISTEN_BACKLOG 0xff ++#define TCP_DEFAULT_LISTEN_BACKLOG 0xffff + + #define TCP_OVERSIZE TCP_MSS + #define LWIP_NETIF_TX_SINGLE_PBUF 1 +-- +2.33.0 + diff --git a/0098-remove-duplicate-lwip-log.patch b/0098-remove-duplicate-lwip-log.patch new file mode 100644 index 0000000000000000000000000000000000000000..16a847d0e3980648605d74e6ef80ead7f2c19c83 --- /dev/null +++ b/0098-remove-duplicate-lwip-log.patch @@ -0,0 +1,25 @@ +From 2d01f8467027e5a640ee6c7ed72d64d8e0247829 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Wed, 27 Dec 2023 10:40:54 +0800 +Subject: [PATCH] remove duplicate log + +--- + src/core/tcp_in.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c +index e9ab96f..69dcd26 100644 +--- a/src/core/tcp_in.c ++++ b/src/core/tcp_in.c +@@ -764,7 +764,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) + if (flags & TCP_ACK) { + /* For incoming segments with the ACK flag set, respond with a + RST. */ +- LWIP_DEBUGF(TCP_RST_DEBUG | GAZELLE_DEBUG_SERIOUS, ++ LWIP_DEBUGF(TCP_RST_DEBUG, + ("tcp_listen_input: ACK in LISTEN, send reset, local_port=%d, remote_port=%d\n", + tcphdr->dest, tcphdr->src)); + tcp_rst((const struct tcp_pcb *)pcb, ackno, seqno + tcplen, ip_current_dest_addr(), +-- +2.27.0 + diff --git a/0099-fix-rte_ring_create-time-consuming.patch b/0099-fix-rte_ring_create-time-consuming.patch new file mode 100644 index 0000000000000000000000000000000000000000..c544b2aa2004ab62672a2654e34110900811fa42 --- /dev/null +++ b/0099-fix-rte_ring_create-time-consuming.patch @@ -0,0 +1,142 @@ +From 01be1587c5e6771da95d6cf8d387c0b5ba15c275 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Wed, 27 Dec 2023 10:19:34 +0800 +Subject: [PATCH] fix rte_ring_create time consuming + +--- + src/api/sockets.c | 2 +- + src/api/sys_arch.c | 63 ++++++++++++++++++++++++++++--------- + src/include/arch/sys_arch.h | 4 +++ + 3 files changed, 54 insertions(+), 15 deletions(-) + +diff --git a/src/api/sockets.c b/src/api/sockets.c +index b7ee304..15053b3 100644 +--- a/src/api/sockets.c ++++ b/src/api/sockets.c +@@ -2810,7 +2810,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) + #endif + break; + case NETCONN_EVT_ERROR: +- if (conn->pending_err != ERR_OK) { ++ if ((conn->pending_err != ERR_OK) && (conn->pending_err != ERR_RST)) { + LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("event_callback: have errevent, err=%d, fd=%d\n", conn->pending_err, conn->socket)); + } + sock->errevent = 1; +diff --git a/src/api/sys_arch.c b/src/api/sys_arch.c +index 1bc3aee..332d460 100644 +--- a/src/api/sys_arch.c ++++ b/src/api/sys_arch.c +@@ -37,6 +37,7 @@ + #include + + #include ++#include + + #include "lwip/err.h" + #include "lwip/mem.h" +@@ -89,9 +90,50 @@ static int mbox_wait_func(void) + return eth_dev_poll(); + } + ++struct rte_ring *gazelle_ring_create_fast(const char *name, uint32_t size, uint32_t flags) ++{ ++ ssize_t ring_size; ++ char ring_name[RTE_MEMZONE_NAMESIZE] = {0}; ++ struct rte_ring *ring; ++ ++ ring_size = rte_ring_get_memsize_elem(sizeof(void *), size); ++ if (ring_size < 0) { ++ RTE_LOG(ERR, EAL, "rte_ring_get_memszie_elem failed\n"); ++ return NULL; ++ } ++ ++ /* ++ * rte_ring_create is not used because it calls memzone_lookup_thread_unsafe function ++ * time consuming when there are many rings ++ */ ++ ring = rte_malloc_socket(NULL, ring_size, RTE_CACHE_LINE_SIZE, rte_socket_id()); ++ if (ring == NULL) { ++ RTE_LOG(ERR, EAL, "cannot create rte_ring for mbox\n"); ++ return NULL; ++ } ++ ++ if (snprintf(ring_name, sizeof(ring_name), "%s""%"PRIXPTR, name, (uintptr_t)ring) < 0) { ++ rte_free(ring); ++ RTE_LOG(ERR, EAL, "snprintf failed\n"); ++ return NULL; ++ } ++ ++ if (rte_ring_init(ring, ring_name, size, flags) != 0) { ++ rte_free(ring); ++ RTE_LOG(ERR, EAL, "cannot init rte_ring for mbox\n"); ++ return NULL; ++ } ++ ++ return ring; ++} ++ ++void gazelle_ring_free_fast(struct rte_ring *ring) ++{ ++ rte_free(ring); ++} ++ + err_t sys_mbox_new(struct sys_mbox **mb, int size) + { +- int ret; + struct sys_mbox *mbox; + + mbox = (struct sys_mbox *)memp_malloc(MEMP_SYS_MBOX); +@@ -100,21 +142,14 @@ err_t sys_mbox_new(struct sys_mbox **mb, int size) + } + + mbox->flags = RING_F_SP_ENQ | RING_F_SC_DEQ; +- +- ret = snprintf(mbox->name, sizeof(mbox->name), MBOX_NAME_PREFIX"%"PRIXPTR, (uintptr_t)mbox); +- if (ret < 0) { +- memp_free(MEMP_SYS_MBOX, mbox); +- return ERR_VAL; +- } +- + mbox->size = size; + mbox->socket_id = rte_socket_id(); +- mbox->ring = rte_ring_create(mbox->name, mbox->size, mbox->socket_id, mbox->flags); +- if (!mbox->ring) { +- RTE_LOG(ERR, EAL, "cannot create rte_ring for mbox\n"); +- memp_free(MEMP_SYS_MBOX, mbox); +- return ERR_MEM; ++ ++ mbox->ring = gazelle_ring_create_fast(MBOX_NAME_PREFIX, mbox->size, mbox->flags); ++ if (mbox->ring == NULL) { ++ sys_mbox_free(&mbox); + } ++ + mbox->wait_fn = mbox_wait_func; + *mb = mbox; + +@@ -125,7 +160,7 @@ void sys_mbox_free(struct sys_mbox **mb) + { + struct sys_mbox *mbox = *mb; + if (mbox->ring != NULL) { +- rte_ring_free(mbox->ring); ++ gazelle_ring_free_fast(mbox->ring); + mbox->ring = NULL; + } + memp_free(MEMP_SYS_MBOX, mbox); +diff --git a/src/include/arch/sys_arch.h b/src/include/arch/sys_arch.h +index 5e95f3d..bf7e437 100644 +--- a/src/include/arch/sys_arch.h ++++ b/src/include/arch/sys_arch.h +@@ -123,6 +123,10 @@ static __rte_always_inline uint32_t gazelle_st_ring_dequeue_burst(struct rte_rin + + return n; + } ++ ++void gazelle_ring_free_fast(struct rte_ring *ring); ++struct rte_ring *gazelle_ring_create_fast(const char *name, uint32_t size, uint32_t flags); ++ + #endif + + void sys_calibrate_tsc(void); +-- +2.33.0 + diff --git a/README.OpenSource b/README.OpenSource index 27d64a64675eb55b5e54aba90fffce185c129d1f..2a6bc2b4557f5b6a57eb545dda14108f60c0f3bf 100644 --- a/README.OpenSource +++ b/README.OpenSource @@ -3,7 +3,7 @@ "Name" : "openEuler:lwip", "License" : "BSD 3-Clause License", "License File" : "COPYING", - "Version Number" : "2.1.3-39.oe2203sp1", + "Version Number" : "2.1.3-102.oe2203sp3", "Owner" : "wangmihu@huawei.com", "Upstream URL" : "https://repo.openeuler.org/openEuler-22.03-LTS/update/source/Packages/lwip-2.1.3-39.oe2203sp1.src.rpm", "Description" : "lwIP is a small independent implementation of the TCP/IP protocol suite that has been initially developed by Adam Dunkels. The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM." diff --git a/install.sh b/install.sh deleted file mode 100644 index 70442cf52efac6cfe307ad1c49af7a2f4020a70d..0000000000000000000000000000000000000000 --- a/install.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -cd $1 -if [ ! -d "lwip" ];then - tar -jxvf lwip-2.1.3.tar.xz -fi diff --git a/lwip.spec b/lwip.spec index a6322931b320db0de43098ff022c9b7727bb1dcc..65ffa681f39df143f2a0e8add414d0ef3e4d175a 100644 --- a/lwip.spec +++ b/lwip.spec @@ -4,7 +4,7 @@ Summary: lwip is a small independent implementation of the TCP/IP protocol suite Name: lwip Version: 2.1.3 -Release: 90 +Release: 102 License: BSD URL: http://savannah.nongnu.org/projects/lwip/ Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip @@ -101,6 +101,18 @@ Patch9083: 0084-add-tcpslowtmr-log-and-tcpfasttmr-cnt.patch Patch9084: 0085-add-lwip-log-tcp_rst-tcp_abandon-tcp_abort.patch Patch9085: 0086-log-add-errevent-log-and-tcp-exception-statistics.patch Patch9086: 0087-support-vlan-offload.patch +Patch9087: 0088-modify-log-info-err.patch +Patch9088: 0089-add-struct-gz-addr.patch +Patch9089: 0090-frag-fix-coredump-when-get-netif.patch +Patch9090: 0091-add-fd-log-info-and-fix-wrong-port-log-info.patch +Patch9091: 0092-fix-the-coredump-issue-when-UDP-traffic-is-sent.patch +Patch9092: 0093-modfiy-accept-null-pointer-when-new-conn-receive-RST-packet-in-listening.patch +Patch9093: 0094-lwip-log-fix-reversed-port-in-tcp_input.patch +Patch9094: 0095-event_callback-del-errevent-log-if-err-is-ERR_OK.patch +Patch9095: 0096-tcp_send_fin-add-the-fin-to-the-last-unsent-segment.patch +Patch9096: 0097-Mod-the-issue-that-2w-connection-unable-to-establish.patch +Patch9097: 0098-remove-duplicate-lwip-log.patch +Patch9098: 0099-fix-rte_ring_create-time-consuming.patch BuildRequires: gcc-c++ dos2unix dpdk-devel @@ -131,6 +143,42 @@ cd %{_builddir}/%{name}-%{version}/src %{_libdir}/liblwip.a %changelog +* Tue Dec 26 2023 jiangheng - 2.1.3-102 +- fix rte_ring_create/free time-consuming + +* Tue Dec 26 2023 jiangheng - 2.1.3-101 +- remove duplicate lwip log + +* Mon Dec 25 2023 hankangkang - 2.1.3-100 +- Mod the issue that 2w connection unable to establish + +* Sat Dec 23 2023 yangchen - 2.1.3-99 +- tcp_send_fin: add the fin to the last unsent segment + +* Wed Dec 20 2023 yangchen - 2.1.3-98 +- event_callback: del errevent log if err is ERR_OK + +* Fri Dec 15 2023 yangchen - 2.1.3-97 +- lwip log: fix reversed port in tcp_input + +* Thu Dec 14 2023 hankangkang - 2.1.3-96 +- modfiy-accept-null-pointer-when-new-conn-receive-RST-packet-in-listening + +* Sat Dec 9 2023 wuchangye - 2.1.3-95 +- fix the coredump issue when UDP traffic is sent + +* Fri Dec 8 2023 yangchen - 2.1.3-94 +- add fd log info and fix wrong port log info + +* Fri Dec 8 2023 jiangheng - 2.1.3-93 +- ip4 frag: fix coredump when get netif + +* Wed Dec 6 2023 zhengjiebing - 2.1.3-92 +- add struct gz_addr_t + +* Tue Dec 5 2023 hankangkang - 2.1.3-91 +- modify-log-info-err + * Tue Nov 28 2023 zhengjiebing - 2.1.3-90 - support vlan offload