48 lines · c
1#include <linux/bpf.h>2#include <bpf/bpf_helpers.h>3#include <bpf/bpf_endian.h>4 5struct {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 12struct {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 19struct {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 26SEC("sk_skb/stream_verdict")27int prog_skb_verdict(struct __sk_buff *skb)28{29 return SK_PASS;30}31 32int clone_called;33 34SEC("sk_skb/stream_verdict")35int prog_skb_verdict_clone(struct __sk_buff *skb)36{37 clone_called = 1;38 return SK_PASS;39}40 41SEC("sk_skb/stream_parser")42int prog_skb_parser(struct __sk_buff *skb)43{44 return SK_PASS;45}46 47char _license[] SEC("license") = "GPL";48