From: "Deng, KaiwenX" <kaiwenx.deng@intel.com>
To: Ferruh Yigit <ferruh.yigit@amd.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "stable@dpdk.org" <stable@dpdk.org>,
"Yang, Qiming" <qiming.yang@intel.com>,
"Zhou, YidingX" <yidingx.zhou@intel.com>,
"Singh, Aman Deep" <aman.deep.singh@intel.com>,
"Zhang, Yuying" <yuying.zhang@intel.com>,
"Matz, Olivier" <olivier.matz@6wind.com>,
"De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
Subject: RE: [PATCH] app/test-pmd: fix L4 checksum with padding data
Date: Tue, 14 Nov 2023 02:19:59 +0000 [thread overview]
Message-ID: <SA3PR11MB800351E1FF8155CA77C852C98EB2A@SA3PR11MB8003.namprd11.prod.outlook.com> (raw)
In-Reply-To: <3aa757eb-23e1-4492-8c14-342540d0899d@amd.com>
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@amd.com>
> Sent: Friday, November 3, 2023 12:03 PM
> To: Deng, KaiwenX <kaiwenx.deng@intel.com>; dev@dpdk.org
> Cc: stable@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Zhou, YidingX
> <yidingx.zhou@intel.com>; Singh, Aman Deep <aman.deep.singh@intel.com>;
> Zhang, Yuying <yuying.zhang@intel.com>; Matz, Olivier
> <olivier.matz@6wind.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: Re: [PATCH] app/test-pmd: fix L4 checksum with padding data
>
> On 11/3/2023 2:49 AM, Deng, KaiwenX wrote:
> >
> >
> >> -----Original Message-----
> >> From: Ferruh Yigit <ferruh.yigit@amd.com>
> >> Sent: Friday, November 3, 2023 3:20 AM
> >> To: Deng, KaiwenX <kaiwenx.deng@intel.com>; dev@dpdk.org
> >> Cc: stable@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Zhou,
> >> YidingX <yidingx.zhou@intel.com>; Singh, Aman Deep
> >> <aman.deep.singh@intel.com>; Zhang, Yuying <yuying.zhang@intel.com>;
> >> Matz, Olivier <olivier.matz@6wind.com>; De Lara Guarch, Pablo
> >> <pablo.de.lara.guarch@intel.com>
> >> Subject: Re: [PATCH] app/test-pmd: fix L4 checksum with padding data
> >>
> >> On 8/4/2023 9:28 AM, Kaiwen Deng wrote:
> >>> IEEE 802 packets may have a minimum size limit. The data fields
> >>> should be padded when necessary. In some cases, the padding data is not
> zero.
> >>> Testpmd does not trim these IP packets to the true length of the
> >>> frame, so errors will occur when calculating TCP or UDP checksum.
> >>>
> >>
> >> Hi Kaiwen,
> >>
> >> I am trying to understand the problem, what is the testcase that has
> >> checksum error?
> >>
> >> Are the received mbuf data_len & pkt_len wrong? Instead of trying to
> >> fix the mbuf during forwarding, can we fix where packet generated?
> >>
> > Hi Ferruh,
> >
> > In effect, the packet is padded by the switch.
> > IEEE 802 packets may have a minimum size limit. The data fields should
> > be padded by switch when necessary. In some switches, the padding data is
> not zero.
> >
> > Csumonly doesn't trim these packets to the true length of the frame.
> > In csumonly, the received mbuf data_len is the true length of the packet plus
> the padding data len.
> > Therefore, padding data is included in the checksum calculation.
> > When the padding data is not zero, the checksum is wrong.
> >
Hi,
Sorry for late reply.
The minimum frame length specified by IEEE 802.3 is 64 bytes. In practice,
there are many packets less than 64 bytes that are padding through the switch.
We found this issue because some customers found that their packets could not
calculate checksum correctly, they would send some packets less than 64 bytes,
but our app didn't strip the padding data for such packets.
>
> Thanks for clarification.
>
> Even some non-zero padding added, it will calculate the csum successfully, but
> I assume in this case csum becomes different than expected csum and test
> fails?
>
> In this case why not fix the generated packets, and make them compatible to
> minimum size requirement? What is generating packets?
>
>
> >>> This commit fixes this issue by triming IP packets to the true
> >>> length of the frame in testpmd.
> >>>
> >>> Fixes: 03d17e4d0179 ("app/testpmd: do not change IP addrs in
> >>> checksum
> >>> engine")
> >>> Cc: stable@dpdk.org
> >>>
> >>> Signed-off-by: Kaiwen Deng <kaiwenx.deng@intel.com>
> >>> ---
> >>> app/test-pmd/csumonly.c | 32
> ++++++++++++++++++++++++++++++++
> >>> 1 file changed, 32 insertions(+)
> >>>
> >>> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index
> >>> 7af635e3f7..58b72b714a 100644
> >>> --- a/app/test-pmd/csumonly.c
> >>> +++ b/app/test-pmd/csumonly.c
> >>> @@ -853,12 +853,14 @@ pkt_burst_checksum_forward(struct
> >> fwd_stream *fs)
> >>> uint16_t nb_rx;
> >>> uint16_t nb_prep;
> >>> uint16_t i;
> >>> + uint16_t pad_len;
> >>> uint64_t rx_ol_flags, tx_ol_flags;
> >>> uint64_t tx_offloads;
> >>> uint32_t rx_bad_ip_csum;
> >>> uint32_t rx_bad_l4_csum;
> >>> uint32_t rx_bad_outer_l4_csum;
> >>> uint32_t rx_bad_outer_ip_csum;
> >>> + uint32_t l3_off;
> >>> struct testpmd_offload_info info;
> >>>
> >>> /* receive a burst of packet */
> >>> @@ -980,6 +982,36 @@ pkt_burst_checksum_forward(struct
> fwd_stream
> >> *fs)
> >>> l3_hdr = (char *)l3_hdr + info.outer_l3_len +
> >> info.l2_len;
> >>> }
> >>>
> >>> + if (info.is_tunnel) {
> >>> + l3_off = info.outer_l2_len +
> >>> + info.outer_l3_len +
> >>> + info.l2_len;
> >>> + } else {
> >>> + l3_off = info.l2_len;
> >>> + }
> >>> + switch (info.ethertype) {
> >>> + case _htons(RTE_ETHER_TYPE_IPV4):
> >>> + pad_len = rte_pktmbuf_data_len(m) -
> >>> + (l3_off +
> >>> + rte_be_to_cpu_16(
> >>> + ((struct rte_ipv4_hdr *)l3_hdr)-
> >>> total_length));
> >>> + break;
> >>> + case _htons(RTE_ETHER_TYPE_IPV6):
> >>> + pad_len = rte_pktmbuf_data_len(m) -
> >>> + (l3_off +
> >>> + rte_be_to_cpu_16(
> >>> + ((struct rte_ipv6_hdr *)l3_hdr)-
> >>> payload_len));
> >>> + break;
> >>> + default:
> >>> + pad_len = 0;
> >>> + break;
> >>> + }
> >>> +
> >>> + if (pad_len) {
> >>> + rte_pktmbuf_data_len(m) =
> >> rte_pktmbuf_data_len(m) - pad_len;
> >>> + rte_pktmbuf_pkt_len(m) = rte_pktmbuf_data_len(m);
> >>> + }
> >>> +
> >>> /* step 2: depending on user command line configuration,
> >>> * recompute checksum either in software or flag the
> >>> * mbuf to offload the calculation to the NIC. If TSO
> >
next prev parent reply other threads:[~2023-11-14 2:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 8:28 Kaiwen Deng
2023-11-02 19:20 ` Ferruh Yigit
2023-11-03 2:49 ` Deng, KaiwenX
2023-11-03 4:03 ` Ferruh Yigit
2023-11-14 2:19 ` Deng, KaiwenX [this message]
2023-11-14 19:09 ` Ferruh Yigit
2023-11-16 7:02 ` Deng, KaiwenX
2023-11-16 22:58 ` Stephen Hemminger
2023-11-17 0:50 ` Ferruh Yigit
2023-11-17 3:28 ` Stephen Hemminger
2023-11-17 9:29 ` Ferruh Yigit
2023-11-17 12:11 ` Morten Brørup
2023-11-17 16:23 ` Stephen Hemminger
2023-11-17 16:22 ` Stephen Hemminger
2023-11-20 10:47 ` Ferruh Yigit
2023-11-20 9:21 ` Deng, KaiwenX
2023-11-20 10:46 ` Ferruh Yigit
2023-11-22 3:04 ` Deng, KaiwenX
2023-11-17 1:13 ` Ferruh Yigit
2023-11-20 9:52 ` Deng, KaiwenX
2023-12-07 8:53 ` [PATCH v2] app/test-pmd: fix tcp/udp cksum " Kaiwen Deng
2023-12-07 14:35 ` Ferruh Yigit
2023-12-12 2:16 ` [PATCH v3] lib/net: " Kaiwen Deng
2023-12-12 8:10 ` Morten Brørup
2023-12-13 4:37 ` [PATCH v4] " Kaiwen Deng
2023-12-13 7:36 ` Morten Brørup
2023-12-14 9:22 ` [PATCH v5] " Kaiwen Deng
2023-12-14 11:20 ` Morten Brørup
2024-02-19 1:10 ` 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=SA3PR11MB800351E1FF8155CA77C852C98EB2A@SA3PR11MB8003.namprd11.prod.outlook.com \
--to=kaiwenx.deng@intel.com \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=olivier.matz@6wind.com \
--cc=pablo.de.lara.guarch@intel.com \
--cc=qiming.yang@intel.com \
--cc=stable@dpdk.org \
--cc=yidingx.zhou@intel.com \
--cc=yuying.zhang@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).