xref: /linux/tools/testing/selftests/bpf/progs/nested_acquire.c (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <vmlinux.h>
4 #include <bpf/bpf_tracing.h>
5 #include <bpf/bpf_helpers.h>
6 #include "bpf_misc.h"
7 #include "../bpf_testmod/bpf_testmod_kfunc.h"
8 
9 char _license[] SEC("license") = "GPL";
10 
11 SEC("tp_btf/tcp_probe")
12 __success
13 int BPF_PROG(test_nested_acquire_nonzero, struct sock *sk, struct sk_buff *skb)
14 {
15 	struct sk_buff *ptr;
16 
17 	ptr = bpf_kfunc_nested_acquire_nonzero_offset_test(&sk->sk_write_queue);
18 
19 	bpf_kfunc_nested_release_test(ptr);
20 	return 0;
21 }
22 
23 SEC("tp_btf/tcp_probe")
24 __success
25 int BPF_PROG(test_nested_acquire_zero, struct sock *sk, struct sk_buff *skb)
26 {
27 	struct sk_buff *ptr;
28 
29 	ptr = bpf_kfunc_nested_acquire_zero_offset_test(&sk->__sk_common);
30 
31 	bpf_kfunc_nested_release_test(ptr);
32 	return 0;
33 }
34