From: Quentin Monnet <quentin@isovalent.com>
To: Usama Arif <usama.arif@bytedance.com>, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, joe@cilium.io,
fam.zheng@bytedance.com, cong.wang@bytedance.com,
alexei.starovoitov@gmail.com, song@kernel.org
Subject: Re: [PATCH v6] bpf/scripts: raise an exception if the correct number of helpers are not generated
Date: Wed, 12 Jan 2022 12:15:53 +0000 [thread overview]
Message-ID: <6586be41-1ceb-c9d3-f9ea-567f51dbab49@isovalent.com> (raw)
In-Reply-To: <20220112114953.722380-1-usama.arif@bytedance.com>
2022-01-12 11:49 UTC+0000 ~ Usama Arif <usama.arif@bytedance.com>
> 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>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Looks cleaner with the check in a dedicated function. Thanks a lot!
> ---
> scripts/bpf_doc.py | 50 ++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 48 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/bpf_doc.py b/scripts/bpf_doc.py
> index a6403ddf5de7..76c96df095e3 100755
> --- a/scripts/bpf_doc.py
> +++ b/scripts/bpf_doc.py
> @@ -295,6 +320,25 @@ class PrinterRST(Printer):
>
> print('')
>
> +def helper_number_check(desc_unique_helpers, define_unique_helpers):
> + """
> + Checks the number of functions documented within the header file
> + with those present as part of #define __BPF_FUNC_MAPPER and raise an
> + Exception if they don't match.
> + """
> + nr_desc_unique_helpers = len(desc_unique_helpers)
> + nr_define_unique_helpers = len(define_unique_helpers)
> + if nr_desc_unique_helpers != nr_define_unique_helpers:
> + helper_exception = '''
> +The number of unique helpers in description (%d) don\'t match the number of unique helpers defined in __BPF_FUNC_MAPPER (%d)
Nit: don't -> doesn't
(but probably not worth a respin)
next prev parent reply other threads:[~2022-01-12 12:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 11:49 [PATCH v6] bpf/scripts: raise an exception if the correct number of helpers are not generated Usama Arif
2022-01-12 12:15 ` Quentin Monnet [this message]
2022-01-12 18:15 ` Song Liu
2022-01-15 0:48 ` Andrii Nakryiko
2022-01-17 14:35 ` Quentin Monnet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6586be41-1ceb-c9d3-f9ea-567f51dbab49@isovalent.com \
--to=quentin@isovalent.com \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=daniel@iogearbox.net \
--cc=fam.zheng@bytedance.com \
--cc=joe@cilium.io \
--cc=song@kernel.org \
--cc=usama.arif@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).