DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
To: jiayu.hu@intel.com
Cc: dev@dpdk.org, Kumara Parameshwaran <kumaraparamesh92@gmail.com>
Subject: [PATCH] gro : fix pkt length when extra bytes are padded to ethernet frame
Date: Mon, 10 Oct 2022 23:21:09 +0530	[thread overview]
Message-ID: <20221010175109.44282-1-kumaraparmesh92@gmail.com> (raw)

From: Kumara Parameshwaran <kumaraparamesh92@gmail.com>

When GRO packets are merged the packet length is used while
merging the adjacent packets. If the padded bytes are accounted
we would end up acking unsent TCP segments.

Signed-off-by: Kumara Parameshwaran <kumaraparamesh92@gmail.com>
v1:
	If there is padding to the ethernet frame cases where timestamp is disabled
	the packet length should be validated with the total ip length as packet length 
	is used in the GRO merging logic

---
 lib/gro/gro_tcp4.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 7498c66141..ac6439bb4e 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_len;
 	uint8_t is_atomic;
 
 	struct tcp4_flow_key key;
@@ -219,6 +219,12 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt,
 	tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
 	hdr_len = pkt->l2_len + pkt->l3_len + pkt->l4_len;
 
+	ip_len = rte_be_to_cpu_16(ipv4_hdr->total_length);
+	/* To handle padding cases in cases like where timestamps are disabled */
+	if (unlikely(pkt->pkt_len > (uint32_t)(ip_len + pkt->l2_len))) {
+		pkt->pkt_len = ip_len + pkt->l2_len;
+	}
+
 	/*
 	 * Don't process the packet which has FIN, SYN, RST, PSH, URG, ECE
 	 * or CWR set.
-- 
2.25.1


             reply	other threads:[~2022-10-10 17:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 17:51 Kumara Parameshwaran [this message]
2022-10-10 19:32 ` David Marchand
     [not found]   ` <CANxNyasJ7RWk6S9hArfKc=m39huCOgab92sV4DjxDh0VENLf7Q@mail.gmail.com>
2022-10-11  5:47     ` Fwd: " kumaraparameshwaran rathinavel
2022-10-12  1:34       ` Jun Qiu
2022-10-12  7:48         ` kumaraparameshwaran rathinavel
2022-10-12  7:50           ` David Marchand
2022-10-16  7:01         ` Hu, Jiayu
2022-10-17 13:27           ` kumaraparameshwaran rathinavel
2023-10-31 18:49             ` Stephen Hemminger
2022-10-16 14:43 ` [PATCH v2] gro : check for payload length after the trim Kumara Parameshwaran
2022-10-18  8:21   ` Hu, Jiayu
2022-10-26 15:23     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221010175109.44282-1-kumaraparmesh92@gmail.com \
    --to=kumaraparamesh92@gmail.com \
    --cc=dev@dpdk.org \
    --cc=jiayu.hu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).