Re: [PATCH bpf-next 2/2] selftests/bpf: add subprog to BPF object file with no entry programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 10, 2024 at 2:17 PM Andrii Nakryiko <andrii@xxxxxxxxxx> wrote:
>
> Add a subprogram to BPF object file that otherwise has no entry BPF
> programs to validate that libbpf can still load this correctly.
>
> Until this was fixed, user could expect this very confusing error message:
>
>   libbpf: prog 'dangling_subprog': missing BPF prog type, check ELF section name '.text'
>   libbpf: prog 'dangling_subprog': failed to load: -22
>   libbpf: failed to load object 'struct_ops_detach'
>   libbpf: failed to load BPF skeleton 'struct_ops_detach': -22
>
> Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> ---
>  tools/testing/selftests/bpf/progs/struct_ops_detach.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/progs/struct_ops_detach.c b/tools/testing/selftests/bpf/progs/struct_ops_detach.c
> index 56b787a89876..5222d58592a7 100644
> --- a/tools/testing/selftests/bpf/progs/struct_ops_detach.c
> +++ b/tools/testing/selftests/bpf/progs/struct_ops_detach.c
> @@ -6,5 +6,11 @@
>
>  char _license[] SEC("license") = "GPL";
>

argh, I had this comment here, which I missed to amend into this
patch, maybe whoever applies can just add it so I don't spam the
mailing list:

/* This subprogram validates that libbpf handles the situation in which BPF
 * object has subprograms in .text section, but has no entry BPF programs.
 * At some point that was causing issues due to legacy logic of treating such
 * subprogram as entry program (with unknown program type, which would fail).
 */
> +int dangling_subprog(void)
> +{
> +       /* do nothing, just be here */
> +       return 0;
> +}
> +
>  SEC(".struct_ops.link")
>  struct bpf_testmod_ops testmod_do_detach;
> --
> 2.43.5
>





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux