From: George Prekas <prekageo@amazon.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>,
Wenzhuo Lu <wenzhuo.lu@intel.com>,
Beilei Xing <beilei.xing@intel.com>,
Bernard Iremonger <bernard.iremonger@intel.com>
Cc: <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] app/testpmd: fix IP checksum calculation
Date: Fri, 4 Dec 2020 23:47:39 -0600 [thread overview]
Message-ID: <1475e52a-7801-60f8-d246-7bc9e786e95e@amazon.com> (raw)
In-Reply-To: <4d9e5925-8439-330c-cb27-aac64878fc24@intel.com>
On 12/4/2020 2:59 AM, Ferruh Yigit wrote:
> CAUTION: This email originated from outside of the organization. Do
> not click links or open attachments unless you can confirm the sender
> and know the content is safe.
>
>
>
> On 12/3/2020 1:59 PM, George Prekas wrote:
>> Insert a compiler barrier to make sure that the IP checksum calculation
>> happens after setting all the fields of the IP header.
>>
>
> Can you please provide the compiler details, and if there is any specific
> instruction on how to reproduce this failure?
This happens with GCC 9 and GCC 10. It works fine on GCC 8.
Stephen was right that a compiler barrier here is not the right
solution. After spending some time on it, I realized that it is an
aliasing problem when casting the IP header to uint16_t*. As far as I
understand, this is not allowed by the C standard. As far as I know,
there are 3 ways to fix this problem: Use a union, use memcpy, or set
the compiler flag -fno-strict-aliasing. I assume that the last option is
the least intrusive. I've submitted a second version of the patch with it.
Let me know of your opinion.
>
>> Signed-off-by: George Prekas <prekageo@amazon.com>
>> ---
>> app/test-pmd/flowgen.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c
>> index acf3e2460..893b4b0b8 100644
>> --- a/app/test-pmd/flowgen.c
>> +++ b/app/test-pmd/flowgen.c
>> @@ -150,6 +150,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
>> next_flow);
>> ip_hdr->total_length = RTE_CPU_TO_BE_16(pkt_size -
>> sizeof(*eth_hdr));
>> + rte_compiler_barrier();
>> ip_hdr->hdr_checksum = ip_sum((unaligned_uint16_t
>> *)ip_hdr,
>> sizeof(*ip_hdr));
>>
>>
>
next prev parent reply other threads:[~2020-12-05 5:48 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 13:59 George Prekas
2020-12-03 16:08 ` Stephen Hemminger
2020-12-03 16:35 ` George Prekas
2020-12-03 18:33 ` Stephen Hemminger
2020-12-04 8:59 ` Ferruh Yigit
2020-12-05 5:47 ` George Prekas [this message]
2020-12-05 5:42 ` [dpdk-dev] [PATCH v2] " George Prekas
2021-01-05 16:26 ` George Prekas
2021-01-06 18:02 ` Ferruh Yigit
2021-01-07 5:25 ` Stephen Hemminger
2021-01-07 5:39 ` George Prekas
2021-01-07 11:32 ` Ferruh Yigit
2021-01-07 13:06 ` Ferruh Yigit
2021-01-07 14:20 ` George Prekas
2021-01-07 15:22 ` Ferruh Yigit
2021-01-07 20:45 ` George Prekas
2021-01-07 15:50 ` Stephen Hemminger
2021-01-07 15:59 ` Ferruh Yigit
2021-01-07 16:29 ` Stephen Hemminger
2021-01-07 20:42 ` [dpdk-dev] [PATCH v3] " George Prekas
2021-01-18 15:20 ` Ferruh Yigit
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=1475e52a-7801-60f8-d246-7bc9e786e95e@amazon.com \
--to=prekageo@amazon.com \
--cc=beilei.xing@intel.com \
--cc=bernard.iremonger@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=wenzhuo.lu@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).