2 #include "bpf_helpers.h"
3 #include "bpf_endian.h"
5 int _version
SEC("version") = 1;
8 __uint(type
, BPF_MAP_TYPE_SOCKMAP
);
9 __uint(max_entries
, 20);
10 __uint(key_size
, sizeof(int));
11 __uint(value_size
, sizeof(int));
12 } sock_map_rx
SEC(".maps");
15 __uint(type
, BPF_MAP_TYPE_SOCKMAP
);
16 __uint(max_entries
, 20);
17 __uint(key_size
, sizeof(int));
18 __uint(value_size
, sizeof(int));
19 } sock_map_tx
SEC(".maps");
22 __uint(type
, BPF_MAP_TYPE_SOCKMAP
);
23 __uint(max_entries
, 20);
24 __uint(key_size
, sizeof(int));
25 __uint(value_size
, sizeof(int));
26 } sock_map_msg
SEC(".maps");
29 __uint(type
, BPF_MAP_TYPE_ARRAY
);
30 __uint(max_entries
, 20);
33 } sock_map_break
SEC(".maps");
36 int bpf_prog2(struct __sk_buff
*skb
)
38 void *data_end
= (void *)(long) skb
->data_end
;
39 void *data
= (void *)(long) skb
->data
;
40 __u32 lport
= skb
->local_port
;
41 __u32 rport
= skb
->remote_port
;
45 if (data
+ 8 > data_end
)
61 return bpf_sk_redirect_map(skb
, &sock_map_rx
, sk
, 0);
62 return bpf_sk_redirect_map(skb
, &sock_map_tx
, sk
, 0);
65 char _license
[] SEC("license") = "GPL";