Re: Is tools/testing/selftests/bpf/ maintained?

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

 



On Thu, Oct 12, 2023 at 6:40 AM Tetsuo Handa
<penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello.
>
> I'm having problem with finding BPF LSM examples that work.
> I tried building tools/testing/selftests/bpf/progs/lsm.c and
> tools/testing/selftests/bpf/prog_tests/test_lsm.c explained at
> https://docs.kernel.org/bpf/prog_lsm.html , but got a lot of errors.

Make sure you a) have necessary kernel configs set up (see [0], there
are also arch-specific configs) and b) build kernel before building
selftests, because selftests generate vmlinux.h header with all kernel
types based on latest built kernel image.

  [0] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tools/testing/selftests/bpf/config

>
> ----------------------------------------
> root@ubuntu:/usr/src# git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git
> Cloning into 'linux'...
> remote: Total 9723739 (delta 8227084), reused 9723739 (delta 8227084)
> Receiving objects: 100% (9723739/9723739), 1.81 GiB | 4.04 MiB/s, done.
> Resolving deltas: 100% (8227084/8227084), done.
> Checking objects: 100% (33554432/33554432), done.
> Updating files: 100% (81759/81759), done.
> root@ubuntu:/usr/src# cd linux
> root@ubuntu:/usr/src/linux# git describe
> v6.6-rc5-72-g401644852d0b
> root@ubuntu:/usr/src/linux# make -s headers
> root@ubuntu:/usr/src/linux# make -sC tools/testing/selftests/bpf/
>   MKDIR    libbpf
> Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' differs from latest version at 'include/uapi/linux/if_xdp.h'
>   TEST-HDR [test_progs] tests.h
>   EXT-OBJ  [test_progs] testing_helpers.o
>   EXT-OBJ  [test_progs] cap_helpers.o
>   EXT-OBJ  [test_progs] unpriv_helpers.o
>   BINARY   test_verifier
>   BINARY   test_tag
>   MKDIR    bpftool
>
>   GEN      vmlinux.h
>   CLNG-BPF [test_maps] async_stack_depth.bpf.o
> progs/async_stack_depth.c:8:19: error: field has incomplete type 'struct bpf_timer'
>         struct bpf_timer timer;
>                          ^
> /usr/src/linux/tools/testing/selftests/bpf/tools/include/bpf/bpf_helper_defs.h:41:8: note: forward declaration of 'struct bpf_timer'
> struct bpf_timer;
>        ^
> 1 error generated.
> make: *** [Makefile:598: /usr/src/linux/tools/testing/selftests/bpf/async_stack_depth.bpf.o] Error 1
> ----------------------------------------
>
> To fix these errors, something like the following
> (this seems to be a fraction) is needed. What am I missing?
>

kernel image used for vmlinux.h generation is probably too old

[...]





[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