Loading...
Note: File does not exist in v5.4.
1/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef _BPF_TESTMOD_KFUNC_H
4#define _BPF_TESTMOD_KFUNC_H
5
6#ifndef __KERNEL__
7#include <vmlinux.h>
8#include <bpf/bpf_helpers.h>
9#else
10#define __ksym
11struct prog_test_member1 {
12 int a;
13};
14
15struct prog_test_member {
16 struct prog_test_member1 m;
17 int c;
18};
19
20struct prog_test_ref_kfunc {
21 int a;
22 int b;
23 struct prog_test_member memb;
24 struct prog_test_ref_kfunc *next;
25 refcount_t cnt;
26};
27#endif
28
29struct prog_test_pass1 {
30 int x0;
31 struct {
32 int x1;
33 struct {
34 int x2;
35 struct {
36 int x3;
37 };
38 };
39 };
40};
41
42struct prog_test_pass2 {
43 int len;
44 short arr1[4];
45 struct {
46 char arr2[4];
47 unsigned long arr3[8];
48 } x;
49};
50
51struct prog_test_fail1 {
52 void *p;
53 int x;
54};
55
56struct prog_test_fail2 {
57 int x8;
58 struct prog_test_pass1 x;
59};
60
61struct prog_test_fail3 {
62 int len;
63 char arr1[2];
64 char arr2[];
65};
66
67struct init_sock_args {
68 int af;
69 int type;
70};
71
72struct addr_args {
73 char addr[sizeof(struct __kernel_sockaddr_storage)];
74 int addrlen;
75};
76
77struct sendmsg_args {
78 struct addr_args addr;
79 char msg[10];
80 int msglen;
81};
82
83struct bpf_testmod_ctx {
84 struct callback_head rcu;
85 refcount_t usage;
86};
87
88struct prog_test_ref_kfunc *
89bpf_kfunc_call_test_acquire(unsigned long *scalar_ptr) __ksym;
90void bpf_kfunc_call_test_release(struct prog_test_ref_kfunc *p) __ksym;
91void bpf_kfunc_call_test_ref(struct prog_test_ref_kfunc *p) __ksym;
92
93void bpf_kfunc_call_test_mem_len_pass1(void *mem, int len) __ksym;
94int *bpf_kfunc_call_test_get_rdwr_mem(struct prog_test_ref_kfunc *p, const int rdwr_buf_size) __ksym;
95int *bpf_kfunc_call_test_get_rdonly_mem(struct prog_test_ref_kfunc *p, const int rdonly_buf_size) __ksym;
96int *bpf_kfunc_call_test_acq_rdonly_mem(struct prog_test_ref_kfunc *p, const int rdonly_buf_size) __ksym;
97void bpf_kfunc_call_int_mem_release(int *p) __ksym;
98
99/* The bpf_kfunc_call_test_static_unused_arg is defined as static,
100 * but bpf program compilation needs to see it as global symbol.
101 */
102#ifndef __KERNEL__
103u32 bpf_kfunc_call_test_static_unused_arg(u32 arg, u32 unused) __ksym;
104#endif
105
106void bpf_testmod_test_mod_kfunc(int i) __ksym;
107
108__u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b,
109 __u32 c, __u64 d) __ksym;
110int bpf_kfunc_call_test2(struct sock *sk, __u32 a, __u32 b) __ksym;
111struct sock *bpf_kfunc_call_test3(struct sock *sk) __ksym;
112long bpf_kfunc_call_test4(signed char a, short b, int c, long d) __ksym;
113
114void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb) __ksym;
115void bpf_kfunc_call_test_pass1(struct prog_test_pass1 *p) __ksym;
116void bpf_kfunc_call_test_pass2(struct prog_test_pass2 *p) __ksym;
117void bpf_kfunc_call_test_mem_len_fail2(__u64 *mem, int len) __ksym;
118
119void bpf_kfunc_call_test_destructive(void) __ksym;
120void bpf_kfunc_call_test_sleepable(void) __ksym;
121
122void bpf_kfunc_call_test_offset(struct prog_test_ref_kfunc *p);
123struct prog_test_member *bpf_kfunc_call_memb_acquire(void);
124void bpf_kfunc_call_memb1_release(struct prog_test_member1 *p);
125void bpf_kfunc_call_test_fail1(struct prog_test_fail1 *p);
126void bpf_kfunc_call_test_fail2(struct prog_test_fail2 *p);
127void bpf_kfunc_call_test_fail3(struct prog_test_fail3 *p);
128void bpf_kfunc_call_test_mem_len_fail1(void *mem, int len);
129
130void bpf_kfunc_common_test(void) __ksym;
131
132int bpf_kfunc_init_sock(struct init_sock_args *args) __ksym;
133void bpf_kfunc_close_sock(void) __ksym;
134int bpf_kfunc_call_kernel_connect(struct addr_args *args) __ksym;
135int bpf_kfunc_call_kernel_bind(struct addr_args *args) __ksym;
136int bpf_kfunc_call_kernel_listen(void) __ksym;
137int bpf_kfunc_call_kernel_sendmsg(struct sendmsg_args *args) __ksym;
138int bpf_kfunc_call_sock_sendmsg(struct sendmsg_args *args) __ksym;
139int bpf_kfunc_call_kernel_getsockname(struct addr_args *args) __ksym;
140int bpf_kfunc_call_kernel_getpeername(struct addr_args *args) __ksym;
141
142void bpf_kfunc_dynptr_test(struct bpf_dynptr *ptr, struct bpf_dynptr *ptr__nullable) __ksym;
143
144struct bpf_testmod_ctx *bpf_testmod_ctx_create(int *err) __ksym;
145void bpf_testmod_ctx_release(struct bpf_testmod_ctx *ctx) __ksym;
146
147struct sk_buff *bpf_kfunc_nested_acquire_nonzero_offset_test(struct sk_buff_head *ptr) __ksym;
148struct sk_buff *bpf_kfunc_nested_acquire_zero_offset_test(struct sock_common *ptr) __ksym;
149void bpf_kfunc_nested_release_test(struct sk_buff *ptr) __ksym;
150
151struct st_ops_args;
152int bpf_kfunc_st_ops_test_prologue(struct st_ops_args *args) __ksym;
153int bpf_kfunc_st_ops_test_epilogue(struct st_ops_args *args) __ksym;
154int bpf_kfunc_st_ops_test_pro_epilogue(struct st_ops_args *args) __ksym;
155int bpf_kfunc_st_ops_inc10(struct st_ops_args *args) __ksym;
156
157void bpf_kfunc_trusted_vma_test(struct vm_area_struct *ptr) __ksym;
158void bpf_kfunc_trusted_task_test(struct task_struct *ptr) __ksym;
159void bpf_kfunc_trusted_num_test(int *ptr) __ksym;
160void bpf_kfunc_rcu_task_test(struct task_struct *ptr) __ksym;
161
162#endif /* _BPF_TESTMOD_KFUNC_H */