All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.duyck@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	Alexander Duyck <alexander.h.duyck@intel.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	herbert@gondor.apana.org
Subject: Re: [PATCH] net: Do not include padding in TCP GRO checksum
Date: Thu, 14 Nov 2013 22:00:00 -0800	[thread overview]
Message-ID: <5285B860.1060800@gmail.com> (raw)
In-Reply-To: <20131115042057.GA24470@gondor.apana.org.au>

On 11/14/2013 08:20 PM, Herbert Xu wrote:
> On Thu, Nov 14, 2013 at 05:18:18PM -0800, Alexander Duyck wrote:
>> In some recent tests where I was generating invalid frames I found that
>> the checksum was being treated as valid for certain frames that computed
>> the checksum with padding included.  On closer inspection I found the
>> issue was that GRO was using the skb->len instead of the length recorded in
>> the IP/IPv6 header to determine the number of bytes to checksum.  As such
>> padded frames that actually had invalid checksums generated by adding the
>> padding to the checksum were being incorrectly tagged as valid.
>>
>> This change corrects that by using the tot_len from IPv4 headers and the
>> payload_len from IPv6 headers to compute the total number of bytes to be
>> included in the checksum.
>>
>> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> 
> Good catch.

I wouldn't have caught it except for I had introduced just the right
packet to see this when I was debugging some FPGA hardware.

> 
>> +	/* adjust for any offsets */
>> +	length += skb_network_offset(skb) - skb_gro_offset(skb);
> 
> Since skb->csum includes your padding, you'll need to adjust that
> as well.  Also this is not the only place where we use skb_gro_len
> to measure the packet length.  So rather than changing each one
> of them, I think we could just do a pskb_trim_rcsum at the point
> where we obtain the network packet length, i.e., in ipv4/ipv6.

I thought about doing it there, but it seemed like the preference was to
flush instead of trim.  Both the inet_gro_receive call and the
ipv6_gro_receive perform a check for length, and if it differs they set
the flush bit.

> We should then fix pskb_trim_rcsum to adjust CHECKSUM_COMPLETE
> checksums as otherwise your NIC's RX checksum offload feature
> will be useless.
> 
> Thanks,

If that is the case why aren't we doing this for ipv4 right now?  I
think what I will do for now is just detect the case where we are padded
for CHECKSUM_COMPLETE and simply fall back to the CHECKSUM_NONE case.

Thanks,

Alex

  reply	other threads:[~2013-11-15  5:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-15  1:18 [PATCH] net: Do not include padding in TCP GRO checksum Alexander Duyck
2013-11-15  1:26 ` Eric Dumazet
2013-11-15  4:08 ` David Miller
2013-11-15  5:34   ` Alexander Duyck
2013-11-15  4:20 ` Herbert Xu
2013-11-15  6:00   ` Alexander Duyck [this message]
2013-11-18 20:44 ` Ben Hutchings

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=5285B860.1060800@gmail.com \
    --to=alexander.duyck@gmail.com \
    --cc=alexander.h.duyck@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=herbert@gondor.apana.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.