DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v3] ip_frag: recalculate data length of fragment
@ 2020-12-03 12:54 Yicai Lu
  2020-12-03 16:13 ` Aaron Conole
  2020-12-07 12:25 ` [dpdk-dev] " Ananyev, Konstantin
  0 siblings, 2 replies; 5+ messages in thread
From: Yicai Lu @ 2020-12-03 12:54 UTC (permalink / raw)
  To: dev
  Cc: konstantin.ananyev, zhoujingbin, chenchanghu, jerry.lilijun,
	haifeng.lin, guohongzhi1, wangyunjian, Yicai Lu, stable

In some situations, we would get several ip fragments, which total
data length is less than minimum frame(64) and padding with zeros.
Examples: Second Fragment "a0a1 a2a3 a4a5 a6a7 0000 0000 ..."
and Third Fragment "a8a9 aaab acad aeaf b0b1 b2b3 ...".
Finally, we would reassemble Second and Third Fragment like this
"a0a1 a2a3 a4a5 a6a7 0000 0000 ... a8a9 aaab acad aeaf b0b1 ...",
which is not correct!
So, we need recalculate data length of fragment to remove padings!

Fixes: 7f0983ee331c ("ip_frag: check fragment length of incoming packet")
Cc: stable@dpdk.org

Signed-off-by: Yicai Lu <luyicai@huawei.com>
---
v2 -> v3: Update the comments.
---
 lib/librte_ip_frag/rte_ipv4_reassembly.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_ip_frag/rte_ipv4_reassembly.c b/lib/librte_ip_frag/rte_ipv4_reassembly.c
index 1dda8aca0..9a9fe3703 100644
--- a/lib/librte_ip_frag/rte_ipv4_reassembly.c
+++ b/lib/librte_ip_frag/rte_ipv4_reassembly.c
@@ -117,6 +117,7 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 
 	ip_ofs *= RTE_IPV4_HDR_OFFSET_UNITS;
 	ip_len = rte_be_to_cpu_16(ip_hdr->total_length) - mb->l3_len;
+	mb->data_len = ip_len + mb->l3_len + mb->l2_len;
 
 	IP_FRAG_LOG(DEBUG, "%s:%d:\n"
 		"mbuf: %p, tms: %" PRIu64
-- 
2.28.0.windows.1


^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ip_frag: recalculate data length of fragment
@ 2020-12-12  9:53 luyicai
  0 siblings, 0 replies; 5+ messages in thread
From: luyicai @ 2020-12-12  9:53 UTC (permalink / raw)
  To: Ananyev, Konstantin, dev
  Cc: Zhoujingbin (Robin, Russell Lab), chenchanghu, Lilijun (Jerry),
	Linhaifeng, Guohongzhi (Russell Lab),
	wangyunjian, stable

Hi,

Thank you so much for your review!
I absolutely agree with that, and
I'll resubmit a patch as soon as possible.

> -----Original Message-----
> From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> Sent: Monday, December 7, 2020 8:25 PM
> To: luyicai <luyicai@huawei.com>; dev@dpdk.org
> Cc: Zhoujingbin (Robin, Russell Lab) <zhoujingbin@huawei.com>; 
> chenchanghu <chenchanghu@huawei.com>; Lilijun (Jerry) 
> <jerry.lilijun@huawei.com>; Linhaifeng <haifeng.lin@huawei.com>; 
> Guohongzhi (Russell Lab) <guohongzhi1@huawei.com>; wangyunjian 
> <wangyunjian@huawei.com>; stable@dpdk.org
> Subject: RE: [PATCH v3] ip_frag: recalculate data length of fragment


> Hi,
 
> In some situations, we would get several ip fragments, which total 
> data length is less than minimum frame(64) and padding with zeros.
> Examples: Second Fragment "a0a1 a2a3 a4a5 a6a7 0000 0000 ..."
> and Third Fragment "a8a9 aaab acad aeaf b0b1 b2b3 ...".
> Finally, we would reassemble Second and Third Fragment like this
> "a0a1 a2a3 a4a5 a6a7 0000 0000 ... a8a9 aaab acad aeaf b0b1 ...", 
> which is not correct!
> So, we need recalculate data length of fragment to remove padings!
> 
> Fixes: 7f0983ee331c ("ip_frag: check fragment length of incoming
> packet")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yicai Lu <luyicai@huawei.com>
> ---
> v2 -> v3: Update the comments.
> ---
>  lib/librte_ip_frag/rte_ipv4_reassembly.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_ip_frag/rte_ipv4_reassembly.c
> b/lib/librte_ip_frag/rte_ipv4_reassembly.c
> index 1dda8aca0..9a9fe3703 100644
> --- a/lib/librte_ip_frag/rte_ipv4_reassembly.c
> +++ b/lib/librte_ip_frag/rte_ipv4_reassembly.c
> @@ -117,6 +117,7 @@ rte_ipv4_frag_reassemble_packet(struct
> rte_ip_frag_tbl *tbl,
> 
>  	ip_ofs *= RTE_IPV4_HDR_OFFSET_UNITS;
>  	ip_len = rte_be_to_cpu_16(ip_hdr->total_length) - mb->l3_len;
> +	mb->data_len = ip_len + mb->l3_len + mb->l2_len;

> That doesn't look correct.
> Even one fragment can consist of multiple segments.
> Plus you don't update mb->pkt_len.
> To do it properly, you'll need something like:
> trim = mb->pkt_len  - ip_len + mb->l3_len + mb->l2_len; 
> rte_pktmbuf_trim(mb, trim);

> Though my preference would be to leave it as responsibility of the 
> caller (As it has to parse packet anyway to fill l2_len/l3_len and 
> usually strips
> l2 headers, etc).  

> 
>  	IP_FRAG_LOG(DEBUG, "%s:%d:\n"
>  		"mbuf: %p, tms: %" PRIu64
> --
> 2.28.0.windows.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-12  9:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 12:54 [dpdk-dev] [PATCH v3] ip_frag: recalculate data length of fragment Yicai Lu
2020-12-03 16:13 ` Aaron Conole
2020-12-07  7:48   ` [dpdk-dev] 答复: " luyicai
2020-12-07 12:25 ` [dpdk-dev] " Ananyev, Konstantin
2020-12-12  9:53 luyicai

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).