!250 [sync] PR-243: backport some patches for gro bugfix

From: @openeuler-sync-bot 
Reviewed-by: @wu-changsheng 
Signed-off-by: @wu-changsheng
This commit is contained in:
openeuler-ci-bot 2022-10-31 11:28:24 +00:00 committed by Gitee
commit f6631ff66a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 142 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From 72f51b097a71fb9bdea13bdd254ff620b34c852e Mon Sep 17 00:00:00 2001
From: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
Date: Sun, 16 Oct 2022 20:13:05 +0530
Subject: [PATCH] gro: check payload length after trim
When packet is padded with extra bytes the
the validation of the payload length should be done
after the trim operation
Fixes: b8a55871d5af ("gro: trim tail padding bytes")
Cc: stable@dpdk.org
Signed-off-by: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
Acked-by: Jiayu Hu <jiayu.hu@intel.com>
---
lib/gro/gro_tcp4.c | 11 ++++++-----
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/lib/librte_gro/gro_tcp4.c b/lib/librte_gro/gro_tcp4.c
index 8f5e800250..0014096e63 100644
--- a/lib/librte_gro/gro_tcp4.c
+++ b/lib/librte_gro/gro_tcp4.c
@@ -225,6 +225,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,
*/
if (tcp_hdr->tcp_flags != RTE_TCP_ACK_FLAG)
return -1;
+
+ /* trim the tail padding bytes */
+ ip_tlen = rte_be_to_cpu_16(ipv4_hdr->total_length);
+ if (pkt->pkt_len > (uint32_t)(ip_tlen + pkt->l2_len))
+ rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_tlen - pkt->l2_len);
+
/*
* Don't process the packet whose payload length is less than or
* equal to 0.
@@ -233,11 +239,6 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,
if (tcp_dl <= 0)
return -1;
- /* trim the tail padding bytes */
- ip_tlen = rte_be_to_cpu_16(ipv4_hdr->total_length);
- if (pkt->pkt_len > (uint32_t)(ip_tlen + pkt->l2_len))
- rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_tlen - pkt->l2_len);
-
/*
* Save IPv4 ID for the packet whose DF bit is 0. For the packet
* whose DF bit is 1, IPv4 ID is ignored.
--
2.23.0

View File

@ -0,0 +1,31 @@
From bc4a7f7ee0281d96b8d93ac2771135a670b4a00f Mon Sep 17 00:00:00 2001
From: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
Date: Wed, 7 Sep 2022 15:02:05 +0530
Subject: [PATCH] gro: fix chain index for more than 2 packets
When more than two packets are merged in a flow, and if we receive
a 3rd packet which is matching the sequence of the 2nd packet the
prev_idx will be 1 and not 2, hence resulting in packet re-ordering
Signed-off-by: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
Acked-by: Jiayu Hu <jiayu.hu@intel.com>
---
lib/gro/gro_tcp4.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_gro/gro_tcp4.c b/lib/librte_gro/gro_tcp4.c
index 7498c66141..9758e28fd5 100644
--- a/lib/librte_gro/gro_tcp4.c
+++ b/lib/librte_gro/gro_tcp4.c
@@ -305,7 +305,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,
* length is greater than the max value. Store
* the packet into the flow.
*/
- if (insert_new_item(tbl, pkt, start_time, prev_idx,
+ if (insert_new_item(tbl, pkt, start_time, cur_idx,
sent_seq, ip_id, is_atomic) ==
INVALID_ARRAY_INDEX)
return -1;
--
2.23.0

View File

@ -0,0 +1,52 @@
From b8a55871d5af6f5b8694b1cb5eacbc629734e403 Mon Sep 17 00:00:00 2001
From: Jun Qiu <jun.qiu@jaguarmicro.com>
Date: Wed, 27 Jul 2022 08:00:36 +0000
Subject: [PATCH] gro: trim tail padding bytes
Exclude CRC fields, the minimum Ethernet packet
length is 60 bytes. When the actual packet length
is less than 60 bytes, padding is added to the tail.
When GRO is performed on a packet containing a padding
field, mbuf->pkt_len is the one that contains the
padding field, which leads to the error of thinking
of the padding field as the actual content of the packet.
We need to trim away this extra padding field during
GRO processing.
Fixes: 0d2cbe59b719 ("lib/gro: support TCP/IPv4")
Cc: stable@dpdk.org
Signed-off-by: Jun Qiu <jun.qiu@jaguarmicro.com>
Acked-by: Jiayu Hu <Jiayu.hu@intel.com>
---
lib/gro/gro_tcp4.c | 7 ++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/librte_gro/gro_tcp4.c b/lib/librte_gro/gro_tcp4.c
index 9758e28fd5..8f5e800250 100644
--- a/lib/librte_gro/gro_tcp4.c
+++ b/lib/librte_gro/gro_tcp4.c
@@ -198,7 +198,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,
struct rte_tcp_hdr *tcp_hdr;
uint32_t sent_seq;
int32_t tcp_dl;
- uint16_t ip_id, hdr_len, frag_off;
+ uint16_t ip_id, hdr_len, frag_off, ip_tlen;
uint8_t is_atomic;
struct tcp4_flow_key key;
@@ -233,6 +233,11 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,
if (tcp_dl <= 0)
return -1;
+ /* trim the tail padding bytes */
+ ip_tlen = rte_be_to_cpu_16(ipv4_hdr->total_length);
+ if (pkt->pkt_len > (uint32_t)(ip_tlen + pkt->l2_len))
+ rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_tlen - pkt->l2_len);
+
/*
* Save IPv4 ID for the packet whose DF bit is 0. For the packet
* whose DF bit is 1, IPv4 ID is ignored.
--
2.23.0

View File

@ -1,6 +1,6 @@
Name: dpdk
Version: 19.11
Release: 21
Release: 22
Packager: packaging@6wind.com
URL: http://dpdk.org
%global source_version 19.11
@ -49,6 +49,9 @@ Patch6000: backport-vhost-handle-mbuf-allocation-failure.patch
Patch6001: backport-0001-CVE-2022-2132.patch
Patch6002: backport-0002-CVE-2022-2131.patch
Patch6003: backport-CVE-2022-28199.patch
Patch6004: backport-gro-fix-chain-index-for-more-than-2-packets.patch
Patch6005: backport-gro-trim-tail-padding-bytes.patch
Patch6006: backport-gro-check-payload-length-after-trim.patch
Summary: Data Plane Development Kit core
Group: System Environment/Libraries
@ -201,6 +204,11 @@ strip -g $RPM_BUILD_ROOT/lib/modules/${namer}/extra/dpdk/rte_kni.ko
/usr/sbin/depmod
%changelog
* Sat Oct 29 2022 jiangheng <jiangheng14@huawei.com> - 19.11-22
- gro: fix chain index for more than 2 packets
- gro: trim tail padding bytes
- gro: check payload length after trim
* Thu Oct 6 2022 wuchangsheng <wuchangsheng2@huawei.com> - 19.11-21
- reinit support return ok