patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: Yicai Lu <luyicai@huawei.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "zhoujingbin@huawei.com" <zhoujingbin@huawei.com>,
	"chenchanghu@huawei.com" <chenchanghu@huawei.com>,
	"jerry.lilijun@huawei.com" <jerry.lilijun@huawei.com>,
	"haifeng.lin@huawei.com" <haifeng.lin@huawei.com>,
	"guohongzhi1@huawei.com" <guohongzhi1@huawei.com>,
	"wangyunjian@huawei.com" <wangyunjian@huawei.com>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-stable] [PATCH v3] ip_frag: recalculate data length of fragment
Date: Mon, 7 Dec 2020 12:25:11 +0000
Message-ID: <BYAPR11MB3301665DF52D68C9964FB68B9ACE0@BYAPR11MB3301.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1607000077-30212-1-git-send-email-luyicai@huawei.com>


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


  parent reply	other threads:[~2020-12-07 12:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 12:54 Yicai Lu
2020-12-03 16:13 ` [dpdk-stable] [dpdk-dev] " Aaron Conole
2020-12-07  7:48   ` [dpdk-stable] 答复: " luyicai
2020-12-07 12:25 ` Ananyev, Konstantin [this message]
2020-12-12  9:53 [dpdk-stable] " luyicai

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=BYAPR11MB3301665DF52D68C9964FB68B9ACE0@BYAPR11MB3301.namprd11.prod.outlook.com \
    --to=konstantin.ananyev@intel.com \
    --cc=chenchanghu@huawei.com \
    --cc=dev@dpdk.org \
    --cc=guohongzhi1@huawei.com \
    --cc=haifeng.lin@huawei.com \
    --cc=jerry.lilijun@huawei.com \
    --cc=luyicai@huawei.com \
    --cc=stable@dpdk.org \
    --cc=wangyunjian@huawei.com \
    --cc=zhoujingbin@huawei.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

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git