Re: [PATCH bpf-next 3/6] libbpf: Add feature for kernel extended vlen/kind support

Alexei Starovoitov
2026-04-15T01:56:25Z

On Tue, Apr 14, 2026 at 12:50 PM Alan Maguire <alan.maguire@oracle.com> wrote:
>
> Add feature check for kernel extended vlen/kind support, and reject
> BTF that uses extended vlens/kinds if the kernel does not support
> it. There is no reasonable path to generally sanitize such BTF.
>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---
> tools/lib/bpf/features.c | 39 +++++++++++++++++++++++++++++++++
> tools/lib/bpf/libbpf.c | 17 +++++++++++++-
> tools/lib/bpf/libbpf_internal.h | 2 ++
> 3 files changed, 57 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/features.c b/tools/lib/bpf/features.c
> index 4f19a0d79b0c..4a75d6717bbb 100644
> --- a/tools/lib/bpf/features.c
> +++ b/tools/lib/bpf/features.c
> @@ -615,6 +615,42 @@ static int probe_kern_btf_layout(int token_fd)
> (char *)layout, token_fd));
> }
>
> +static int probe_kern_btf_vlen_kind_extended(int token_fd)
> +{
> + struct btf *btf;
> + int ret = 0;
> + __s32 id;
> + int err;
> +
> + btf = btf__load_vmlinux_btf();
> + err = libbpf_get_error(btf);
> + if (err)
> + return err;
> + id = btf__find_by_name_kind(btf, "btf_max", BTF_KIND_ENUM);
> + if (id > 0) {
> + const struct btf_type *t;
> + const struct btf_enum *e;
> + const char *name;
> + __u32 i, vlen;
> +
> + t = btf__type_by_id(btf, id);
> + if (t) {

Too much claude.
Please reduce the indent.
Easy shrink by 2 tabs.