From 3a9650f09867b1ada795c358ba4be79ce5eb48d3 Mon Sep 17 00:00:00 2001 From: wuchangsheng Date: Thu, 6 Oct 2022 21:09:12 +0800 Subject: [PATCH] fix free pbuf miss data (cherry picked from commit 39ebcfa06d31ef5a7dc6aad48cf2282199f33350) --- 0032-fix-free-pbuf-miss-data.patch | 80 ++++++++++++++++++++++++++++++ lwip.spec | 7 ++- 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 0032-fix-free-pbuf-miss-data.patch diff --git a/0032-fix-free-pbuf-miss-data.patch b/0032-fix-free-pbuf-miss-data.patch new file mode 100644 index 0000000..0816127 --- /dev/null +++ b/0032-fix-free-pbuf-miss-data.patch @@ -0,0 +1,80 @@ +From 0c7d7ad7f9a79a557a867a6009aa2aac067d454e Mon Sep 17 00:00:00 2001 +From: wuchangsheng +Date: Thu, 6 Oct 2022 21:07:12 +0800 +Subject: [PATCH] fix free pbuf miss data + +--- + src/core/tcp_out.c | 18 ++++++++++++++++++ + src/include/lwipopts.h | 2 +- + 2 files changed, 19 insertions(+), 1 deletion(-) + +diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c +index dd780d3..2834ba3 100644 +--- a/src/core/tcp_out.c ++++ b/src/core/tcp_out.c +@@ -682,11 +682,24 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) + if (queuelen > LWIP_MIN(TCP_SND_QUEUELEN, TCP_SNDQUEUELEN_OVERFLOW)) { + LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("tcp_write: queue too long %"U16_F" (%d)\n", + queuelen, (int)TCP_SND_QUEUELEN)); ++#if USE_LIBOS ++ if (pos > 0) { ++ queuelen -= pbuf_clen(p); ++ break; ++ } ++#else + pbuf_free(p); ++#endif + goto memerr; + } + + if ((seg = tcp_create_segment(pcb, p, 0, pcb->snd_lbb + pos, optflags)) == NULL) { ++#if USE_LIBOS ++ if (pos > 0) { ++ queuelen -= pbuf_clen(p); ++ break; ++ } ++#endif + goto memerr; + } + #if TCP_OVERSIZE_DBGCHECK +@@ -714,6 +727,9 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) + lwip_ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg))); + + pos += seglen; ++#if USE_LIBOS ++ write_lwip_over((struct lwip_sock*)arg, 1); ++#endif + } + + /* +@@ -825,12 +841,14 @@ memerr: + tcp_set_flags(pcb, TF_NAGLEMEMERR); + TCP_STATS_INC(tcp.memerr); + ++#if !USE_LIBOS + if (concat_p != NULL) { + pbuf_free(concat_p); + } + if (queue != NULL) { + tcp_segs_free(queue); + } ++#endif + if (pcb->snd_queuelen != 0) { + LWIP_ASSERT("tcp_write: valid queue length", pcb->unacked != NULL || + pcb->unsent != NULL); +diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h +index 75d3c74..7459991 100644 +--- a/src/include/lwipopts.h ++++ b/src/include/lwipopts.h +@@ -133,7 +133,7 @@ + + #define USE_LIBOS 1 + +-#define LWIP_DEBUG 1 ++//#define LWIP_DEBUG 1 + + #define LWIP_PERF 1 + +-- +2.27.0 + diff --git a/lwip.spec b/lwip.spec index 66589e7..145c1ed 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: 19 +Release: 20 License: BSD URL: http://savannah.nongnu.org/projects/lwip/ Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.tar.gz @@ -43,6 +43,7 @@ Patch9027: 0028-per-thread-reassdata-variables.patch Patch9028: 0029-fix-EISCONN-err-and-remove-same-customized-modificat.patch Patch9029: 0030-refactor-tcp-new-port.patch Patch9030: 0031-refactor-add-event-limit-send-pkts-num.patch +Patch9031: 0032-fix-free-pbuf-miss-data.patch BuildRequires: gcc-c++ dos2unix dpdk-devel @@ -71,6 +72,10 @@ cd %{_builddir}/%{name}-%{version}/src %{_libdir}/liblwip.a %changelog +* Thu Oct 6 2022 wuchangsheng - 2.1.3-20 +- fix miss data due to free pbuf + close debug + * Thu Oct 6 2022 wuchangsheng - 2.1.3-19 - refactor add event limit send pkts num max 10 -- Gitee