diff options
author | Alexei Starovoitov <ast@fb.com> | 2017-10-03 01:50:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-04 19:05:05 -0400 |
commit | 5d0cbf9b6c11964bf2f4041a5b0b6f81cb169736 (patch) | |
tree | 88888ccb66f2d05cba46fc8a7d2ce18aa18a722d /tools/lib/bpf | |
parent | defd9c476fa6b01b4eb5450452bfd202138decb7 (diff) |
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')
-rw-r--r-- | tools/lib/bpf/bpf.c | 20 | ||||
-rw-r--r-- | tools/lib/bpf/bpf.h | 3 |
2 files changed, 22 insertions, 1 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) | |||
303 | return sys_bpf(BPF_PROG_DETACH, &attr, sizeof(attr)); | 303 | return sys_bpf(BPF_PROG_DETACH, &attr, sizeof(attr)); |
304 | } | 304 | } |
305 | 305 | ||
306 | int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, | ||
307 | __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt) | ||
308 | { | ||
309 | union bpf_attr attr; | ||
310 | int ret; | ||
311 | |||
312 | bzero(&attr, sizeof(attr)); | ||
313 | attr.query.target_fd = target_fd; | ||
314 | attr.query.attach_type = type; | ||
315 | attr.query.query_flags = query_flags; | ||
316 | attr.query.prog_cnt = *prog_cnt; | ||
317 | attr.query.prog_ids = ptr_to_u64(prog_ids); | ||
318 | |||
319 | ret = sys_bpf(BPF_PROG_QUERY, &attr, sizeof(attr)); | ||
320 | if (attach_flags) | ||
321 | *attach_flags = attr.query.attach_flags; | ||
322 | *prog_cnt = attr.query.prog_cnt; | ||
323 | return ret; | ||
324 | } | ||
325 | |||
306 | int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size, | 326 | int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size, |
307 | void *data_out, __u32 *size_out, __u32 *retval, | 327 | void *data_out, __u32 *size_out, __u32 *retval, |
308 | __u32 *duration) | 328 | __u32 *duration) |
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index afd64727c9cf..6534889e2b2f 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h | |||
@@ -75,5 +75,6 @@ int bpf_map_get_next_id(__u32 start_id, __u32 *next_id); | |||
75 | int bpf_prog_get_fd_by_id(__u32 id); | 75 | int bpf_prog_get_fd_by_id(__u32 id); |
76 | int bpf_map_get_fd_by_id(__u32 id); | 76 | int bpf_map_get_fd_by_id(__u32 id); |
77 | int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len); | 77 | int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len); |
78 | 78 | int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, | |
79 | __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt); | ||
79 | #endif | 80 | #endif |