Skip to contentSkip to conversation

selftests/bpf: Fix compilation failure for prog vrf_socket_lookup

PATCH Applied Yonghong Song 2 participants 2 messages Jun 22, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 tools/testing/selftests/bpf/progs/vrf_socket_lookup.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/progs/vrf_socket_lookup.c +3 -2
index 26e07a252585..bcfb6feb38c0 100644
@@ -1,11 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/bpf.h>
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_endian.h>
+
 #include <linux/ip.h>
 #include <linux/in.h>
 #include <linux/if_ether.h>
 #include <linux/pkt_cls.h>
-#include <bpf/bpf_helpers.h>
-#include <bpf/bpf_endian.h>
 #include <stdbool.h>
 
 int lookup_status;
Signature · 1 line
2.34.1
#1 lore raw
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Quoted 14 lines · On Wed, 21 Jun 2023 23:19:21 -0700 you wrote:

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'

Quoted 8 lines
    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)
        |                             ^

...

[...]

Here is the summary with links:
- [bpf-next] selftests/bpf: Fix compilation failure for prog vrf_socket_lookup

    https://git.kernel.org/bpf/bpf-next/c/ee77f3d602b0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html