summaryrefslogtreecommitdiffstats
path: root/tools/bpf
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2022-01-31 23:05:22 +0100
committerDaniel Borkmann <daniel@iogearbox.net>2022-02-01 23:56:18 +0100
commit42d1d53fedc9980e8fed98a5a03762cba7d2e9f6 (patch)
treea1cf1ae164fa3fcea54009b3edce03c0d08b9e01 /tools/bpf
parentMerge branch 'libbpf: deprecate xdp_cpumap, xdp_devmap and classifier sec def... (diff)
downloadlinux-42d1d53fedc9980e8fed98a5a03762cba7d2e9f6.tar.xz
linux-42d1d53fedc9980e8fed98a5a03762cba7d2e9f6.zip
libbpf: Add support for bpf iter in light skeleton.
bpf iterator programs should use bpf_link_create to attach instead of bpf_raw_tracepoint_open like other tracing programs. 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-2-alexei.starovoitov@gmail.com
Diffstat (limited to 'tools/bpf')
-rw-r--r--tools/bpf/bpftool/gen.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index 8f78c27d41f0..8eacfc79ec43 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -384,7 +384,10 @@ static void codegen_attach_detach(struct bpf_object *obj, const char *obj_name)
printf("\tint fd = bpf_raw_tracepoint_open(\"%s\", prog_fd);\n", tp_name);
break;
case BPF_PROG_TYPE_TRACING:
- printf("\tint fd = bpf_raw_tracepoint_open(NULL, prog_fd);\n");
+ if (bpf_program__expected_attach_type(prog) == BPF_TRACE_ITER)
+ printf("\tint fd = bpf_link_create(prog_fd, 0, BPF_TRACE_ITER, NULL);\n");
+ else
+ printf("\tint fd = bpf_raw_tracepoint_open(NULL, prog_fd);\n");
break;
default:
printf("\tint fd = ((void)prog_fd, 0); /* auto-attach not supported */\n");