diff options
author | Alexei Starovoitov <ast@fb.com> | 2017-10-03 07:50:27 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-05 01:05:05 +0200 |
commit | 5d0cbf9b6c11964bf2f4041a5b0b6f81cb169736 (patch) | |
tree | 88888ccb66f2d05cba46fc8a7d2ce18aa18a722d /tools/lib/bpf/bpf.c | |
parent | libbpf: sync bpf.h (diff) | |
download | linux-5d0cbf9b6c11964bf2f4041a5b0b6f81cb169736.tar.xz linux-5d0cbf9b6c11964bf2f4041a5b0b6f81cb169736.zip |
libbpf: add support for BPF_PROG_QUERY
add support for BPF_PROG_QUERY command to libbpf
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/lib/bpf/bpf.c')
-rw-r--r-- | tools/lib/bpf/bpf.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index d4b6ba8292ee..5128677e4117 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -303,6 +303,26 @@ int bpf_prog_detach2(int prog_fd, int target_fd, enum bpf_attach_type type) return sys_bpf(BPF_PROG_DETACH, &attr, sizeof(attr)); } +int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, + __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt) +{ + union bpf_attr attr; + int ret; + + bzero(&attr, sizeof(attr)); + attr.query.target_fd = target_fd; + attr.query.attach_type = type; + attr.query.query_flags = query_flags; + attr.query.prog_cnt = *prog_cnt; + attr.query.prog_ids = ptr_to_u64(prog_ids); + + ret = sys_bpf(BPF_PROG_QUERY, &attr, sizeof(attr)); + if (attach_flags) + *attach_flags = attr.query.attach_flags; + *prog_cnt = attr.query.prog_cnt; + return ret; +} + int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size, void *data_out, __u32 *size_out, __u32 *retval, __u32 *duration) |