summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/test_socket_cookie.c
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2018-09-27 21:15:00 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2018-09-27 21:19:34 +0200
commit78e6e5c11acef7dae81d7f0e919ad5563a611a6a (patch)
treee906592468b388ae703879244a33a80259e0c4b1 /tools/testing/selftests/bpf/test_socket_cookie.c
parent100811936f89fd455eda1984810c09003550555b (diff)
parent370920c47b26ae3a837f7c46f0795804ae2940f7 (diff)
downloadlinux-78e6e5c11acef7dae81d7f0e919ad5563a611a6a.tar.bz2
Merge branch 'bpf-libbpf-attach-by-name'
Andrey Ignatov says: ==================== This patch set introduces libbpf_attach_type_by_name function in libbpf to identify attach type by section name. This is useful to avoid writing same logic over and over again in user space applications that leverage libbpf. Patch 1 has more details on the new function and problem being solved. Patches 2 and 3 add support for new section names. Patch 4 uses new function in a selftest. Patch 5 adds selftest for libbpf_{prog,attach}_type_by_name. As a side note there are a lot of inconsistencies now between names used by libbpf and bpftool (e.g. cgroup/skb vs cgroup_skb, cgroup_device and device vs cgroup/dev, sockops vs sock_ops, etc). This patch set does not address it but it tries not to make it harder to address it in the future. ==================== Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/test_socket_cookie.c')
-rw-r--r--tools/testing/selftests/bpf/test_socket_cookie.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/tools/testing/selftests/bpf/test_socket_cookie.c b/tools/testing/selftests/bpf/test_socket_cookie.c
index 68e108e4687a..b6c2c605d8c0 100644
--- a/tools/testing/selftests/bpf/test_socket_cookie.c
+++ b/tools/testing/selftests/bpf/test_socket_cookie.c
@@ -158,11 +158,7 @@ static int run_test(int cgfd)
bpf_object__for_each_program(prog, pobj) {
prog_name = bpf_program__title(prog, /*needs_copy*/ false);
- if (strcmp(prog_name, "cgroup/connect6") == 0) {
- attach_type = BPF_CGROUP_INET6_CONNECT;
- } else if (strcmp(prog_name, "sockops") == 0) {
- attach_type = BPF_CGROUP_SOCK_OPS;
- } else {
+ if (libbpf_attach_type_by_name(prog_name, &attach_type)) {
log_err("Unexpected prog: %s", prog_name);
goto err;
}