1 Star 0 Fork 48

flying-eagle/lwip

forked from src-openEuler/lwip 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0134-mod-checksum-of-ip_hdr-and-udp_hdr.patch 2.07 KB
一键复制 编辑 原始数据 按行查看 历史
hantwofish 提交于 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/flying-eagle12138/lwip.git
git@gitee.com:flying-eagle12138/lwip.git
flying-eagle12138
lwip
lwip
master

搜索帮助