diff mbox series

[bpf-next] selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n]

Message ID 20221206193554.1059757-1-martin.lau@linux.dev (mailing list archive)
State Accepted
Commit aa67961f3243dfff26c47769f87b4d94b07ec71f
Delegated to: BPF
Headers show
Series [bpf-next] selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n] | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 10 maintainers not CCed: linux-kselftest@vger.kernel.org kpsingh@kernel.org haoluo@google.com song@kernel.org yhs@fb.com sdf@google.com john.fastabend@gmail.com shuah@kernel.org jolsa@kernel.org mykolal@fb.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 34 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-2 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-4 pending Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix

Commit Message

Martin KaFai Lau Dec. 6, 2022, 7:35 p.m. UTC
From: Martin KaFai Lau <martin.lau@kernel.org>

It is useful to use vmlinux.h in the xfrm_info test like other kfunc
tests do.  In particular, it is common for kfunc bpf prog that requires
to use other core kernel structures in vmlinux.h

Although vmlinux.h is preferred, it needs a ___local flavor of
struct bpf_xfrm_info in order to build the bpf selftests
when CONFIG_XFRM_INTERFACE=[m|n].

Cc: Eyal Birger <eyal.birger@gmail.com>
Fixes: 90a3a05eb33f ("selftests/bpf: add xfrm_info tests")
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
---
 tools/testing/selftests/bpf/progs/xfrm_info.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 6, 2022, 9 p.m. UTC | #1
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue,  6 Dec 2022 11:35:54 -0800 you wrote:
> From: Martin KaFai Lau <martin.lau@kernel.org>
> 
> It is useful to use vmlinux.h in the xfrm_info test like other kfunc
> tests do.  In particular, it is common for kfunc bpf prog that requires
> to use other core kernel structures in vmlinux.h
> 
> Although vmlinux.h is preferred, it needs a ___local flavor of
> struct bpf_xfrm_info in order to build the bpf selftests
> when CONFIG_XFRM_INTERFACE=[m|n].
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n]
    https://git.kernel.org/bpf/bpf-next/c/aa67961f3243

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/progs/xfrm_info.c b/tools/testing/selftests/bpf/progs/xfrm_info.c
index 3acedcdd962d..f6a501fbba2b 100644
--- a/tools/testing/selftests/bpf/progs/xfrm_info.c
+++ b/tools/testing/selftests/bpf/progs/xfrm_info.c
@@ -3,18 +3,23 @@ 
 #include "bpf_tracing_net.h"
 #include <bpf/bpf_helpers.h>
 
+struct bpf_xfrm_info___local {
+	u32 if_id;
+	int link;
+} __attribute__((preserve_access_index));
+
 __u32 req_if_id;
 __u32 resp_if_id;
 
 int bpf_skb_set_xfrm_info(struct __sk_buff *skb_ctx,
-			  const struct bpf_xfrm_info *from) __ksym;
+			  const struct bpf_xfrm_info___local *from) __ksym;
 int bpf_skb_get_xfrm_info(struct __sk_buff *skb_ctx,
-			  struct bpf_xfrm_info *to) __ksym;
+			  struct bpf_xfrm_info___local *to) __ksym;
 
 SEC("tc")
 int set_xfrm_info(struct __sk_buff *skb)
 {
-	struct bpf_xfrm_info info = { .if_id = req_if_id };
+	struct bpf_xfrm_info___local info = { .if_id = req_if_id };
 
 	return bpf_skb_set_xfrm_info(skb, &info) ? TC_ACT_SHOT : TC_ACT_UNSPEC;
 }
@@ -22,7 +27,7 @@  int set_xfrm_info(struct __sk_buff *skb)
 SEC("tc")
 int get_xfrm_info(struct __sk_buff *skb)
 {
-	struct bpf_xfrm_info info = {};
+	struct bpf_xfrm_info___local info = {};
 
 	if (bpf_skb_get_xfrm_info(skb, &info) < 0)
 		return TC_ACT_SHOT;