> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> index b965ad571540..838602319da8 100644
> --- a/tools/lib/bpf/libbpf.h
> +++ b/tools/lib/bpf/libbpf.h

[ ... ]

> @@ -224,10 +224,32 @@ struct bpf_object_open_opts {
>        * point (/sys/fs/bpf), in case this default behavior is undesirable.
>        */
>       const char *bpf_token_path;
> +     /*
> +      * Optional list of kernel module names whose BTFs should be loaded.
> +      * nr_btf_module_names specifies the number of entries in
> +      * btf_module_names.
> +      *
> +      * If btf_module_names is NULL, all module BTFs are loaded,
> +      * preserving the default behavior. Otherwise, only the BTFs of
> +      * the listed modules are loaded. A non-NULL btf_module_names
> +      * with nr_btf_module_names equal to zero means that no module
> +      * BTFs are loaded.
> +      *
> +      * The list must not contain duplicate entries; otherwise
> +      * -EINVAL is returned.
> +      *
> +      * This affects:
> +      * - BPF CO-RE relocations against types defined in modules;
> +      * - BTF-based resolution of function attach targets for
> +      *   fentry/fexit/fmod_ret/freplace/LSM programs;
> +      * - extern (ksym) resolution for kernel symbols defined in modules.
                   ^^^^

This isn't a bug, but would it be worth adding struct_ops kernel-type
resolution to the "This affects:" list?

find_struct_ops_kern_types() (tools/lib/bpf/libbpf.c:1049) looks up
'bpf_struct_ops_<name>' via find_ksym_btf_id(), which falls back to
obj->btf_modules[] after load_module_btfs().

A struct_ops implementation whose kernel type lives in a module (e.g. a
module-provided tcp_congestion_ops or sched_ext-style struct_ops) will
therefore stop resolving once a filter that omits that module is supplied.

> +      */
> +     const char **btf_module_names;
> +     size_t nr_btf_module_names;
>
>       size_t :0;
>  };
> -#define bpf_object_open_opts__last_field bpf_token_path
> +#define bpf_object_open_opts__last_field nr_btf_module_names



---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/32730521630

Reply via email to