[dpdk-dev] [PATCH v3] ip_frag: recalculate data length of fragment

Aaron Conole aconole at redhat.com
Thu Dec 3 17:13:44 CET 2020


Yicai Lu <luyicai at huawei.com> writes:

> 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 at dpdk.org
>
> Signed-off-by: Yicai Lu <luyicai at huawei.com>
> ---

Sorry for coming late to the party.

Are you saying that we have fragments which are less than min ip_len
for anything other than the final fragment?  Or the total data length
after all fragments are reassembled is < min_ip_len ?

like:

frag1, len = 48
frag2, len = 10

something like that?  Can you put some concrete examples in the commit
message (or even better, include a test case in the ipv4_frag test suite
that shows this)?

> 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



More information about the dev mailing list