diff --git a/backport-gro-check-payload-length-after-trim.patch b/backport-gro-check-payload-length-after-trim.patch new file mode 100644 index 0000000000000000000000000000000000000000..f1f1a888f9dfa3b90176047625a5f7aca7980865 --- /dev/null +++ b/backport-gro-check-payload-length-after-trim.patch @@ -0,0 +1,82 @@ +From 72f51b097a71fb9bdea13bdd254ff620b34c852e Mon Sep 17 00:00:00 2001 +From: Kumara Parameshwaran +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 +Acked-by: Jiayu Hu +--- + lib/gro/gro_tcp4.c | 11 ++++++----- + lib/gro/gro_udp4.c | 10 +++++----- + 2 files changed, 11 insertions(+), 10 deletions(-) + +diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c +index 8f5e800250..0014096e63 100644 +--- a/lib/gro/gro_tcp4.c ++++ b/lib/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. +diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c +index 839f9748b7..42596d33b6 100644 +--- a/lib/gro/gro_udp4.c ++++ b/lib/gro/gro_udp4.c +@@ -220,6 +220,11 @@ gro_udp4_reassemble(struct rte_mbuf *pkt, + if (!is_ipv4_fragment(ipv4_hdr)) + return -1; + ++ ip_dl = rte_be_to_cpu_16(ipv4_hdr->total_length); ++ /* trim the tail padding bytes */ ++ if (pkt->pkt_len > (uint32_t)(ip_dl + pkt->l2_len)) ++ rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_dl - pkt->l2_len); ++ + /* + * Don't process the packet whose payload length is less than or + * equal to 0. +@@ -227,14 +232,9 @@ gro_udp4_reassemble(struct rte_mbuf *pkt, + if (pkt->pkt_len <= hdr_len) + return -1; + +- ip_dl = rte_be_to_cpu_16(ipv4_hdr->total_length); + if (ip_dl <= pkt->l3_len) + return -1; + +- /* trim the tail padding bytes */ +- if (pkt->pkt_len > (uint32_t)(ip_dl + pkt->l2_len)) +- rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_dl - pkt->l2_len); +- + ip_dl -= pkt->l3_len; + ip_id = rte_be_to_cpu_16(ipv4_hdr->packet_id); + frag_offset = rte_be_to_cpu_16(ipv4_hdr->fragment_offset); +-- +2.23.0 + diff --git a/backport-gro-trim-tail-padding-bytes.patch b/backport-gro-trim-tail-padding-bytes.patch new file mode 100644 index 0000000000000000000000000000000000000000..f34d4a93fe5b62eba9a6172419480ee18797789b --- /dev/null +++ b/backport-gro-trim-tail-padding-bytes.patch @@ -0,0 +1,68 @@ +From b8a55871d5af6f5b8694b1cb5eacbc629734e403 Mon Sep 17 00:00:00 2001 +From: Jun Qiu +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 +Acked-by: Jiayu Hu +--- + lib/gro/gro_tcp4.c | 7 ++++++- + lib/gro/gro_udp4.c | 4 ++++ + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c +index 9758e28fd5..8f5e800250 100644 +--- a/lib/gro/gro_tcp4.c ++++ b/lib/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. +diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c +index dd71135ada..839f9748b7 100644 +--- a/lib/gro/gro_udp4.c ++++ b/lib/gro/gro_udp4.c +@@ -231,6 +231,10 @@ gro_udp4_reassemble(struct rte_mbuf *pkt, + if (ip_dl <= pkt->l3_len) + return -1; + ++ /* trim the tail padding bytes */ ++ if (pkt->pkt_len > (uint32_t)(ip_dl + pkt->l2_len)) ++ rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_dl - pkt->l2_len); ++ + ip_dl -= pkt->l3_len; + ip_id = rte_be_to_cpu_16(ipv4_hdr->packet_id); + frag_offset = rte_be_to_cpu_16(ipv4_hdr->fragment_offset); +-- +2.23.0 + diff --git a/dpdk.spec b/dpdk.spec index 4d6eff690566391c12817121613ccb5d4ba396fe..a2378d204d0cbe991e07936bcb111c61c28fcf59 100644 --- a/dpdk.spec +++ b/dpdk.spec @@ -1,6 +1,6 @@ Name: dpdk Version: 21.11 -Release: 19 +Release: 20 Packager: packaging@6wind.com URL: http://dpdk.org %global source_version 21.11 @@ -203,6 +203,9 @@ Patch9187: 0187-telemetry-limit-command-characters.patch Patch9188: 0188-telemetry-eliminate-duplicate-code-for-json-output.patch Patch9189: 0189-telemetry-make-help-command-more-helpful.patch +Patch6006: backport-gro-trim-tail-padding-bytes.patch +Patch6007: backport-gro-check-payload-length-after-trim.patch + Summary: Data Plane Development Kit core Group: System Environment/Libraries License: BSD and LGPLv2 and GPLv2 @@ -330,6 +333,10 @@ strip -g $RPM_BUILD_ROOT/lib/modules/%{kern_devel_ver}/extra/dpdk/igb_uio.ko /usr/sbin/depmod %changelog +* Fri Oct 28 2022 jiangheng - 21.11-20 +- gro: trim tail padding bytes +- gro: check payload length after trim + * Sat Oct 22 2022 Huisong Li - 21.11-19 Sync some patches for hns3 PMD, telemetry and testpmd. And main modifications are as follows: