From: Alexei Starovoitov Date: Mon, 1 Dec 2014 23:06:39 +0000 (-0800) Subject: samples: bpf: large eBPF program in C X-Git-Tag: omap-for-v3.20/drop-legacy-3517~122^2~93^2 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbe3310840c65f3cf97dd90d23e177d061c376f2;p=pandora-kernel.git 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 Signed-off-by: David S. Miller --- Reading git-diff-tree failed