Skip to content

Commit aa67961

Browse files
Martin KaFai LauAlexei Starovoitov
authored andcommitted
selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n]
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: 90a3a05 ("selftests/bpf: add xfrm_info tests") Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://lore.kernel.org/r/20221206193554.1059757-1-martin.lau@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent fa55ef1 commit aa67961

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tools/testing/selftests/bpf/progs/xfrm_info.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,31 @@
33
#include "bpf_tracing_net.h"
44
#include <bpf/bpf_helpers.h>
55

6+
struct bpf_xfrm_info___local {
7+
u32 if_id;
8+
int link;
9+
} __attribute__((preserve_access_index));
10+
611
__u32 req_if_id;
712
__u32 resp_if_id;
813

914
int bpf_skb_set_xfrm_info(struct __sk_buff *skb_ctx,
10-
const struct bpf_xfrm_info *from) __ksym;
15+
const struct bpf_xfrm_info___local *from) __ksym;
1116
int bpf_skb_get_xfrm_info(struct __sk_buff *skb_ctx,
12-
struct bpf_xfrm_info *to) __ksym;
17+
struct bpf_xfrm_info___local *to) __ksym;
1318

1419
SEC("tc")
1520
int set_xfrm_info(struct __sk_buff *skb)
1621
{
17-
struct bpf_xfrm_info info = { .if_id = req_if_id };
22+
struct bpf_xfrm_info___local info = { .if_id = req_if_id };
1823

1924
return bpf_skb_set_xfrm_info(skb, &info) ? TC_ACT_SHOT : TC_ACT_UNSPEC;
2025
}
2126

2227
SEC("tc")
2328
int get_xfrm_info(struct __sk_buff *skb)
2429
{
25-
struct bpf_xfrm_info info = {};
30+
struct bpf_xfrm_info___local info = {};
2631

2732
if (bpf_skb_get_xfrm_info(skb, &info) < 0)
2833
return TC_ACT_SHOT;

0 commit comments

Comments
 (0)