From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii@kernel.org>,
bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
martin.lau@kernel.org
Cc: tj@kernel.org, void@manifault.com
Subject: Re: [PATCH bpf-next 2/3] bpf: allow passing struct bpf_iter_<type> as kfunc arguments
Date: Fri, 09 Aug 2024 12:14:27 -0700 [thread overview]
Message-ID: <2689ece2c10e234a2326ad4406439ad7c8d35a03.camel@gmail.com> (raw)
In-Reply-To: <20240808232230.2848712-3-andrii@kernel.org>
On Thu, 2024-08-08 at 16:22 -0700, Andrii Nakryiko wrote:
> There are potentially useful cases where a specific iterator type might
> need to be passed into some kfunc. So, in addition to existing
> bpf_iter_<type>_{new,next,destroy}() kfuncs, allow to pass iterator
> pointer to any kfunc.
>
> We employ "__iter" naming suffix for arguments that are meant to accept
> iterators. We also enforce that they accept PTR -> STRUCT btf_iter_<type>
> type chain and point to a valid initialized on-the-stack iterator state.
>
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> ---
In current form this allows the following usage:
SEC("?socket")
__success
int testmod_seq_getter_good(const void *ctx)
{
struct bpf_iter_testmod_seq it;
s64 sum = 0;
bpf_iter_testmod_seq_new(&it, 100, 100);
sum *= bpf_iter_testmod_seq_value(0, &it);
bpf_iter_testmod_seq_destroy(&it);
return sum;
}
Do we want to ensure that iterator is not drained before the call to
bpf_iter_testmod_seq_value()?
Otherwise this patch lgtm.
[...]
next prev parent reply other threads:[~2024-08-09 19:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 23:22 [PATCH bpf-next 0/3] Support passing BPF iterator to kfuncs Andrii Nakryiko
2024-08-08 23:22 ` [PATCH bpf-next 1/3] bpf: extract iterator argument type and name validation logic Andrii Nakryiko
2024-08-09 18:38 ` Eduard Zingerman
2024-08-08 23:22 ` [PATCH bpf-next 2/3] bpf: allow passing struct bpf_iter_<type> as kfunc arguments Andrii Nakryiko
2024-08-09 19:14 ` Eduard Zingerman [this message]
2024-08-09 19:28 ` Andrii Nakryiko
2024-08-09 19:40 ` Eduard Zingerman
2024-08-09 20:36 ` Andrii Nakryiko
2024-08-08 23:22 ` [PATCH bpf-next 3/3] selftests/bpf: test passing iterator to a kfunc Andrii Nakryiko
2024-08-21 17:50 ` [PATCH bpf-next 0/3] Support passing BPF iterator to kfuncs 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=2689ece2c10e234a2326ad4406439ad7c8d35a03.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=martin.lau@kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.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