All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Saeed Mahameed <saeedm@mellanox.com>,
	Eric Dumazet <edumazet@google.com>
Subject: Re: [Patch net] mlx5: fixup checksum for ethernet padding
Date: Tue, 27 Nov 2018 16:07:27 -0800	[thread overview]
Message-ID: <CAM_iQpW2=rTa-QZxK5ygvr=UgM9Lcxr_NyPiD=1jh3Hgovn2gQ@mail.gmail.com> (raw)
In-Reply-To: <0b5b3894-161f-c604-12bc-ecde341d7776@gmail.com>

On Tue, Nov 27, 2018 at 3:48 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>
>
> On 11/27/2018 03:21 PM, Cong Wang wrote:
> > When an ethernet frame is padded to meet the minimum ethernet frame
> > size, the padding octets are not covered by the hardware checksum.
> > Fortunately the padding octets are ususally zero's, which don't affect
> > checksum. However, we have a switch which pads non-zero octets, this
> > causes kernel hardware checksum fault repeatedly.
> >
> > Prior to commit 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"),
> > skb checksum is forced to be CHECKSUM_NONE when padding is detected.
> > After it, we have to keep skb->csum updated, like what we do for FCS.
> >
> > The logic is a bit complicated when dealing with both FCS and padding,
> > so I wrap it up in a helper function mlx5e_csum_padding().
> >
> > I tested this patch with RXFCS on and off, it works fine without any
> > warning in both cases.
> >
> > Fixes: 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"),
> > Cc: Saeed Mahameed <saeedm@mellanox.com>
> > Cc: Eric Dumazet <edumazet@google.com>
> > Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> > ---
> >  .../net/ethernet/mellanox/mlx5/core/en_rx.c   | 36 +++++++++++++++++++
> >  1 file changed, 36 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> > index 16985ca3248d..93c18647ca74 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> > @@ -732,6 +732,35 @@ static u8 get_ip_proto(struct sk_buff *skb, __be16 proto)
> >                                           ((struct ipv6hdr *)ip_p)->nexthdr;
> >  }
> >
> > +static void mlx5e_csum_padding(struct sk_buff *skb, int network_depth,
> > +                            __be16 proto, bool has_fcs)
> > +{
> > +     u32 frame_len = has_fcs ? skb->len - ETH_FCS_LEN : skb->len;
> > +     void *ip_p = skb->data + network_depth;
> > +     u32 pad_offset, pad_len;
> > +     void *pad;
> > +
> > +     if (likely(frame_len > ETH_ZLEN))
> > +             return;
> > +
>
>
> But the padding might be added on normal packets (say 1000 bytes + 3 bytes of padding) ?

I never see other padding cases than ETH_ZLEN. Does ethernet standard
require padding for other cases? I only read the section "3.2.8 Pad field" in
the standard.

>
> The bug here is that mlx5 csum only includes the data in IP frame.
>
> I would simply force skb->ip_summed to CHECKSUM_NONE if any padding is detected.
>
> Otherwise, your patch needs more work when multiple frags are used (ie num_frags > 1 )

You mean using skb_header_pointer()? Yeah if we need to handle cases
larger than ETH_ZLEN.

Thanks.

  reply	other threads:[~2018-11-28 11:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 23:21 [Patch net] mlx5: fixup checksum for ethernet padding Cong Wang
2018-11-27 23:23 ` Cong Wang
2018-11-27 23:48 ` Eric Dumazet
2018-11-28  0:07   ` Cong Wang [this message]
2018-11-28  1:11     ` Saeed Mahameed
2018-11-28  1:38       ` Cong Wang
2018-11-28  1:25     ` Eric Dumazet
2018-11-28  1:42       ` Cong Wang
2018-11-28  1:48         ` Eric Dumazet
2018-11-28  1:52           ` Cong Wang
2018-11-29 21:51 ` kbuild test robot

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='CAM_iQpW2=rTa-QZxK5ygvr=UgM9Lcxr_NyPiD=1jh3Hgovn2gQ@mail.gmail.com' \
    --to=xiyou.wangcong@gmail.com \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.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 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.