Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Fix compilation failure for prog vrf_socket_lookup

When building the latest kernel/selftest with clang17 compiler:

make LLVM=1 -j <== for kernel
make -C tools/testing/selftests/bpf LLVM=1 -j <== for selftest

I hit the following compilation error:

[...]
In file included from progs/vrf_socket_lookup.c:3:
In file included from /usr/include/linux/ip.h:21:
In file included from /usr/include/asm/byteorder.h:5:
In file included from /usr/include/linux/byteorder/little_endian.h:13:
/usr/include/linux/swab.h:136:8: error: unknown type name '__always_inline'
136 | static __always_inline unsigned long __swab(const unsigned long y)
| ^
/usr/include/linux/swab.h:171:8: error: unknown type name '__always_inline'
171 | static __always_inline __u16 __swab16p(const __u16 *p)
| ^
/usr/include/linux/swab.h:171:29: error: expected ';' after top level declarator
171 | static __always_inline __u16 __swab16p(const __u16 *p)
| ^
[...]

Basically, with header files in my local host which is based on 5.12 kernel,
__always_inline is not defined and this caused compilation failure.

Since __always_inline is defined in bpf_helpers.h, let us move bpf_helpers.h
to an early position which fixed the problem.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230622061921.816772-1-yhs@fb.com

authored by

Yonghong Song and committed by
Daniel Borkmann
ee77f3d6 3d5786ea

+3 -2
+3 -2
tools/testing/selftests/bpf/progs/vrf_socket_lookup.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/bpf.h> 3 + #include <bpf/bpf_helpers.h> 4 + #include <bpf/bpf_endian.h> 5 + 3 6 #include <linux/ip.h> 4 7 #include <linux/in.h> 5 8 #include <linux/if_ether.h> 6 9 #include <linux/pkt_cls.h> 7 - #include <bpf/bpf_helpers.h> 8 - #include <bpf/bpf_endian.h> 9 10 #include <stdbool.h> 10 11 11 12 int lookup_status;