bpftool: Handle libbpf_probe_prog_type errors
authorMilan Landaverde <milan@mdaverde.com>
Thu, 31 Mar 2022 15:45:55 +0000 (11:45 -0400)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 4 Apr 2022 21:54:44 +0000 (14:54 -0700)
Previously [1], we were using bpf_probe_prog_type which returned a
bool, but the new libbpf_probe_bpf_prog_type can return a negative
error code on failure. This change decides for bpftool to declare
a program type is not available on probe failure.

[1] https://lore.kernel.org/bpf/20220202225916.3313522-3-andrii@kernel.org/

Signed-off-by: Milan Landaverde <milan@mdaverde.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20220331154555.422506-4-milan@mdaverde.com
tools/bpf/bpftool/feature.c

index 290998c82de12ea5fa053c11e2a6724a81166e7e..f041c4a6a1f2b19b86da48e90aec4595c37608cc 100644 (file)
@@ -567,7 +567,7 @@ probe_prog_type(enum bpf_prog_type prog_type, bool *supported_types,
 
                res = probe_prog_type_ifindex(prog_type, ifindex);
        } else {
-               res = libbpf_probe_bpf_prog_type(prog_type, NULL);
+               res = libbpf_probe_bpf_prog_type(prog_type, NULL) > 0;
        }
 
 #ifdef USE_LIBCAP