xref: /linux/tools/testing/selftests/bpf/progs/sock_addr_kern.c (revision 621cde16e49b3ecf7d59a8106a20aaebfb4a59a9)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2024 Google LLC */
3 #include <vmlinux.h>
4 #include <bpf/bpf_helpers.h>
5 #include "../bpf_testmod/bpf_testmod_kfunc.h"
6 
7 SEC("syscall")
init_sock(struct init_sock_args * args)8 int init_sock(struct init_sock_args *args)
9 {
10 	bpf_kfunc_init_sock(args);
11 
12 	return 0;
13 }
14 
15 SEC("syscall")
close_sock(void * ctx)16 int close_sock(void *ctx)
17 {
18 	bpf_kfunc_close_sock();
19 
20 	return 0;
21 }
22 
23 SEC("syscall")
kernel_connect(struct addr_args * args)24 int kernel_connect(struct addr_args *args)
25 {
26 	return bpf_kfunc_call_kernel_connect(args);
27 }
28 
29 SEC("syscall")
kernel_bind(struct addr_args * args)30 int kernel_bind(struct addr_args *args)
31 {
32 	return bpf_kfunc_call_kernel_bind(args);
33 }
34 
35 SEC("syscall")
kernel_listen(struct addr_args * args)36 int kernel_listen(struct addr_args *args)
37 {
38 	return bpf_kfunc_call_kernel_listen();
39 }
40 
41 SEC("syscall")
kernel_sendmsg(struct sendmsg_args * args)42 int kernel_sendmsg(struct sendmsg_args *args)
43 {
44 	return bpf_kfunc_call_kernel_sendmsg(args);
45 }
46 
47 SEC("syscall")
sock_sendmsg(struct sendmsg_args * args)48 int sock_sendmsg(struct sendmsg_args *args)
49 {
50 	return bpf_kfunc_call_sock_sendmsg(args);
51 }
52 
53 SEC("syscall")
kernel_getsockname(struct addr_args * args)54 int kernel_getsockname(struct addr_args *args)
55 {
56 	return bpf_kfunc_call_kernel_getsockname(args);
57 }
58 
59 SEC("syscall")
kernel_getpeername(struct addr_args * args)60 int kernel_getpeername(struct addr_args *args)
61 {
62 	return bpf_kfunc_call_kernel_getpeername(args);
63 }
64 
65 char _license[] SEC("license") = "GPL";
66