WSL2-Linux-Kernel/samples/bpf
Alexei Starovoitov fbe3310840 samples: bpf: large eBPF program in C
sockex2_kern.c is purposefully large eBPF program in C.
llvm compiles ~200 lines of C code into ~300 eBPF instructions.

It's similar to __skb_flow_dissect() to demonstrate that complex packet parsing
can be done by eBPF.
Then it uses (struct flow_keys)->dst IP address (or hash of ipv6 dst) to keep
stats of number of packets per IP.
User space loads eBPF program, attaches it to loopback interface and prints
dest_ip->#packets stats every second.

Usage:
$sudo samples/bpf/sockex2
ip 127.0.0.1 count 19
ip 127.0.0.1 count 178115
ip 127.0.0.1 count 369437
ip 127.0.0.1 count 559841
ip 127.0.0.1 count 750539

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-12-05 21:47:34 -08:00
..
Makefile samples: bpf: large eBPF program in C 2014-12-05 21:47:34 -08:00
bpf_helpers.h samples: bpf: elf_bpf file loader 2014-12-05 21:47:33 -08:00
bpf_load.c samples: bpf: elf_bpf file loader 2014-12-05 21:47:33 -08:00
bpf_load.h samples: bpf: elf_bpf file loader 2014-12-05 21:47:33 -08:00
libbpf.c samples: bpf: example of stateful socket filtering 2014-12-05 21:47:32 -08:00
libbpf.h samples: bpf: trivial eBPF program in C 2014-12-05 21:47:33 -08:00
sock_example.c samples: bpf: example of stateful socket filtering 2014-12-05 21:47:32 -08:00
sockex1_kern.c samples: bpf: trivial eBPF program in C 2014-12-05 21:47:33 -08:00
sockex1_user.c samples: bpf: trivial eBPF program in C 2014-12-05 21:47:33 -08:00
sockex2_kern.c samples: bpf: large eBPF program in C 2014-12-05 21:47:34 -08:00
sockex2_user.c samples: bpf: large eBPF program in C 2014-12-05 21:47:34 -08:00
test_maps.c bpf: add a testsuite for eBPF maps 2014-11-18 13:43:59 -05:00
test_verifier.c bpf: remove test map scaffolding and user proper types 2014-11-18 13:44:00 -05:00