From: Roberto Sassu <roberto.sassu@huawei.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Stanislav Fomichev <sdf@google.com>
Cc: Quentin Monnet <quentin@isovalent.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Joe Burton <jevburton.kernel@gmail.com>,
bpf <bpf@vger.kernel.org>
Subject: RE: [RFC][PATCH v3 07/15] libbpf: Introduce bpf_obj_get_opts()
Date: Mon, 25 Jul 2022 07:18:33 +0000 [thread overview]
Message-ID: <0af18af66d7c4efb866d0bbf2057caf1@huawei.com> (raw)
In-Reply-To: <CAADnVQ+9xYy+tAiTrQudS+gTo-VxqUs4y576-DNCbPKASv9RXg@mail.gmail.com>
> From: Alexei Starovoitov [mailto:alexei.starovoitov@gmail.com]
> Sent: Friday, July 22, 2022 8:02 PM
> On Fri, Jul 22, 2022 at 10:58 AM Stanislav Fomichev <sdf@google.com> wrote:
> >
> > On Fri, Jul 22, 2022 at 10:20 AM Roberto Sassu <roberto.sassu@huawei.com>
> wrote:
> > >
> > > Introduce bpf_obj_get_opts(), to let the caller pass the needed permissions
> > > for the operation. Keep the existing bpf_obj_get() to request read-write
> > > permissions.
> > >
> > > bpf_obj_get() allows the caller to get a file descriptor from a pinned
> > > object with the provided pathname. Specifying permissions has only effect
> > > on maps (for links, the permission must be always read-write).
> > >
> > > Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
> > > ---
> > > tools/lib/bpf/bpf.c | 12 +++++++++++-
> > > tools/lib/bpf/bpf.h | 2 ++
> > > tools/lib/bpf/libbpf.map | 1 +
> > > 3 files changed, 14 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> > > index 5f2785a4c358..0df088890864 100644
> > > --- a/tools/lib/bpf/bpf.c
> > > +++ b/tools/lib/bpf/bpf.c
> > > @@ -577,18 +577,28 @@ int bpf_obj_pin(int fd, const char *pathname)
> > > return libbpf_err_errno(ret);
> > > }
> > >
> > > -int bpf_obj_get(const char *pathname)
> > > +int bpf_obj_get_opts(const char *pathname,
> > > + const struct bpf_get_fd_opts *opts)
> >
> > I'm still not sure whether it's a good idea to mix get_fd with
> > obj_get/pin operations? [1] seems more clear.
>
> +1
I think so. Both types of functions are accessing the same object,
just in a different way: one by ID, and another by path.
Consider the case I mentioned, map_parse_fds() in bpftool. It calls
both type of functions. What opts a caller of this function should
provide, if they are different?
> > It just so happens that (differently named) flags in BPF_OBJ_GET and
> > BPF_XXX_GET_FD_BY_ID align, but maybe we shouldn't depend on it?
> >
> > Also, it seems only bpf_map_get_fd_by_id currently accepts flags? So
> > this sharing makes even more sense?
As I mentioned in another email, Andrii requested me in v2 to add
opts to all bpf_*_get_fd_by_id() functions.
> +1
>
> Roberto, the patch set is broken in many ways.
Could you please explain?
Thanks
Roberto
next prev parent reply other threads:[~2022-07-25 7:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 17:18 [RFC][PATCH v3 00/15] bpf: Per-operation map permissions Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 01/15] bpftool: Attempt to link static libraries Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 02/15] bpf: Set open_flags as last bpf_attr field for bpf_*_get_fd_by_id() funcs Roberto Sassu
2022-07-22 17:55 ` Alexei Starovoitov
2022-07-25 7:10 ` Roberto Sassu
2022-07-29 18:49 ` Andrii Nakryiko
2022-08-01 10:33 ` Roberto Sassu
2022-08-25 12:21 ` Roberto Sassu
2022-08-25 22:06 ` Andrii Nakryiko
2022-07-22 17:18 ` [RFC][PATCH v3 03/15] libbpf: Introduce bpf_prog_get_fd_by_id_opts() Roberto Sassu
2022-07-29 18:51 ` Andrii Nakryiko
2022-07-22 17:18 ` [RFC][PATCH v3 04/15] libbpf: Introduce bpf_map_get_fd_by_id_opts() Roberto Sassu
2022-07-29 18:52 ` Andrii Nakryiko
2022-07-22 17:18 ` [RFC][PATCH v3 05/15] libbpf: Introduce bpf_btf_get_fd_by_id_opts() Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 06/15] libbpf: Introduce bpf_link_get_fd_by_id_opts() Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 07/15] libbpf: Introduce bpf_obj_get_opts() Roberto Sassu
2022-07-22 17:58 ` Stanislav Fomichev
2022-07-22 18:01 ` Alexei Starovoitov
2022-07-25 7:18 ` Roberto Sassu [this message]
2022-07-22 17:18 ` [RFC][PATCH v3 08/15] bpftool: Add opts parameter to open_obj_pinned_any() and open_obj_pinned() Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 09/15] bpftool: Add opts parameter to *_parse_fd() functions Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 10/15] bpftool: Add opts parameter to *_parse_fds() Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 11/15] bpftool: Add opts parameter to map_parse_fd_and_info() Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 12/15] bpftool: Add opts parameter in struct_ops functions Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 13/15] bpftool: Complete switch to bpf_*_get_fd_by_id_opts() Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 14/15] bpftool: Adjust map permissions Roberto Sassu
2022-07-22 17:18 ` [RFC][PATCH v3 15/15] selftests/bpf: Add map access tests Roberto Sassu
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=0af18af66d7c4efb866d0bbf2057caf1@huawei.com \
--to=roberto.sassu@huawei.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jevburton.kernel@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=quentin@isovalent.com \
--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