xref: /linux/tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c (revision c5288cda69ee2d8607f5026bd599a5cebf0ee783)
1 #include <linux/bpf.h>
2 #include <bpf/bpf_helpers.h>
3 #include <bpf/bpf_endian.h>
4 
5 struct {
6 	__uint(type, BPF_MAP_TYPE_SOCKMAP);
7 	__uint(max_entries, 20);
8 	__type(key, int);
9 	__type(value, int);
10 } sock_map_rx SEC(".maps");
11 
12 struct {
13 	__uint(type, BPF_MAP_TYPE_SOCKMAP);
14 	__uint(max_entries, 20);
15 	__type(key, int);
16 	__type(value, int);
17 } sock_map_tx SEC(".maps");
18 
19 struct {
20 	__uint(type, BPF_MAP_TYPE_SOCKMAP);
21 	__uint(max_entries, 20);
22 	__type(key, int);
23 	__type(value, int);
24 } sock_map_msg SEC(".maps");
25 
26 SEC("sk_skb/stream_verdict")
27 int prog_skb_verdict(struct __sk_buff *skb)
28 {
29 	return SK_PASS;
30 }
31 
32 int clone_called;
33 
34 SEC("sk_skb/stream_verdict")
35 int prog_skb_verdict_clone(struct __sk_buff *skb)
36 {
37 	clone_called = 1;
38 	return SK_PASS;
39 }
40 
41 SEC("sk_skb/stream_parser")
42 int prog_skb_parser(struct __sk_buff *skb)
43 {
44 	return SK_PASS;
45 }
46 
47 char _license[] SEC("license") = "GPL";
48