samples/bpf: Add tunnel set/get tests.
Subsystems (3)
PATCH 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 | 121 ++++++++++++++++++++++++++ 4 files changed, 321 insertions(+) create mode 100644 samples/bpf/tcbpf2_kern.c create mode 100755 samples/bpf/test_tunnel_bpf.sh
samples/bpf/Makefile +1 -0
@@ -64,6 +64,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
@@ -43,6 +43,14 @@ static int (*bpf_get_stackid)(void *ctx, void *map, int flags) = (void *) BPF_FUNC_get_stackid;static int (*bpf_probe_write_user)(void *dst,void *src,int size) = (void *) BPF_FUNC_probe_write_user; +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 +121 -0
121 lines not on this page · raw message
Signature · 1 line
2.5.0
Quoted 9 lines · William Tu
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]>
For net-next tree. LGTM, thanks!
Quoted 9 lines · William Tu
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]>
nice test. thanks!
David Miller
maintainerFrom: William Tu <[email protected]>
Date: Tue, 16 Aug 2016 07:03:01 -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]>
Please respin, this doesn't apply cleanly to net-next.
Thanks, I've submitted newer version.
Quoted 14 lines · David Miller
From: William Tu <[email protected]>
Date: Tue, 16 Aug 2016 07:03:01 -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]>Please respin, this doesn't apply cleanly to net-next.