diff options
author | Andrii Nakryiko <andriin@fb.com> | 2020-07-31 11:28:28 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-08-01 20:38:28 -0700 |
commit | 90806ccc90bbd0150267a97ae4003269597a6a6c (patch) | |
tree | 9a3eb6b6cda28f4689509797816966e648cf84fb /tools/testing/selftests/bpf/testing_helpers.c | |
parent | 2e49527e52486dac910460b1b3f6fce6e21c6b48 (diff) | |
download | lwn-90806ccc90bbd0150267a97ae4003269597a6a6c.tar.gz lwn-90806ccc90bbd0150267a97ae4003269597a6a6c.zip |
selftests/bpf: Add link detach tests for cgroup, netns, and xdp bpf_links
Add bpf_link__detach() testing to selftests for cgroup, netns, and xdp
bpf_links.
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200731182830.286260-4-andriin@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/testing_helpers.c')
-rw-r--r-- | tools/testing/selftests/bpf/testing_helpers.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c index 0af6337a8962..800d503e5cb4 100644 --- a/tools/testing/selftests/bpf/testing_helpers.c +++ b/tools/testing/selftests/bpf/testing_helpers.c @@ -64,3 +64,17 @@ int parse_num_list(const char *s, bool **num_set, int *num_set_len) return 0; } + +__u32 link_info_prog_id(const struct bpf_link *link, struct bpf_link_info *info) +{ + __u32 info_len = sizeof(*info); + int err; + + memset(info, 0, sizeof(*info)); + err = bpf_obj_get_info_by_fd(bpf_link__fd(link), info, &info_len); + if (err) { + printf("failed to get link info: %d\n", -errno); + return 0; + } + return info->prog_id; +} |