mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-15 06:55:13 +08:00
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 <milan@mdaverde.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220504161356.3497972-3-milan@mdaverde.com
This commit is contained in:
parent
6d9f63b9df
commit
b06a92a18d
@ -690,7 +690,7 @@ probe_helper_ifindex(enum bpf_func_id id, enum bpf_prog_type prog_type,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
probe_helper_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
|
probe_helper_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
|
||||||
const char *define_prefix, unsigned int id,
|
const char *define_prefix, unsigned int id,
|
||||||
const char *ptype_name, __u32 ifindex)
|
const char *ptype_name, __u32 ifindex)
|
||||||
@ -723,6 +723,8 @@ probe_helper_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
|
|||||||
if (res)
|
if (res)
|
||||||
printf("\n\t- %s", helper_name[id]);
|
printf("\n\t- %s", helper_name[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -732,6 +734,7 @@ probe_helpers_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
|
|||||||
const char *ptype_name = prog_type_name[prog_type];
|
const char *ptype_name = prog_type_name[prog_type];
|
||||||
char feat_name[128];
|
char feat_name[128];
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
|
bool probe_res = false;
|
||||||
|
|
||||||
if (ifindex)
|
if (ifindex)
|
||||||
/* Only test helpers for offload-able program types */
|
/* Only test helpers for offload-able program types */
|
||||||
@ -764,7 +767,7 @@ probe_helpers_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
|
|||||||
continue;
|
continue;
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
probe_helper_for_progtype(prog_type, supported_type,
|
probe_res |= probe_helper_for_progtype(prog_type, supported_type,
|
||||||
define_prefix, id, ptype_name,
|
define_prefix, id, ptype_name,
|
||||||
ifindex);
|
ifindex);
|
||||||
}
|
}
|
||||||
@ -772,8 +775,17 @@ probe_helpers_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
|
|||||||
|
|
||||||
if (json_output)
|
if (json_output)
|
||||||
jsonw_end_array(json_wtr);
|
jsonw_end_array(json_wtr);
|
||||||
else if (!define_prefix)
|
else if (!define_prefix) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
if (!probe_res) {
|
||||||
|
if (!supported_type)
|
||||||
|
printf("\tProgram type not supported\n");
|
||||||
|
else
|
||||||
|
printf("\tCould not determine which helpers are available\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user