Instead of inferring whether map already point to previously created/pinned BPF map (which user can specify through bpf_map__reuse_fd() or bpf_object__reuse_map() APIs), use explicit map->reused flag that is set in such case. Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> --- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index e4fe79d5693f..2ead8fc1e344 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -5463,7 +5463,7 @@ bpf_object__create_maps(struct bpf_object *obj) } } - if (map->fd >= 0) { + if (map->reused) { pr_debug("map '%s': skipping creation (preset fd=%d)\n", map->name, map->fd); } else { -- 2.34.1