netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yadu Kishore <kyk.segfault@gmail.com>
To: davem@davemloft.net
Cc: David.Laight@aculab.com, eric.dumazet@gmail.com,
	kyk.segfault@gmail.com, netdev@vger.kernel.org,
	willemdebruijn.kernel@gmail.com
Subject: [PATCH v3] net: Make skb_segment not to compute checksum if network controller supports checksumming
Date: Tue, 17 Mar 2020 14:08:38 +0530	[thread overview]
Message-ID: <1584434318-27980-1-git-send-email-kyk.segfault@gmail.com> (raw)
In-Reply-To: <20200313.110542.570427563998639331.davem@davemloft.net>


> I think you can rebase and submit against net-next.

> If your patch isn't active in the networking development patchwork instance,
> it is not pending to be applied and you must resend it.

Rebasing the patch on net-next and resending it.

Problem:
TCP checksum in the output path is not being offloaded during GSO
in the following case:
The network driver does not support scatter-gather but supports
checksum offload with NETIF_F_HW_CSUM.

Cause:
skb_segment calls skb_copy_and_csum_bits if the network driver
does not announce NETIF_F_SG. It does not check if the driver
supports NETIF_F_HW_CSUM.
So for devices which might want to offload checksum but do not support SG
there is currently no way to do so if GSO is enabled.

Solution:
In skb_segment check if the network controller does checksum and if so
call skb_copy_bits instead of skb_copy_and_csum_bits.

Testing:
Without the patch, ran iperf TCP traffic with NETIF_F_HW_CSUM enabled
in the network driver. Observed the TCP checksum offload is not happening
since the skbs received by the driver in the output path have
skb->ip_summed set to CHECKSUM_NONE.

With the patch ran iperf TCP traffic and observed that TCP checksum
is being offloaded with skb->ip_summed set to CHECKSUM_PARTIAL.
Also tested with the patch by disabling NETIF_F_HW_CSUM in the driver
to cover the newly introduced if-else code path in skb_segment.

Link: https://lore.kernel.org/netdev/CA+FuTSeYGYr3Umij+Mezk9CUcaxYwqEe5sPSuXF8jPE2yMFJAw@mail.gmail.com
Signed-off-by: Yadu Kishore <kyk.segfault@gmail.com>
---
 net/core/skbuff.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e1101a4..621b447 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3926,14 +3926,21 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
 			goto perform_csum_check;
 
 		if (!sg) {
-			if (!nskb->remcsum_offload)
-				nskb->ip_summed = CHECKSUM_NONE;
-			SKB_GSO_CB(nskb)->csum =
-				skb_copy_and_csum_bits(head_skb, offset,
-						       skb_put(nskb, len),
-						       len, 0);
-			SKB_GSO_CB(nskb)->csum_start =
-				skb_headroom(nskb) + doffset;
+			if (!csum) {
+				if (!nskb->remcsum_offload)
+					nskb->ip_summed = CHECKSUM_NONE;
+				SKB_GSO_CB(nskb)->csum =
+					skb_copy_and_csum_bits(head_skb, offset,
+							       skb_put(nskb,
+								       len),
+							       len, 0);
+				SKB_GSO_CB(nskb)->csum_start =
+					skb_headroom(nskb) + doffset;
+			} else {
+				skb_copy_bits(head_skb, offset,
+					      skb_put(nskb, len),
+					      len);
+			}
 			continue;
 		}
 
-- 
2.7.4


  reply	other threads:[~2020-03-17  8:39 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04  5:55 TCP checksum not offloaded during GSO Yadu Kishore
2020-02-05 21:43 ` Willem de Bruijn
2020-02-21  5:13   ` [PATCH] net: Make skb_segment not to compute checksum if network controller supports checksumming Yadu Kishore
2020-02-23  2:41     ` Willem de Bruijn
2020-02-28  5:24       ` Yadu Kishore
2020-02-28 14:30         ` Willem de Bruijn
2020-02-28 20:01           ` David Miller
2020-03-02  6:51             ` [PATCH v2] " Yadu Kishore
2020-03-02  8:42               ` Yadu Kishore
2020-03-02 15:19                 ` David Laight
2020-03-03  9:15                   ` Yadu Kishore
2020-03-03  9:56                     ` David Laight
2020-03-05  6:32                       ` Yadu Kishore
2020-03-05 16:06                         ` Willem de Bruijn
2020-03-05 17:00                           ` David Laight
2020-03-05 17:19                             ` Eric Dumazet
2020-03-06 17:12                               ` David Laight
2020-03-13  6:36                                 ` Yadu Kishore
2020-03-13 13:57                                   ` Willem de Bruijn
2020-03-13 14:04                                     ` David Laight
2020-03-13 18:05                                   ` David Miller
2020-03-17  8:38                                     ` Yadu Kishore [this message]
2020-03-22  3:06                                       ` [PATCH v3] " David Miller
2020-03-22 14:40                                       ` Willem de Bruijn
2020-03-23 20:00                                       ` David Miller
2020-03-22 19:53                                 ` [PATCH v2] " Tom Herbert
2020-03-23  9:15                                   ` David Laight
2020-02-06 12:13 ` TCP checksum not offloaded during GSO David Laight

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=1584434318-27980-1-git-send-email-kyk.segfault@gmail.com \
    --to=kyk.segfault@gmail.com \
    --cc=David.Laight@aculab.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=willemdebruijn.kernel@gmail.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).