Skip to content

Commit bc551cc

Browse files
mdaverdeKernel Patches Daemon
authored andcommitted
bpftool: output message if no helpers found in feature probing
Currently in libbpf, we have hardcoded program types that are not supported for helper function probing (e.g. tracing, ext, lsm). Due to this (and other legitimate failures), bpftool feature probe returns empty for those program type helper functions. Instead of implying to the user that there are no helper functions available for a program type, we output a message to the user explaining that helper function probing failed for that program type. Signed-off-by: Milan Landaverde <[email protected]>
1 parent 8398c37 commit bc551cc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tools/bpf/bpftool/feature.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ probe_helper_ifindex(enum bpf_func_id id, enum bpf_prog_type prog_type,
690690
return res;
691691
}
692692

693-
static void
693+
static bool
694694
probe_helper_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
695695
const char *define_prefix, unsigned int id,
696696
const char *ptype_name, __u32 ifindex)
@@ -723,6 +723,8 @@ probe_helper_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
723723
if (res)
724724
printf("\n\t- %s", helper_name[id]);
725725
}
726+
727+
return res;
726728
}
727729

728730
static void
@@ -732,6 +734,7 @@ probe_helpers_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
732734
const char *ptype_name = prog_type_name[prog_type];
733735
char feat_name[128];
734736
unsigned int id;
737+
bool probe_res = false;
735738

736739
if (ifindex)
737740
/* Only test helpers for offload-able program types */
@@ -764,16 +767,25 @@ probe_helpers_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
764767
continue;
765768
/* fallthrough */
766769
default:
767-
probe_helper_for_progtype(prog_type, supported_type,
770+
probe_res |= probe_helper_for_progtype(prog_type, supported_type,
768771
define_prefix, id, ptype_name,
769772
ifindex);
770773
}
771774
}
772775

773776
if (json_output)
774777
jsonw_end_array(json_wtr);
775-
else if (!define_prefix)
778+
else if (!define_prefix) {
776779
printf("\n");
780+
if (!probe_res) {
781+
if (!supported_type)
782+
printf("\tProgram type not supported\n");
783+
else
784+
printf("\tCould not determine which helpers are available\n");
785+
}
786+
}
787+
788+
777789
}
778790

779791
static void

0 commit comments

Comments
 (0)