!418 [sync] PR-417: gro:fix gro with tcp push flag

From: @openeuler-sync-bot 
Reviewed-by: @jiangheng12 
Signed-off-by: @jiangheng12
This commit is contained in:
openeuler-ci-bot 2023-06-20 01:05:45 +00:00 committed by Gitee
commit 37630d2567
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 90 additions and 1 deletions

View File

@ -0,0 +1,85 @@
From 027e250f2246b6a3c9b8fd370b27348e7b3f2be1 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 19 Jun 2023 01:29:51 +0800
Subject: [PATCH] gro:fix gro with tcp push flag
TCP data packets sometimes carry a PUSH flag. Currently,
only the packets that do not have PUSH flag can be GROed.
The packets that have a PUSH flag cannot be GROed, the packets
that cannot be processed by GRO are placed last.
In this case, the received packets may be out of order.
For example, there are two packets mbuf1 and mbuf2. mbuf1
contains PUSH flag, mbuf2 does not contain PUSH flag.
After GRO processing, mbuf2 is sent for processing before mbuf1.
This out-of-order will affect TCP processing performance and
lead to unnecessary dup-ACK.
Referring to the Linux kernel implementation, packets with PUSH
flag can also perform GRO. And if one of the packets containing
PUSH flag, the packets after GRO will carry PUSH flag.
Reference: https://mails.dpdk.org/archives/stable/2022-July/039759.html
---
lib/librte_gro/gro_tcp4.c | 4 ++--
lib/librte_gro/gro_tcp4.h | 16 +++++++++++++---
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/lib/librte_gro/gro_tcp4.c b/lib/librte_gro/gro_tcp4.c
index 15b7ae7..31d165f 100644
--- a/lib/librte_gro/gro_tcp4.c
+++ b/lib/librte_gro/gro_tcp4.c
@@ -221,10 +221,10 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,
hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len;
/*
- * Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE
+ * Don't process the packet which has FIN, SYN, RST, URG, ECE
* or CWR set.
*/
- if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG)
+ if (tcp_hdr->tcp_flags & (~(RTE_TCP_ACK_FLAG | RTE_TCP_PSH_FLAG)))
return -1;
/* trim the tail padding bytes */
diff --git a/lib/librte_gro/gro_tcp4.h b/lib/librte_gro/gro_tcp4.h
index bb875a5..5032ef3 100644
--- a/lib/librte_gro/gro_tcp4.h
+++ b/lib/librte_gro/gro_tcp4.h
@@ -212,7 +212,8 @@ merge_two_tcp4_packets(struct gro_tcp4_item *item,
uint16_t l2_offset)
{
struct rte_mbuf *pkt_head, *pkt_tail, *lastseg;
- uint16_t hdr_len, l2_len;
+ struct rte_tcp_hdr *head_tcp_hdr, *tail_tcp_hdr;
+ uint16_t hdr_len, l2_len, l3_offset;
if (cmp > 0) {
pkt_head = item->firstseg;
@@ -223,13 +224,22 @@ merge_two_tcp4_packets(struct gro_tcp4_item *item,
}
/* check if the IPv4 packet length is greater than the max value */
- hdr_len = l2_offset + pkt_head->l2_len + pkt_head->l3_len +
- pkt_head->l4_len;
+ l3_offset = l2_offset + pkt_head->l2_len + pkt_head->l3_len;
+ hdr_len = l3_offset + pkt_head->l4_len;
l2_len = l2_offset > 0 ? pkt_head->outer_l2_len : pkt_head->l2_len;
if (unlikely(pkt_head->pkt_len - l2_len + pkt_tail->pkt_len -
hdr_len > MAX_IPV4_PKT_LENGTH))
return 0;
+ /* merge push flag to pkt_head */
+ tail_tcp_hdr = rte_pktmbuf_mtod_offset(pkt_tail,
+ struct rte_tcp_hdr *, l3_offset);
+ if (tail_tcp_hdr->tcp_flags & RTE_TCP_PSH_FLAG) {
+ head_tcp_hdr = rte_pktmbuf_mtod_offset(pkt_head,
+ struct rte_tcp_hdr *, l3_offset);
+ head_tcp_hdr->tcp_flags |= RTE_TCP_PSH_FLAG;
+ }
+
/* remove the packet header for the tail packet */
rte_pktmbuf_adj(pkt_tail, hdr_len);
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: dpdk
Version: 19.11
Release: 29
Release: 30
Packager: packaging@6wind.com
URL: http://dpdk.org
%global source_version 19.11
@ -65,6 +65,7 @@ Patch9000: hinic-free-mbuf-use-rte_pktmbuf_free_seg.patch
Patch6014: backport-fix-dedicated-queue-mode-in-vector-burst.patch
Patch9001: 0001-pdump-fix-pcap_dump-coredump-caused-by-incorrect-pkt_len.patch
Patch9002: 0002-gro-fix-gro-with-tcp-push-flag.patch
Summary: Data Plane Development Kit core
Group: System Environment/Libraries
@ -234,6 +235,9 @@ strip -g $RPM_BUILD_ROOT/lib/modules/${namer}/extra/dpdk/rte_kni.ko
/usr/sbin/depmod
%changelog
* Mon Jun 19 2023 jiangheng <jiangheng14@huawei.com> - 19.11-30
- gro: fix gro with tcp push flag
* Sat Jun 17 2023 jiangheng <jiangheng14@huawei.com> - 19.11-29
- pdump: fix pcap_dump coredump caused by incorrect pkt_len