diff options
author | Alexei Starovoitov | 2022-01-31 14:05:27 -0800 |
---|---|---|
committer | Daniel Borkmann | 2022-02-01 23:56:18 +0100 |
commit | 18ef5dac934a0fb1aeb7d6bee6c81e1fa6bcc598 (patch) | |
tree | 917d310d50878b64988bf87eab8a372a6c97eb86 | |
parent | 79b203926d18cb8c110564d8a09ff646691de9e7 (diff) |
bpf: Open code obj_get_info_by_fd in bpf preload.
Open code obj_get_info_by_fd in bpf preload.
It's the last part of libbpf that preload/iterators were using.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20220131220528.98088-7-alexei.starovoitov@gmail.com
-rw-r--r-- | kernel/bpf/preload/iterators/iterators.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/kernel/bpf/preload/iterators/iterators.c b/kernel/bpf/preload/iterators/iterators.c index 23b74916fb84..4dafe0f4f2b2 100644 --- a/kernel/bpf/preload/iterators/iterators.c +++ b/kernel/bpf/preload/iterators/iterators.c @@ -16,6 +16,22 @@ int to_kernel = -1; int from_kernel = 0; +static int __bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len) +{ + union bpf_attr attr; + int err; + + memset(&attr, 0, sizeof(attr)); + attr.info.bpf_fd = bpf_fd; + attr.info.info_len = *info_len; + attr.info.info = (long) info; + + err = skel_sys_bpf(BPF_OBJ_GET_INFO_BY_FD, &attr, sizeof(attr)); + if (!err) + *info_len = attr.info.info_len; + return err; +} + static int send_link_to_kernel(int link_fd, const char *link_name) { struct bpf_preload_info obj = {}; @@ -23,7 +39,7 @@ static int send_link_to_kernel(int link_fd, const char *link_name) __u32 info_len = sizeof(info); int err; - err = bpf_obj_get_info_by_fd(link_fd, &info, &info_len); + err = __bpf_obj_get_info_by_fd(link_fd, &info, &info_len); if (err) return err; obj.link_id = info.id; |