netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Stanislav Fomichev <sdf@google.com>
Cc: daniel@iogearbox.net, bpf@vger.kernel.org,
	netdev@vger.kernel.org, Anand Parthasarathy <anpartha@meta.com>,
	martin.lau@linux.dev, song@kernel.org, john.fastabend@gmail.com
Subject: Re: [PATCH bpf 1/2] bpf: pull before calling skb_postpull_rcsum()
Date: Mon, 19 Dec 2022 17:45:05 -0800	[thread overview]
Message-ID: <20221219174505.67014ea5@kernel.org> (raw)
In-Reply-To: <CAKH8qBvVTHXsgVLHuCmdFM1dnYEiDFovOFfXNq1=8igPCCO7jQ@mail.gmail.com>

On Mon, 19 Dec 2022 17:21:27 -0800 Stanislav Fomichev wrote:
> > -       skb_postpull_rcsum(skb, skb->data + off, len);
> > -       memmove(skb->data + len, skb->data, off);
> > +       old_data = skb->data;
> >         __skb_pull(skb, len);  
> 
> [..]

Very counter-productively trimmed ;)

> > +       skb_postpull_rcsum(skb, old_data + off, len);  
> 
> Are you sure about the 'old_data + off' part here (for
> CHECKSUM_COMPLETE)? Shouldn't it be old_data?

AFAIU before:

      old_data (aka skb->data before)
     /
    / off  len 
   V-----><--->
[ .=======xxxxx... buffer ...... ]
          ^
           \
            the xxx part is what we delete

after:
          skb->data (after)
         /
        v
[ .yyyyy=======... buffer ...... ]
   <---><----->
    len   off  
   ^
    \
     the yyy part is technically the old values of === but now "outside"
     of the valid packet data

> I'm assuming we need to negate the old parts that we've pulled?

Yes.

> Maybe safer/more correct to do the following?
> 
> skb_pull_rcsum(skb, off);

This just pulls from the front, we need to skip over various L2/L3
headers thanks to off. Hopefully the diagrams help, LMK if they are
wrong.

> memmove(skb->data, skb->data-off, off);

  reply	other threads:[~2022-12-20  1:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20  0:47 [PATCH bpf 1/2] bpf: pull before calling skb_postpull_rcsum() Jakub Kicinski
2022-12-20  0:47 ` [PATCH bpf 2/2] selftests/bpf: tunnel: add sanity test for checksums Jakub Kicinski
2022-12-20 23:13   ` [PATCH bpf] selftests/bpf: Test bpf_skb_adjust_room on CHECKSUM_PARTIAL Martin KaFai Lau
2022-12-20 23:21   ` [PATCH bpf 2/2] selftests/bpf: tunnel: add sanity test for checksums Martin KaFai Lau
2022-12-20 23:36     ` Jakub Kicinski
2022-12-20  1:21 ` [PATCH bpf 1/2] bpf: pull before calling skb_postpull_rcsum() Stanislav Fomichev
2022-12-20  1:45   ` Jakub Kicinski [this message]
2022-12-20  1:55     ` Stanislav Fomichev
2022-12-21  0:20 ` patchwork-bot+netdevbpf

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=20221219174505.67014ea5@kernel.org \
    --to=kuba@kernel.org \
    --cc=anpartha@meta.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=song@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 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).