diff options
author | Joe Burton <jevburton@google.com> | 2022-07-29 20:27:27 +0000 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-07-29 15:30:06 -0700 |
commit | 395fc4fa33e98944384d0d6c8b3ecd9fb4b50d00 (patch) | |
tree | ca8f08c202735460a66276f9f461a3352689a1ae /tools/lib/bpf/bpf.h | |
parent | netdevsim: Avoid allocation warnings triggered from user space (diff) | |
download | linux-dev-395fc4fa33e98944384d0d6c8b3ecd9fb4b50d00.tar.xz linux-dev-395fc4fa33e98944384d0d6c8b3ecd9fb4b50d00.zip |
libbpf: Add bpf_obj_get_opts()
Add an extensible variant of bpf_obj_get() capable of setting the
`file_flags` parameter.
This parameter is needed to enable unprivileged access to BPF maps.
Without a method like this, users must manually make the syscall.
Signed-off-by: Joe Burton <jevburton@google.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220729202727.3311806-1-jevburton.kernel@gmail.com
Diffstat (limited to 'tools/lib/bpf/bpf.h')
-rw-r--r-- | tools/lib/bpf/bpf.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 88a7cc4bd76f..9c50beabdd14 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h @@ -270,8 +270,19 @@ LIBBPF_API int bpf_map_update_batch(int fd, const void *keys, const void *values __u32 *count, const struct bpf_map_batch_opts *opts); +struct bpf_obj_get_opts { + size_t sz; /* size of this struct for forward/backward compatibility */ + + __u32 file_flags; + + size_t :0; +}; +#define bpf_obj_get_opts__last_field file_flags + LIBBPF_API int bpf_obj_pin(int fd, const char *pathname); LIBBPF_API int bpf_obj_get(const char *pathname); +LIBBPF_API int bpf_obj_get_opts(const char *pathname, + const struct bpf_obj_get_opts *opts); struct bpf_prog_attach_opts { size_t sz; /* size of this struct for forward/backward compatibility */ |