netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joanne Koong <joannelkoong@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: bpf@vger.kernel.org, andrii@kernel.org, daniel@iogearbox.net,
	ast@kernel.org, kafai@fb.com, kuba@kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 0/3] Add skb + xdp dynptrs
Date: Tue, 23 Aug 2022 11:52:33 -0700	[thread overview]
Message-ID: <CAJnrk1amsYS51deoXTOnWvMKSQNvbCK_JSPaGW=OBZZsEyNVuQ@mail.gmail.com> (raw)
In-Reply-To: <CAP01T74LUHjpnVOtwV1h7ha4Dqz0EU5zjwojz-9gWPCN6Gih0Q@mail.gmail.com>

On Mon, Aug 22, 2022 at 7:32 PM Kumar Kartikeya Dwivedi
<memxor@gmail.com> wrote:
>
> On Tue, 23 Aug 2022 at 02:06, Joanne Koong <joannelkoong@gmail.com> wrote:
> >
> > This patchset is the 2nd in the dynptr series. The 1st can be found here [0].
> >
> > This patchset adds skb and xdp type dynptrs, which have two main benefits for
> > packet parsing:
> >     * allowing operations on sizes that are not statically known at
> >       compile-time (eg variable-sized accesses).
> >     * more ergonomic and less brittle iteration through data (eg does not need
> >       manual if checking for being within bounds of data_end)
> >
>
> Just curious: so would you be adding a dynptr interface for obtaining
> data_meta slices as well in the future? Since the same manual bounds
> checking is needed for data_meta vs data. How would that look in the
> generic dynptr interface of data/read/write this set is trying to fit
> things in?

Oh cool, I didn't realize there is also a data_meta used in packet
parsing - thanks for bringing this up. I think there are 2 options for
how data_meta can be incorporated into the dynptr interface:

1) have a separate api "bpf_dynptr_from_{skb/xdp}_meta. We'll have to
have a function in the verifier that does something similar to
'may_access_direct_pkt_data' but for pkt data meta, since skb progs
can have different access restrictions for data vs. data_meta.

2) ideally, the flags arg would be used to indicate whether the
parsing should be for data_meta. To support this though, I think we'd
need to do access type checking within the helper instead of at the
verifier level. One idea is to pass in the env->ops ptr as a 4th arg
(manually patching it from the verifier) to the helper,  which can be
used to determine if data_meta access is permitted.

In both options, there'll be a new BPF_DYNPTR_{SKB/XDP}_META dynptr
type and data/read/write will be supported for it.

What are your thoughts?

>
>
>
> > When comparing the differences in runtime for packet parsing without dynptrs
> > vs. with dynptrs for the more simple cases, there is no noticeable difference.
> > For the more complex cases where lengths are non-statically known at compile
> > time, there can be a significant speed-up when using dynptrs (eg a 2x speed up
> > for cls redirection). Patch 3 contains more details as well as examples of how
> > to use skb and xdp dynptrs.
> >
> > [0] https://lore.kernel.org/bpf/20220523210712.3641569-1-joannelkoong@gmail.com/
> >
> > --

  reply	other threads:[~2022-08-23 19:49 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22 23:56 [PATCH bpf-next v4 0/3] Add skb + xdp dynptrs Joanne Koong
2022-08-22 23:56 ` [PATCH bpf-next v4 1/3] bpf: Add skb dynptrs Joanne Koong
2022-08-23 23:22   ` kernel test robot
2022-08-23 23:53   ` kernel test robot
2022-08-24 18:27   ` Andrii Nakryiko
2022-08-24 23:25     ` Kumar Kartikeya Dwivedi
2022-08-25 21:02       ` Joanne Koong
2022-08-26  0:18         ` Kumar Kartikeya Dwivedi
2022-08-26 18:44           ` Joanne Koong
2022-08-26 18:51             ` Kumar Kartikeya Dwivedi
2022-08-26 19:49               ` Joanne Koong
2022-08-26 20:54                 ` Kumar Kartikeya Dwivedi
2022-08-27  5:36                   ` Andrii Nakryiko
2022-08-27  7:11                     ` Kumar Kartikeya Dwivedi
2022-08-27 17:21                       ` Andrii Nakryiko
2022-08-27 18:32                         ` Kumar Kartikeya Dwivedi
2022-08-27 19:16                           ` Kumar Kartikeya Dwivedi
2022-08-27 23:03                           ` Andrii Nakryiko
2022-08-27 23:47                             ` Kumar Kartikeya Dwivedi
2022-08-22 23:56 ` [PATCH bpf-next v4 2/3] bpf: Add xdp dynptrs Joanne Koong
2022-08-23  2:30   ` Kumar Kartikeya Dwivedi
2022-08-23 22:26     ` Joanne Koong
2022-08-24 10:39       ` Toke Høiland-Jørgensen
2022-08-24 18:10         ` Joanne Koong
2022-08-24 23:04           ` Kumar Kartikeya Dwivedi
2022-08-25 20:14             ` Joanne Koong
2022-08-25 21:53             ` Andrii Nakryiko
2022-08-26  6:37             ` Martin KaFai Lau
2022-08-26  6:50               ` Martin KaFai Lau
2022-08-26 19:09               ` Kumar Kartikeya Dwivedi
2022-08-26 20:47                 ` Joanne Koong
2022-08-24 21:10       ` Kumar Kartikeya Dwivedi
2022-08-25 20:39         ` Joanne Koong
2022-08-25 23:18           ` Kumar Kartikeya Dwivedi
2022-08-26 18:23             ` Joanne Koong
2022-08-26 18:31               ` Kumar Kartikeya Dwivedi
2022-08-24  1:15   ` kernel test robot
2022-08-22 23:56 ` [PATCH bpf-next v4 3/3] selftests/bpf: tests for using dynptrs to parse skb and xdp buffers Joanne Koong
2022-08-24 18:47   ` Andrii Nakryiko
2022-08-23  2:31 ` [PATCH bpf-next v4 0/3] Add skb + xdp dynptrs Kumar Kartikeya Dwivedi
2022-08-23 18:52   ` Joanne Koong [this message]
2022-08-24 18:01     ` Andrii Nakryiko
2022-08-24 23:18       ` Kumar Kartikeya Dwivedi

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='CAJnrk1amsYS51deoXTOnWvMKSQNvbCK_JSPaGW=OBZZsEyNVuQ@mail.gmail.com' \
    --to=joannelkoong@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=kuba@kernel.org \
    --cc=memxor@gmail.com \
    --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 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).