On Fri, Jul 22, 2022 at 10:58 AM Stanislav Fomichev <sdf@xxxxxxxxxx> wrote: > > On Fri, Jul 22, 2022 at 10:20 AM Roberto Sassu <roberto.sassu@xxxxxxxxxx> 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@xxxxxxxxxx> > > --- > > 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 > 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? +1 Roberto, the patch set is broken in many ways.