summaryrefslogtreecommitdiff
path: root/tools/bpf/bpftool/iter.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bpf/bpftool/iter.c')
-rw-r--r--tools/bpf/bpftool/iter.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/bpf/bpftool/iter.c b/tools/bpf/bpftool/iter.c
index c9dba7543dba..3b1aad7535dd 100644
--- a/tools/bpf/bpftool/iter.c
+++ b/tools/bpf/bpftool/iter.c
@@ -11,6 +11,7 @@
static int do_pin(int argc, char **argv)
{
DECLARE_LIBBPF_OPTS(bpf_iter_attach_opts, iter_opts);
+ union bpf_iter_link_info linfo;
const char *objfile, *path;
struct bpf_program *prog;
struct bpf_object *obj;
@@ -36,6 +37,11 @@ static int do_pin(int argc, char **argv)
map_fd = map_parse_fd(&argc, &argv);
if (map_fd < 0)
return -1;
+
+ memset(&linfo, 0, sizeof(linfo));
+ linfo.map.map_fd = map_fd;
+ iter_opts.link_info = &linfo;
+ iter_opts.link_info_len = sizeof(linfo);
}
}
@@ -57,9 +63,6 @@ static int do_pin(int argc, char **argv)
goto close_obj;
}
- if (map_fd >= 0)
- iter_opts.map_fd = map_fd;
-
link = bpf_program__attach_iter(prog, &iter_opts);
if (IS_ERR(link)) {
err = PTR_ERR(link);