diff options
| author | Ihor Solodrai <[email protected]> | 2024-09-13 00:19:02 +0000 |
|---|---|---|
| committer | Andrii Nakryiko <[email protected]> | 2024-09-13 02:07:13 +0000 |
| commit | ea02a946873ba6709080e9db7b22449f1ac69fd4 (patch) | |
| tree | 53e317721866b200e9342ba701ee8dde1f802299 /tools/lib/bpf/libbpf.c | |
| parent | docs/bpf: Add missing BPF program types to docs (diff) | |
| download | kernel-ea02a946873ba6709080e9db7b22449f1ac69fd4.tar.gz kernel-ea02a946873ba6709080e9db7b22449f1ac69fd4.zip | |
libbpf: Add bpf_object__token_fd accessor
Add a LIBBPF_API function to retrieve the token_fd from a bpf_object.
Without this accessor, if user needs a token FD they have to get it
manually via bpf_token_create, even though a token might have been
already created by bpf_object__load.
Suggested-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Ihor Solodrai <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 84d4ec0e1f60..219facd0e66e 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -9059,6 +9059,11 @@ unsigned int bpf_object__kversion(const struct bpf_object *obj) return obj ? obj->kern_version : 0; } +int bpf_object__token_fd(const struct bpf_object *obj) +{ + return obj->token_fd ?: -1; +} + struct btf *bpf_object__btf(const struct bpf_object *obj) { return obj ? obj->btf : NULL; |
