From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Tom Herbert <tom@herbertland.com>,
Eric Dumazet <edumazet@google.com>
Subject: [Patch net] net: invert the check of detecting hardware RX checksum fault
Date: Thu, 15 Nov 2018 15:16:02 -0800 [thread overview]
Message-ID: <20181115231602.18328-1-xiyou.wangcong@gmail.com> (raw)
The following evidences indicate this check is likely wrong:
1. In the assignment "skb->csum_valid = !sum", sum==0 indicates a valid checksum.
2. __skb_checksum_complete() always returns sum, and TCP packets are dropped
only when it returns non-zero. So non-zero indicates a failure.
3. In __skb_checksum_validate_complete(), we have a nearly same check, where
zero is considered as success.
4. csum_fold() already does the one’s complement, this indicates 0 should
be considered as a successful validation.
5. We have triggered this fault for many times, but InCsumErrors field in
/proc/net/snmp remains 0.
Base on the above, non-zero should be used as a checksum mismatch.
I tested this with mlx5 driver, no warning or InCsumErrors after 1 hour.
Fixes: fb286bb2990a ("[NET]: Detect hardware rx checksum faults correctly")
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Tom Herbert <tom@herbertland.com>
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
net/core/datagram.c | 4 ++--
net/core/dev.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 57f3a6fcfc1e..e542a9a212a7 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -733,7 +733,7 @@ __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len)
__sum16 sum;
sum = csum_fold(skb_checksum(skb, 0, len, skb->csum));
- if (likely(!sum)) {
+ if (unlikely(sum)) {
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) &&
!skb->csum_complete_sw)
netdev_rx_csum_fault(skb->dev);
@@ -753,7 +753,7 @@ __sum16 __skb_checksum_complete(struct sk_buff *skb)
/* skb->csum holds pseudo checksum */
sum = csum_fold(csum_add(skb->csum, csum));
- if (likely(!sum)) {
+ if (unlikely(sum)) {
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) &&
!skb->csum_complete_sw)
netdev_rx_csum_fault(skb->dev);
diff --git a/net/core/dev.c b/net/core/dev.c
index 0ffcbdd55fa9..c76dee329844 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5776,7 +5776,7 @@ __sum16 __skb_gro_checksum_complete(struct sk_buff *skb)
/* NAPI_GRO_CB(skb)->csum holds pseudo checksum */
sum = csum_fold(csum_add(NAPI_GRO_CB(skb)->csum, wsum));
- if (likely(!sum)) {
+ if (unlikely(sum)) {
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) &&
!skb->csum_complete_sw)
netdev_rx_csum_fault(skb->dev);
--
2.19.1
next reply other threads:[~2018-11-16 9:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 23:16 Cong Wang [this message]
2018-11-16 1:52 ` [Patch net] net: invert the check of detecting hardware RX checksum fault Herbert Xu
2018-11-16 2:23 ` Cong Wang
2018-11-16 4:50 ` Herbert Xu
2018-11-16 20:06 ` Cong Wang
2018-11-16 21:32 ` Cong Wang
2018-11-19 4:01 ` Herbert Xu
2018-11-19 19:25 ` Cong Wang
2018-11-20 3:09 ` Herbert Xu
2018-11-22 1:25 ` Paweł Staszewski
2018-11-16 4:52 ` Eric Dumazet
2018-11-16 4:59 ` Herbert Xu
2018-11-16 20:10 ` Cong Wang
2018-11-16 20:15 ` Cong Wang
2018-11-16 21:33 ` Eric Dumazet
2018-11-20 1:42 ` Cong Wang
2018-11-20 1:47 ` Eric Dumazet
2018-11-20 18:13 ` David Miller
2018-11-20 18:18 ` Eric Dumazet
2018-11-21 3:35 ` Herbert Xu
2018-11-18 0:40 ` David Miller
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=20181115231602.18328-1-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=tom@herbertland.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