From: Stanislav Fomichev <sdf@fomichev.me>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Stanislav Fomichev <sdf@google.com>,
netdev@vger.kernel.org, davem@davemloft.net, ast@kernel.org,
daniel@iogearbox.net
Subject: Re: [PATCH bpf-next 2/3] bpf: add BPF_PROG_TEST_RUN support for flow dissector
Date: Thu, 24 Jan 2019 08:34:19 -0800 [thread overview]
Message-ID: <20190124163419.GD26773@mini-arch> (raw)
In-Reply-To: <20190124035600.ag4d7glkyysiluuu@ast-mbp.dhcp.thefacebook.com>
On 01/23, Alexei Starovoitov wrote:
> On Tue, Jan 22, 2019 at 01:23:14PM -0800, Stanislav Fomichev wrote:
> > The input is packet data, the output is struct bpf_flow_key. This should
> > make it easy to test flow dissector programs without elaborate
> > setup.
> >
> > Signed-off-by: Stanislav Fomichev <sdf@google.com>
> > ---
> > include/linux/bpf.h | 3 ++
> > net/bpf/test_run.c | 75 ++++++++++++++++++++++++++++++++++++++++++++-
> > net/core/filter.c | 1 +
> > 3 files changed, 78 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> > index e734f163bd0b..701ef954a258 100644
> > --- a/include/linux/bpf.h
> > +++ b/include/linux/bpf.h
> > @@ -397,6 +397,9 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
> > union bpf_attr __user *uattr);
> > int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
> > union bpf_attr __user *uattr);
> > +int bpf_prog_test_run_flow_dissector(struct bpf_prog *prog,
> > + const union bpf_attr *kattr,
> > + union bpf_attr __user *uattr);
> >
> > /* an array of programs to be executed under rcu_lock.
> > *
> > diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> > index fa2644d276ef..ecad72885f23 100644
> > --- a/net/bpf/test_run.c
> > +++ b/net/bpf/test_run.c
> > @@ -16,12 +16,26 @@
> > static __always_inline u32 bpf_test_run_one(struct bpf_prog *prog, void *ctx,
> > struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE])
> > {
> > + struct bpf_skb_data_end *cb;
> > + struct sk_buff *skb;
> > u32 ret;
> >
> > preempt_disable();
> > rcu_read_lock();
> > bpf_cgroup_storage_set(storage);
> > - ret = BPF_PROG_RUN(prog, ctx);
> > +
> > + switch (prog->type) {
> > + case BPF_PROG_TYPE_FLOW_DISSECTOR:
> > + skb = (struct sk_buff *)ctx;
> > + cb = (struct bpf_skb_data_end *)skb->cb;
> > + ret = __skb_flow_bpf_dissect(prog, ctx, &flow_keys_dissector,
> > + cb->qdisc_cb.flow_keys);
> > + break;
> > + default:
> > + ret = BPF_PROG_RUN(prog, ctx);
> > + break;
> > + }
>
> What is the benefit of this minimal code reuse?
> It seems to me bpf_test_run_one() gets slower for all,
> since prog type needs to be checked before every prog run.
> The point of bpf_prog_ops->test_run was to avoid this overhead.
> Are you somehow expecting flow_dissector prog using cgroup local storage?
> I don't think that's possible.
Agreed. Initially I didn't want to re-implement the logic of
bpf_test_run. But now that you mention that it's mostly about cgroup local
storage, I think I can do a simple loop inside of
bpf_prog_test_run_flow_dissector. Thanks, will follow up with another
series!
next prev parent reply other threads:[~2019-01-24 16:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-22 21:23 [PATCH bpf-next 0/3] support flow dissector in BPF_PROG_TEST_RUN Stanislav Fomichev
2019-01-22 21:23 ` [PATCH bpf-next 1/3] net/flow_dissector: move bpf case into __skb_flow_bpf_dissect Stanislav Fomichev
2019-01-22 21:23 ` [PATCH bpf-next 2/3] bpf: add BPF_PROG_TEST_RUN support for flow dissector Stanislav Fomichev
2019-01-24 3:57 ` Alexei Starovoitov
2019-01-24 16:34 ` Stanislav Fomichev [this message]
2019-01-22 21:23 ` [PATCH bpf-next 3/3] selftests/bpf: add simple BPF_PROG_TEST_RUN examples " Stanislav Fomichev
-- strict thread matches above, loose matches on Subject: below --
2018-12-03 18:59 [PATCH bpf-next 0/3] support flow dissector in BPF_PROG_TEST_RUN Stanislav Fomichev
2018-12-03 18:59 ` [PATCH bpf-next 2/3] bpf: add BPF_PROG_TEST_RUN support for flow dissector Stanislav Fomichev
2018-12-03 22:28 ` Song Liu
2018-12-03 23:08 ` Stanislav Fomichev
2018-12-04 3:54 ` Stanislav Fomichev
2018-12-04 23:25 ` Song Liu
2018-12-04 23:36 ` Stanislav Fomichev
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=20190124163419.GD26773@mini-arch \
--to=sdf@fomichev.me \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.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.