xref: /linux/tools/testing/selftests/bpf/bpf_kfuncs.h (revision d457a0e329b0bfd3a1450e0b1a18cd2b47a25a08)
1 #ifndef __BPF_KFUNCS__
2 #define __BPF_KFUNCS__
3 
4 /* Description
5  *  Initializes an skb-type dynptr
6  * Returns
7  *  Error code
8  */
9 extern int bpf_dynptr_from_skb(struct __sk_buff *skb, __u64 flags,
10     struct bpf_dynptr *ptr__uninit) __ksym;
11 
12 /* Description
13  *  Initializes an xdp-type dynptr
14  * Returns
15  *  Error code
16  */
17 extern int bpf_dynptr_from_xdp(struct xdp_md *xdp, __u64 flags,
18 			       struct bpf_dynptr *ptr__uninit) __ksym;
19 
20 /* Description
21  *  Obtain a read-only pointer to the dynptr's data
22  * Returns
23  *  Either a direct pointer to the dynptr data or a pointer to the user-provided
24  *  buffer if unable to obtain a direct pointer
25  */
26 extern void *bpf_dynptr_slice(const struct bpf_dynptr *ptr, __u32 offset,
27 			      void *buffer, __u32 buffer__szk) __ksym;
28 
29 /* Description
30  *  Obtain a read-write pointer to the dynptr's data
31  * Returns
32  *  Either a direct pointer to the dynptr data or a pointer to the user-provided
33  *  buffer if unable to obtain a direct pointer
34  */
35 extern void *bpf_dynptr_slice_rdwr(const struct bpf_dynptr *ptr, __u32 offset,
36 			      void *buffer, __u32 buffer__szk) __ksym;
37 
38 extern int bpf_dynptr_adjust(const struct bpf_dynptr *ptr, __u32 start, __u32 end) __ksym;
39 extern bool bpf_dynptr_is_null(const struct bpf_dynptr *ptr) __ksym;
40 extern bool bpf_dynptr_is_rdonly(const struct bpf_dynptr *ptr) __ksym;
41 extern __u32 bpf_dynptr_size(const struct bpf_dynptr *ptr) __ksym;
42 extern int bpf_dynptr_clone(const struct bpf_dynptr *ptr, struct bpf_dynptr *clone__init) __ksym;
43 
44 #endif
45