bpf/scripts: Raise an exception if the correct number of helpers are not generated
authorUsama Arif <usama.arif@bytedance.com>
Wed, 12 Jan 2022 11:49:53 +0000 (11:49 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Sat, 15 Jan 2022 00:47:34 +0000 (16:47 -0800)
commit71a3cdf80c0d12aadca6f9b0f5a43883649bdbea
tree0902e079e3c4875f6bf5255d42a56fc30d4e19a1
parent86c7ecad3bf83f6a03057b41b353a44b3a4c1f21
bpf/scripts: Raise an exception if the correct number of helpers are not generated

Currently bpf_helper_defs.h and the bpf helpers man page are auto-generated
using function documentation present in bpf.h. If the documentation for the
helper is missing or doesn't follow a specific format for e.g. if a function
is documented as:
 * long bpf_kallsyms_lookup_name( const char *name, int name_sz, int flags, u64 *res )
instead of
 * long bpf_kallsyms_lookup_name(const char *name, int name_sz, int flags, u64 *res)
(notice the extra space at the start and end of function arguments)
then that helper is not dumped in the auto-generated header and results in
an invalid call during eBPF runtime, even if all the code specific to the
helper is correct.

This patch checks the number of functions documented within the header file
with those present as part of #define __BPF_FUNC_MAPPER and raises an
Exception if they don't match. It is not needed with the currently documented
upstream functions, but can help in debugging when developing new helpers
when there might be missing or misformatted documentation.

Signed-off-by: Usama Arif <usama.arif@bytedance.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20220112114953.722380-1-usama.arif@bytedance.com
scripts/bpf_doc.py