diff --git a/0132-mod-udp-loop-mem-leak.patch b/0132-mod-udp-loop-mem-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..7f930dcd9ce12c4e13d4d21ae7a562f6a5280d74 --- /dev/null +++ b/0132-mod-udp-loop-mem-leak.patch @@ -0,0 +1,79 @@ +From 817a3b938db89efa8ef63d610b43cb10321da446 Mon Sep 17 00:00:00 2001 +From: hantwofish +Date: Tue, 7 May 2024 17:49:32 +0800 +Subject: [PATCH] mod udp loop mem leak + +--- + src/core/netif.c | 21 +++++++++++++++------ + src/core/pbuf.c | 20 +++++++++++++++++--- + 2 files changed, 32 insertions(+), 9 deletions(-) + +diff --git a/src/core/netif.c b/src/core/netif.c +index 2fc8945..e6cdebe 100644 +--- a/src/core/netif.c ++++ b/src/core/netif.c +@@ -1182,13 +1182,22 @@ udp_netif_loop_output(struct netif *netif, struct pbuf *p) + LWIP_ASSERT("netif_loop_output: invalid pbuf", p != NULL); + + /* Allocate a new pbuf */ +- r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); +- if (r == NULL) { +- LINK_STATS_INC(link.memerr); +- LINK_STATS_INC(link.drop); +- MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards); +- return ERR_MEM; ++ u16_t p_clen = pbuf_clen(p); ++ struct pbuf *temp[p_clen]; ++ for (int i = 0; i < p_clen; i++) { ++ temp[i] = pbuf_alloc(PBUF_LINK, p->len, PBUF_RAM); ++ if (temp[i] == NULL) { ++ LINK_STATS_INC(link.memerr); ++ LINK_STATS_INC(link.drop); ++ MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards); ++ pbuf_free(temp[0]); ++ return ERR_MEM; ++ } ++ if (i > 0) { ++ pbuf_cat(temp[0], temp[i]); ++ } + } ++ r = temp[0]; + #if LWIP_LOOPBACK_MAX_PBUFS + clen = pbuf_clen(r); + /* check for overflow or too many pbuf on queue */ +diff --git a/src/core/pbuf.c b/src/core/pbuf.c +index b0a63b4..914d1f4 100644 +--- a/src/core/pbuf.c ++++ b/src/core/pbuf.c +@@ -1373,11 +1373,25 @@ pbuf_clone(pbuf_layer layer, pbuf_type type, struct pbuf *p) + { + struct pbuf *q; + err_t err; +- q = pbuf_alloc(layer, p->tot_len, type); +- if (q == NULL) { +- return NULL; ++ u16_t p_clen = pbuf_clen(p); ++ struct pbuf *temp[p_clen]; ++ for (int i = 0; i < p_clen; i++) { ++ temp[i] = pbuf_alloc(PBUF_LINK, p->len, PBUF_RAM); ++ if (temp[i] == NULL) { ++ pbuf_free(temp[0]); ++ return NULL; ++ } ++ if (i > 0) { ++ pbuf_cat(temp[0], temp[i]); ++ } + } ++ q = temp[0]; ++ + err = pbuf_copy(q, p); ++ if (err != ERR_OK) { ++ pbuf_free(q); ++ return NULL; ++ } + LWIP_UNUSED_ARG(err); /* in case of LWIP_NOASSERT */ + LWIP_ASSERT("pbuf_copy failed", err == ERR_OK); + return q; +-- +2.33.0 + diff --git a/0133-allow-membership-to-register-multiple-times.patch b/0133-allow-membership-to-register-multiple-times.patch new file mode 100644 index 0000000000000000000000000000000000000000..2249b9aa9d67404d19a6d3bb5541bcaf7ae96399 --- /dev/null +++ b/0133-allow-membership-to-register-multiple-times.patch @@ -0,0 +1,34 @@ +From 3b23b3a69d71a862dfe7fca1b53b673dc868ffa5 Mon Sep 17 00:00:00 2001 +From: wanfeng +Date: Fri, 10 May 2024 15:11:12 +0800 +Subject: [PATCH] allow membership to register multiple times + +--- + src/api/sockets.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/api/sockets.c b/src/api/sockets.c +index 04df15a..5a72b62 100644 +--- a/src/api/sockets.c ++++ b/src/api/sockets.c +@@ -4501,7 +4501,7 @@ lwip_socket_register_membership(int s, unsigned int if_idx, const ip4_addr_t *mu + #else + for (i = 0; i < LWIP_SOCKET_MAX_MEMBERSHIPS; i++) { + #endif +- if (socket_ipv4_multicast_memberships[i].sock == NULL) { ++ if (socket_ipv4_multicast_memberships[i].sock == NULL || (socket_ipv4_multicast_memberships[i].sock == sock)) { + socket_ipv4_multicast_memberships[i].sock = sock; + socket_ipv4_multicast_memberships[i].if_idx = if_idx; + ip4_addr_copy(socket_ipv4_multicast_memberships[i].multi_addr, *multi_addr); +@@ -4617,7 +4617,7 @@ lwip_socket_register_mld6_membership(int s, unsigned int if_idx, const ip6_addr_ + #else + for (i = 0; i < LWIP_SOCKET_MAX_MEMBERSHIPS; i++) { + #endif +- if (socket_ipv6_multicast_memberships[i].sock == NULL) { ++ if (socket_ipv6_multicast_memberships[i].sock == NULL || (socket_ipv6_multicast_memberships[i].sock == sock)) { + socket_ipv6_multicast_memberships[i].sock = sock; + socket_ipv6_multicast_memberships[i].if_idx = (u8_t)if_idx; + ip6_addr_copy(socket_ipv6_multicast_memberships[i].multi_addr, *multi_addr); +-- +2.25.1 + diff --git a/0134-mod-checksum-of-ip_hdr-and-udp_hdr.patch b/0134-mod-checksum-of-ip_hdr-and-udp_hdr.patch new file mode 100644 index 0000000000000000000000000000000000000000..41456d7f2c179f1acd64be9b4166dd29a030d075 --- /dev/null +++ b/0134-mod-checksum-of-ip_hdr-and-udp_hdr.patch @@ -0,0 +1,53 @@ +From c465aa8bce75770ed296862657118d0ceaf4087b Mon Sep 17 00:00:00 2001 +From: hantwofish +Date: Thu, 9 May 2024 20:06:50 +0800 +Subject: [PATCH] mod checksum of ip_hdr and udp_hdr + +--- + src/core/ipv4/ip4.c | 2 +- + src/core/ipv4/ip4_frag.c | 1 + + src/core/udp.c | 3 ++- + 3 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c +index 8865766..0bbeefc 100644 +--- a/src/core/ipv4/ip4.c ++++ b/src/core/ipv4/ip4.c +@@ -1084,7 +1084,7 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d + #if IP_FRAG + /* don't fragment if interface has mtu set to 0 [loopif] */ + #if GAZELLE_ENABLE +- if (!(netif_get_txol_flags(netif) & RTE_ETH_TX_OFFLOAD_TCP_TSO)) { ++ if ((!(netif_get_txol_flags(netif) & RTE_ETH_TX_OFFLOAD_TCP_TSO)) || !(IPH_PROTO(iphdr) == IP_PROTO_TCP)) { + #endif + if (netif->mtu && (p->tot_len > netif->mtu)) { + return ip4_frag(p, netif, dest); +diff --git a/src/core/ipv4/ip4_frag.c b/src/core/ipv4/ip4_frag.c +index aa50856..2ba473b 100644 +--- a/src/core/ipv4/ip4_frag.c ++++ b/src/core/ipv4/ip4_frag.c +@@ -892,6 +892,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest) + #if CHECKSUM_GEN_IP_HW + if (netif_get_txol_flags(netif) & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) { + iph_cksum_set(p, IP_HLEN, 1); ++ iph_cksum_set(rambuf, IP_HLEN, 1); + } else { + iph_cksum_set(p, IP_HLEN, 0); + IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); +diff --git a/src/core/udp.c b/src/core/udp.c +index 2c946c7..1fae8b6 100644 +--- a/src/core/udp.c ++++ b/src/core/udp.c +@@ -1011,7 +1011,8 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d + #endif /* LWIP_CHECKSUM_ON_COPY */ + { + #if CHECKSUM_GEN_UDP_HW +- if (netif_get_txol_flags(netif) & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) { ++ if ( (netif_get_txol_flags(netif) & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) && ++ (netif->mtu) && (p->tot_len <= netif->mtu)) { + udph_cksum_set(q, UDP_HLEN); + udpchksum = 0; + } else { +-- +2.33.0 + diff --git a/0135-change-STAT_COUNTER-from-u16-to-u64.patch b/0135-change-STAT_COUNTER-from-u16-to-u64.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b4143ecbeaf65c3101fe71d91c3a4c15ccfb2c7 --- /dev/null +++ b/0135-change-STAT_COUNTER-from-u16-to-u64.patch @@ -0,0 +1,28 @@ +From 2d03a11cfbbe8885339fda776f45ad3d26829d9f Mon Sep 17 00:00:00 2001 +From: ningjin +Date: Mon, 20 May 2024 17:33:12 +0800 +Subject: [PATCH] change STAT_COUNTER from u16 to u64 + +--- + src/include/lwip/stats.h | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/include/lwip/stats.h b/src/include/lwip/stats.h +index f99f6e5..6798f48 100644 +--- a/src/include/lwip/stats.h ++++ b/src/include/lwip/stats.h +@@ -52,7 +52,10 @@ extern "C" { + #define LWIP_STATS_LARGE 0 + #endif + +-#if LWIP_STATS_LARGE ++#if GAZELLE_ENABLE ++#define STAT_COUNTER u64_t ++#define STAT_COUNTER_F U64_F ++#elif LWIP_STATS_LARGE + #define STAT_COUNTER u32_t + #define STAT_COUNTER_F U32_F + #else +-- +2.27.0 + diff --git a/0136-fix-vlan-filter-bug.patch b/0136-fix-vlan-filter-bug.patch new file mode 100644 index 0000000000000000000000000000000000000000..69049309c1b09c5e2ceab335d764c86c62e49be1 --- /dev/null +++ b/0136-fix-vlan-filter-bug.patch @@ -0,0 +1,25 @@ +diff --git a/src/netif/ethernet.c b/src/netif/ethernet.c +index d0d68b3..5ba6d95 100644 +--- a/src/netif/ethernet.c ++++ b/src/netif/ethernet.c +@@ -123,7 +123,9 @@ ethernet_input(struct pbuf *p, struct netif *netif) + goto free_and_return; + } + #if GAZELLE_ENABLE +- if (netif->vlan_enable && !(netif->txol_flags & RTE_ETH_RX_OFFLOAD_VLAN_FILTER) && VLAN_ID(vlan) != netif->vlan_tci) { ++ /* 1.if vlan mode is not enable, ignore VLAN packets. ++ 2.if vlan mode is enable, ignore packets not for our VLAN */ ++ if (netif->vlan_enable == false || (netif->vlan_enable && VLAN_ID(vlan) != netif->vlan_tci)) { + goto free_and_return; + } + #endif +@@ -141,6 +143,9 @@ ethernet_input(struct pbuf *p, struct netif *netif) + } + #endif /* defined(LWIP_HOOK_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) */ + type = vlan->tpid; ++ } else if (netif->vlan_enable && !(netif->txol_flags & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)) { ++ /* if vlan mode is enable but vlan strip offload is off, ignore packets without vlan info. */ ++ goto free_and_return; + } + #endif /* ETHARP_SUPPORT_VLAN */ + diff --git a/lwip.spec b/lwip.spec index 3748f1e21b2467585334e6ee0c46127416086673..8937de8561b248b9055e33fd6c518e512723824b 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.2.0 -Release: 24 +Release: 29 License: BSD URL: http://savannah.nongnu.org/projects/lwip/ Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip @@ -143,6 +143,11 @@ Patch9127: 0128-add-MCAST_JOIN_SOURCE_GROUP-to-setsockopt-for-igmpv3.patch Patch9128: 0129-memset-gazelle_quintuple-in-vdev_reg_done.patch Patch9129: 0130-add-MCAST_JOIN_GROUP-to-setsockopt-for-igmpv3.patch Patch9130: 0131-add-MCAST_BLOCK_SOURCE-to-setsockopt-for-igmpv3.patch +Patch9131: 0132-mod-udp-loop-mem-leak.patch +Patch9132: 0133-allow-membership-to-register-multiple-times.patch +Patch9133: 0134-mod-checksum-of-ip_hdr-and-udp_hdr.patch +Patch9134: 0135-change-STAT_COUNTER-from-u16-to-u64.patch +Patch9135: 0136-fix-vlan-filter-bug.patch BuildRequires: gcc-c++ dos2unix dpdk-devel @@ -172,6 +177,21 @@ cd %{_builddir}/%{name}-%{version}/src %{_libdir}/liblwip.a %changelog +* Fri May 24 2024 zhengjiebing - 2.2.0-29 +- fix vlan filter bug + +* Tue May 21 2024 ningjin - 2.2.0-28 +- change change STAT_COUNTER from u16 to u64 + +* Thu May 09 2024 hankangkang - 2.2.0-27 +- mod checksum of ip_hdr and udp_hdr + +* Fri May 10 2024 wanfeng - 2.2.0-26 +- allow multicast membership to register multiple times + +* Tue May 07 2024 hankangkang - 2.2.0-25 +- Fix MBUF memory leakage issue when message length is greater than MTU + * Tue May 07 2024 zhangyulong - 2.2.0-24 - add option MCAST_BLOCK_SOURCE to the setsockopt for the igmpv3 protocol