Skip to contentSkip to conversation

samples/bpf: Add tunnel set/get tests.

PATCH Superseded William Tu 4 participants 5 messages Aug 16, 2016 – Aug 19, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

William Tu

author
#0 lore raw

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
index 90ebf7d..1070075 100644
@@ -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
index 217c8d5..3af8320 100644
@@ -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
maintainer Acked-by on v1 1/1
#1 lore raw
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.

For net-next tree. LGTM, thanks!

Acked-by on v1 1/1
#2 lore raw
In reply to William Tu
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.

nice test. thanks!

maintainer
#3 lore raw
In reply to William Tu

From: 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.

Please respin, this doesn't apply cleanly to net-next.

author
#4 lore raw

Thanks, I've submitted newer version.

Quoted 14 lines · David Miller

From: 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.

Please respin, this doesn't apply cleanly to net-next.