samples/bpf: Add tunnel set/get tests.
Subsystems (3)
PATCH v2 1/1 samples/bpf: Add tunnel set/get tests.
The patch creates sample code exercising bpf_skb_{set,get}_tunnel_key, and bpf_skb_{set,get}_tunnel_opt for GRE, VXLAN, and GENEVE. A native tunnel device is created in a namespace to interact with a lwtunnel device out of the namespace, with metadata enabled. The bpf_skb_set_* program is attached to tc egress and bpf_skb_get_* is attached to egress qdisc. A ping between two tunnels is used to verify correctness and the result of bpf_skb_get_* printed by bpf_trace_printk.
--- samples/bpf/Makefile | 1 + samples/bpf/bpf_helpers.h | 8 ++ samples/bpf/tcbpf2_kern.c | 191 +++++++++++++++++++++++++++++++++++++++++ samples/bpf/test_tunnel_bpf.sh | 127 +++++++++++++++++++++++++++ 4 files changed, 327 insertions(+) create mode 100644 samples/bpf/tcbpf2_kern.c create mode 100755 samples/bpf/test_tunnel_bpf.sh
samples/bpf/Makefile +1 -0
@@ -67,6 +67,7 @@ always += tracex6_kern.o always += test_probe_write_user_kern.o always += trace_output_kern.o always += tcbpf1_kern.o +always += tcbpf2_kern.o always += lathist_kern.o always += offwaketime_kern.o always += spintest_kern.o
samples/bpf/bpf_helpers.h +8 -0
@@ -47,6 +47,14 @@ static int (*bpf_probe_write_user)(void *dst, void *src, int size) = (void *) BPF_FUNC_probe_write_user;static int (*bpf_current_task_under_cgroup)(void *map,int index) = (void *) BPF_FUNC_current_task_under_cgroup; +static int (*bpf_skb_get_tunnel_key)(void *ctx,void *key,int size,int flags) = + (void *) BPF_FUNC_skb_get_tunnel_key; +static int (*bpf_skb_set_tunnel_key)(void *ctx,void *key,int size,int flags) = + (void *) BPF_FUNC_skb_set_tunnel_key; +static int (*bpf_skb_get_tunnel_opt)(void *ctx,void *md,int size) = + (void *) BPF_FUNC_skb_get_tunnel_opt; +static int (*bpf_skb_set_tunnel_opt)(void *ctx,void *md,int size) = + (void *) BPF_FUNC_skb_set_tunnel_opt;/* llvm builtin functions that eBPF C program may use to * emit BPF_LD_ABS and BPF_LD_IND instructions
samples/bpf/tcbpf2_kern.c new file +191 -0
191 lines not on this page · raw message
samples/bpf/test_tunnel_bpf.sh new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
2.5.0
From: William Tu <[email protected]>
Date: Fri, 19 Aug 2016 11:55:44 -0700
Quoted 9 lines
The patch creates sample code exercising bpf_skb_{set,get}_tunnel_key, and bpf_skb_{set,get}_tunnel_opt for GRE, VXLAN, and GENEVE. A native tunnel device is created in a namespace to interact with a lwtunnel device out of the namespace, with metadata enabled. The bpf_skb_set_* program is attached to tc egress and bpf_skb_get_* is attached to egress qdisc. A ping between two tunnels is used to verify correctness and the result of bpf_skb_get_* printed by
bpf_trace_printk.Signed-off-by William Tu <[email protected]>
Applied, thanks.
Next time, propagate the ACK's your received into your commit message when you post new versions.
Thanks. I will do it next time.
Quoted 17 lines · David Miller
From: William Tu <[email protected]>
Date: Fri, 19 Aug 2016 11:55:44 -0700Quoted 9 lines
The patch creates sample code exercising bpf_skb_{set,get}_tunnel_key, and bpf_skb_{set,get}_tunnel_opt for GRE, VXLAN, and GENEVE. A native tunnel device is created in a namespace to interact with a lwtunnel device out of the namespace, with metadata enabled. The bpf_skb_set_* program is attached to tc egress and bpf_skb_get_* is attached to egress qdisc. A ping between two tunnels is used to verify correctness and the result of bpf_skb_get_* printed by
bpf_trace_printk.Signed-off-by William Tu <[email protected]>Applied, thanks.
Next time, propagate the ACK's your received into your commit message when you post new versions.