From 41c333678ba87b421d5bd54f0e92e27fd74bf799 Mon Sep 17 00:00:00 2001 From: yinbin Date: Wed, 27 Dec 2023 14:51:08 +0800 Subject: [PATCH] sync patches from master --- ...p-log-fix-reversed-port-in-tcp_input.patch | 61 ++++ ...ck-del-errevent-log-if-err-is-ERR_OK.patch | 27 ++ ...d-the-fin-to-the-last-unsent-segment.patch | 27 ++ ...at-2w-connection-unable-to-establish.patch | 275 ++++++++++++++++++ 0098-remove-duplicate-lwip-log.patch | 25 ++ 0099-fix-rte_ring_create-time-consuming.patch | 142 +++++++++ lwip.spec | 26 +- 7 files changed, 582 insertions(+), 1 deletion(-) create mode 100644 0094-lwip-log-fix-reversed-port-in-tcp_input.patch create mode 100644 0095-event_callback-del-errevent-log-if-err-is-ERR_OK.patch create mode 100644 0096-tcp_send_fin-add-the-fin-to-the-last-unsent-segment.patch create mode 100644 0097-Mod-the-issue-that-2w-connection-unable-to-establish.patch create mode 100644 0098-remove-duplicate-lwip-log.patch create mode 100644 0099-fix-rte_ring_create-time-consuming.patch 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 0000000..1168db7 --- /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 0000000..9260abc --- /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 0000000..2e77f0e --- /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 0000000..764a155 --- /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 0000000..16a847d --- /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 0000000..c544b2a --- /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/lwip.spec b/lwip.spec index 13276ce..65ffa68 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: 96 +Release: 102 License: BSD URL: http://savannah.nongnu.org/projects/lwip/ Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip @@ -107,6 +107,12 @@ 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 @@ -137,6 +143,24 @@ 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