From: Pavel Begunkov <asml.silence@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>, Alexei Starovoitov <ast@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] cgroup/bpf: fast path skb BPF filtering
Date: Wed, 15 Dec 2021 17:38:11 +0000 [thread overview]
Message-ID: <6406f753-180a-7896-6df2-c187cb0e975f@gmail.com> (raw)
In-Reply-To: <20211215084044.064e6861@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
On 12/15/21 16:40, Jakub Kicinski wrote:
> On Wed, 15 Dec 2021 14:49:18 +0000 Pavel Begunkov wrote:
>> +static inline bool
>> +__cgroup_bpf_prog_array_is_empty(struct cgroup_bpf *cgrp_bpf,
>> + enum cgroup_bpf_attach_type type)
>> +{
>> + struct bpf_prog_array *array = rcu_access_pointer(cgrp_bpf->effective[type]);
>> +
>> + return array == &bpf_empty_prog_array.hdr;
>> +}
>> +
>> +#define CGROUP_BPF_TYPE_ENABLED(sk, atype) \
>> +({ \
>> + struct cgroup *__cgrp = sock_cgroup_ptr(&(sk)->sk_cgrp_data); \
>> + \
>> + !__cgroup_bpf_prog_array_is_empty(&__cgrp->bpf, (atype)); \
>> +})
>> +
>
>> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
>> index e7a163a3146b..0d2195c6fb2a 100644
>> --- a/include/linux/bpf.h
>> +++ b/include/linux/bpf.h
>> @@ -1161,6 +1161,19 @@ struct bpf_prog_array {
>> struct bpf_prog_array_item items[];
>> };
>>
>> +struct bpf_empty_prog_array {
>> + struct bpf_prog_array hdr;
>> + struct bpf_prog *null_prog;
>> +};
>> +
>> +/* to avoid allocating empty bpf_prog_array for cgroups that
>> + * don't have bpf program attached use one global 'bpf_empty_prog_array'
>> + * It will not be modified the caller of bpf_prog_array_alloc()
>> + * (since caller requested prog_cnt == 0)
>> + * that pointer should be 'freed' by bpf_prog_array_free()
>> + */
>> +extern struct bpf_empty_prog_array bpf_empty_prog_array;
>
> mumble mumble, this adds more "fun" dependencies [1] Maybe I'm going
Header dependencies? It's declared right after struct bpf_prog_array,
and the other member is a pointer, so not sure what can go wrong.
> about this all wrong, maybe I should be pulling out struct cgroup_bpf
> so that cgroup.h does not need bpf-cgroup, not breaking bpf <-> bpf-cgroup.
> Alexei, WDYT?
>
> [1] https://lore.kernel.org/all/20211215061916.715513-2-kuba@kernel.org/
>
--
Pavel Begunkov
next prev parent reply other threads:[~2021-12-15 17:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-15 14:49 [PATCH v3] cgroup/bpf: fast path skb BPF filtering Pavel Begunkov
2021-12-15 16:40 ` Jakub Kicinski
2021-12-15 17:38 ` Pavel Begunkov [this message]
2021-12-15 16:51 ` sdf
2021-12-15 17:18 ` Pavel Begunkov
2021-12-15 17:33 ` sdf
2021-12-15 17:53 ` Pavel Begunkov
2021-12-15 18:24 ` sdf
2021-12-15 18:54 ` Pavel Begunkov
2021-12-15 19:15 ` Stanislav Fomichev
2021-12-15 19:55 ` Pavel Begunkov
2021-12-15 22:07 ` Stanislav Fomichev
2021-12-16 13:21 ` Pavel Begunkov
2021-12-16 18:14 ` Martin KaFai Lau
2021-12-16 18:24 ` Stanislav Fomichev
2022-01-24 15:46 ` Pavel Begunkov
2022-01-24 18:25 ` Stanislav Fomichev
2022-01-25 18:54 ` Pavel Begunkov
2022-01-25 21:27 ` 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=6406f753-180a-7896-6df2-c187cb0e975f@gmail.com \
--to=asml.silence@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=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.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 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).