mod checksum of ip_hdr and udp_hdr

(cherry picked from commit 9cb9aea40b320896c4703b36b9f173404402923f)
This commit is contained in:
hantwofish 2024-05-09 20:11:12 +08:00 committed by openeuler-sync-bot
parent 6205096940
commit a019b46e7f
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,53 @@
From c465aa8bce75770ed296862657118d0ceaf4087b Mon Sep 17 00:00:00 2001
From: hantwofish <hankangkang5@huawei.com>
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

View File

@ -4,7 +4,7 @@
Summary: lwip is a small independent implementation of the TCP/IP protocol suite
Name: lwip
Version: 2.2.0
Release: 26
Release: 27
License: BSD
URL: http://savannah.nongnu.org/projects/lwip/
Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip
@ -145,6 +145,7 @@ 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
BuildRequires: gcc-c++ dos2unix dpdk-devel
@ -174,6 +175,9 @@ cd %{_builddir}/%{name}-%{version}/src
%{_libdir}/liblwip.a
%changelog
* Thu May 09 2024 hankangkang <hankangkang5@huawei.com> - 2.2.0-27
- mod checksum of ip_hdr and udp_hdr
* Fri May 10 2024 wanfeng <wanfeng@kylinos.cn> - 2.2.0-26
- allow multicast membership to register multiple times