xref: /linux/tools/testing/selftests/bpf/progs/nested_acquire.c (revision 1260ed77798502de9c98020040d2995008de10cc)
16db59c49SJuntong Deng // SPDX-License-Identifier: GPL-2.0
26db59c49SJuntong Deng 
36db59c49SJuntong Deng #include <vmlinux.h>
46db59c49SJuntong Deng #include <bpf/bpf_tracing.h>
56db59c49SJuntong Deng #include <bpf/bpf_helpers.h>
66db59c49SJuntong Deng #include "bpf_misc.h"
7*d6212d82SToke Høiland-Jørgensen #include "../test_kmods/bpf_testmod_kfunc.h"
86db59c49SJuntong Deng 
96db59c49SJuntong Deng char _license[] SEC("license") = "GPL";
106db59c49SJuntong Deng 
116db59c49SJuntong Deng SEC("tp_btf/tcp_probe")
126db59c49SJuntong Deng __success
BPF_PROG(test_nested_acquire_nonzero,struct sock * sk,struct sk_buff * skb)136db59c49SJuntong Deng int BPF_PROG(test_nested_acquire_nonzero, struct sock *sk, struct sk_buff *skb)
146db59c49SJuntong Deng {
156db59c49SJuntong Deng 	struct sk_buff *ptr;
166db59c49SJuntong Deng 
176db59c49SJuntong Deng 	ptr = bpf_kfunc_nested_acquire_nonzero_offset_test(&sk->sk_write_queue);
186db59c49SJuntong Deng 
196db59c49SJuntong Deng 	bpf_kfunc_nested_release_test(ptr);
206db59c49SJuntong Deng 	return 0;
216db59c49SJuntong Deng }
226db59c49SJuntong Deng 
236db59c49SJuntong Deng SEC("tp_btf/tcp_probe")
246db59c49SJuntong Deng __success
BPF_PROG(test_nested_acquire_zero,struct sock * sk,struct sk_buff * skb)256db59c49SJuntong Deng int BPF_PROG(test_nested_acquire_zero, struct sock *sk, struct sk_buff *skb)
266db59c49SJuntong Deng {
276db59c49SJuntong Deng 	struct sk_buff *ptr;
286db59c49SJuntong Deng 
296db59c49SJuntong Deng 	ptr = bpf_kfunc_nested_acquire_zero_offset_test(&sk->__sk_common);
306db59c49SJuntong Deng 
316db59c49SJuntong Deng 	bpf_kfunc_nested_release_test(ptr);
326db59c49SJuntong Deng 	return 0;
336db59c49SJuntong Deng }
34