bpf: selftests: test_tunnel: Use vmlinux.h declarations
authorDaniel Xu <dxu@dxuuu.xyz>
Thu, 14 Dec 2023 22:49:04 +0000 (15:49 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 15 Dec 2023 01:12:49 +0000 (17:12 -0800)
commit02b4e126e6a5f5552da2ccec47a028984d2d9654
tree8c250a11aa648e0d71e26ae415062335b729a141
parent77a7a8220f0d87c44425c0a12e0a72b14962535b
bpf: selftests: test_tunnel: Use vmlinux.h declarations

vmlinux.h declarations are more ergnomic, especially when working with
kfuncs. The uapi headers are often incomplete for kfunc definitions.

This commit also switches bitfield accesses to use CO-RE helpers.
Switching to vmlinux.h definitions makes the verifier very
unhappy with raw bitfield accesses. The error is:

    ; md.u.md2.dir = direction;
    33: (69) r1 = *(u16 *)(r2 +11)
    misaligned stack access off (0x0; 0x0)+-64+11 size 2

Fix by using CO-RE-aware bitfield reads and writes.

Co-developed-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/884bde1d9a351d126a3923886b945ea6b1b0776b.1702593901.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/bpf_tracing_net.h
tools/testing/selftests/bpf/progs/test_tunnel_kern.c