1 Star 0 Fork 48

hantwofish/lwip

forked from src-openEuler/lwip 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
0134-mod-checksum-of-ip_hdr-and-udp_hdr.patch 2.07 KB
Copy Edit Raw Blame History
hantwofish authored 2024-05-09 20:11 . mod checksum of ip_hdr and udp_hdr
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hantwofish/lwip.git
git@gitee.com:hantwofish/lwip.git
hantwofish
lwip
lwip
master

Search