selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n]
Subsystems (5)
Martin KaFai Lau
reviewerPATCH 1/1 selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n]
From: Martin KaFai Lau <[email protected]>
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].
--- tools/testing/selftests/bpf/progs/xfrm_info.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/progs/xfrm_info.c +9 -4
@@ -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 ;
Signature · 1 line
2.30.2
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 11 lines · On Tue, 6 Dec 2022 11:35:54 -0800 you wrote:
From: Martin KaFai Lau <[email protected]>
It is useful to use
vmlinux.hin thexfrm_infotest like other kfunc tests do. In particular, it is common for kfunc bpf prog that requires to use other core kernel structures invmlinux.hAlthough
vmlinux.his preferred, it needs a___localflavor of structbpf_xfrm_infoin order to build the bpf selftests whenCONFIG_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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html