Skip to contentSkip to conversation

BPF tunnel testsuite

PATCH In review William Tu 2 participants 4 messages Apr 26, 2018 – Apr 27, 2018

Subsystems (5)
lore
Share & tools
lore

William Tu

author
#0 lore raw

v2 cover BPF tunnel testsuite

The patch series provide end-to-end eBPF tunnel testsute. A common topology is created below for all types of tunnels:

Topology:
---------

     root namespace   |     at_ns0 namespace                                   
                      |                                                        
      -----------     |     -----------                                        
      | tnl dev |     |     | tnl dev |  (overlay network)                     
      -----------     |     -----------                                        
      metadata-mode   |     native-mode                                        
       with bpf       |                                                        
                      |                                                        
      ----------      |     ----------                                         
      |  veth1  | --------- |  veth0  |  (underlay network)                    
      ----------    peer    ----------                                         

Device Configuration
--------------------
Root namespace with metadata-mode tunnel + BPF
Device names and addresses:

       veth1 IP: 172.16.1.200, IPv6: 00::22 (underlay)                         
       tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200 (overlay)              

Namespace at_ns0 with native tunnel
Device names and addresses:

       veth0 IPv4: 172.16.1.100, IPv6: 00::11 (underlay)                       
       tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100 (overlay)              

End-to-end ping packet flow
---------------------------
Most of the tests start by namespace creation, device configuration, then ping the underlay and overlay network. When doing 'ping 10.1.1.100' from root namespace, the following operations happen:
1) Route lookup shows 10.1.1.100/24 belongs to tnl dev, fwd to tnl dev.
2) Tnl device's egress BPF program is triggered and set the tunnel metadata,

    with remote_ip=172.16.1.200 and others.                                    

3) Outer tunnel header is prepended and route the packet to veth1's egress
4) veth0's ingress queue receive the tunneled packet at namespace at_ns0
5) Tunnel protocol handler, ex: vxlan_rcv, decap the packet
6) Forward the packet to the overlay tnl dev

Test Cases
-----------------------------
Tunnel Type | BPF Programs
-----------------------------

 GRE:          gre_set_tunnel, gre_get_tunnel
 IP6GRE:       ip6gretap_set_tunnel, ip6gretap_get_tunnel
 ERSPAN:       erspan_set_tunnel, erspan_get_tunnel
 IP6ERSPAN:    ip4ip6erspan_set_tunnel, ip4ip6erspan_get_tunnel
 VXLAN:        vxlan_set_tunnel, vxlan_get_tunnel
 IP6VXLAN:     ip6vxlan_set_tunnel, ip6vxlan_get_tunnel
 GENEVE:       geneve_set_tunnel, geneve_get_tunnel
 IP6GENEVE:    ip6geneve_set_tunnel, ip6geneve_get_tunnel
 IPIP:         ipip_set_tunnel, ipip_get_tunnel
 IP6IP:        ipip6_set_tunnel, ipip6_get_tunnel,

ip6ip6_set_tunnel, ip6ip6_get_tunnel
XFRM: xfrm_get_state

William Tu (2):
selftests/bpf: bpf tunnel test.
samples/bpf: remove the bpf tunnel testsuite.

 samples/bpf/Makefile                           |   1 -
 samples/bpf/tcbpf2_kern.c                      | 612 ---------------------
 samples/bpf/test_tunnel_bpf.sh                 | 390 -------------
 tools/testing/selftests/bpf/Makefile           |   5 +-
 tools/testing/selftests/bpf/test_tunnel.sh     | 729 +++++++++++++++++++++++++
 tools/testing/selftests/bpf/test_tunnel_kern.c | 713 ++++++++++++++++++++++++
 6 files changed, 1445 insertions(+), 1005 deletions(-)
 delete mode 100644 samples/bpf/tcbpf2_kern.c
 delete mode 100755 samples/bpf/test_tunnel_bpf.sh
 create mode 100755 tools/testing/selftests/bpf/test_tunnel.sh
 create mode 100644 tools/testing/selftests/bpf/test_tunnel_kern.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v2 1/2 selftests/bpf: bpf tunnel test.

The patch migrates the original tests at samples/bpf/tcbpf2_kern.c and samples/bpf/test_tunnel_bpf.sh to selftests. There are a couple changes from the original:
1) add ipv6 vxlan, ipv6 geneve, ipv6 ipip tests
2) simplify the original ipip tests (remove iperf tests)
3) improve documentation
4) use bpf_ntoh* and bpf_hton* api

In summary, 'test_tunnel_kern.o' contains the following bpf program:
GRE: gre_set_tunnel, gre_get_tunnel
IP6GRE: ip6gretap_set_tunnel, ip6gretap_get_tunnel
ERSPAN: erspan_set_tunnel, erspan_get_tunnel
IP6ERSPAN: ip4ip6erspan_set_tunnel, ip4ip6erspan_get_tunnel
VXLAN: vxlan_set_tunnel, vxlan_get_tunnel
IP6VXLAN: ip6vxlan_set_tunnel, ip6vxlan_get_tunnel
GENEVE: geneve_set_tunnel, geneve_get_tunnel
IP6GENEVE: ip6geneve_set_tunnel, ip6geneve_get_tunnel
IPIP: ipip_set_tunnel, ipip_get_tunnel
IP6IP: ipip6_set_tunnel, ipip6_get_tunnel,
ip6ip6_set_tunnel, ip6ip6_get_tunnel
XFRM: xfrm_get_state

---
 tools/testing/selftests/bpf/Makefile           |   5 +-
 tools/testing/selftests/bpf/test_tunnel.sh     | 729 +++++++++++++++++++++++++
 tools/testing/selftests/bpf/test_tunnel_kern.c | 713 ++++++++++++++++++++++++
 3 files changed, 1445 insertions(+), 2 deletions(-)
 create mode 100755 tools/testing/selftests/bpf/test_tunnel.sh
 create mode 100644 tools/testing/selftests/bpf/test_tunnel_kern.c
tools/testing/selftests/bpf/Makefile +3 -2
index 0c19d5e08f08..b64a7a39cbc8 100644
@@ -32,7 +32,7 @@ TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o test
 	test_l4lb_noinline.o test_xdp_noinline.o test_stacktrace_map.o \
 	sample_map_ret0.o test_tcpbpf_kern.o test_stacktrace_build_id.o \
 	sockmap_tcp_msg_prog.o connect4_prog.o connect6_prog.o test_adjust_tail.o \
-	test_btf_haskv.o test_btf_nokv.o test_sockmap_kern.o
+	test_btf_haskv.o test_btf_nokv.o test_sockmap_kern.o test_tunnel_kern.o
 
 # Order correspond to 'make run_tests' order
 TEST_PROGS := test_kmod.sh \
@@ -40,7 +40,8 @@ TEST_PROGS := test_kmod.sh \
 	test_xdp_redirect.sh \
 	test_xdp_meta.sh \
 	test_offload.py \
-	test_sock_addr.sh
+	test_sock_addr.sh \
+	test_tunnel.sh
 
 # Compile but not part of 'make run_tests'
 TEST_GEN_PROGS_EXTENDED = test_libbpf_open test_sock_addr
tools/testing/selftests/bpf/test_tunnel.sh new file +729 -0

729 lines not on this page · raw message

tools/testing/selftests/bpf/test_tunnel_kern.c new file +713 -0

713 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v2 2/2 samples/bpf: remove the bpf tunnel testsuite.

In reply to William Tu

Move the testsuite to selftests/bpf/{test_tunnel_kern.c, test_tunnel.sh}

---
 samples/bpf/Makefile           |   1 -
 samples/bpf/tcbpf2_kern.c      | 612 -----------------------------------------
 samples/bpf/test_tunnel_bpf.sh | 390 --------------------------
 3 files changed, 1003 deletions(-)
 delete mode 100644 samples/bpf/tcbpf2_kern.c
 delete mode 100755 samples/bpf/test_tunnel_bpf.sh
samples/bpf/Makefile +0 -1
index aa8c392e2e52..b853581592fd 100644
@@ -114,7 +114,6 @@ always += sock_flags_kern.o
 always += test_probe_write_user_kern.o
 always += trace_output_kern.o
 always += tcbpf1_kern.o
-always += tcbpf2_kern.o
 always += tc_l2_redirect_kern.o
 always += lathist_kern.o
 always += offwaketime_kern.o
samples/bpf/tcbpf2_kern.c deleted +0 -612

612 lines not on this page · raw message

samples/bpf/test_tunnel_bpf.sh deleted +0 -390

390 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#3 lore raw
In reply to William Tu
Quoted 58 lines · William Tu

The patch series provide end-to-end eBPF tunnel testsute. A common topology is created below for all types of tunnels:

Topology:
---------

     root namespace   |     at_ns0 namespace                                   
                      |                                                        
      -----------     |     -----------                                        
      | tnl dev |     |     | tnl dev |  (overlay network)                     
      -----------     |     -----------                                        
      metadata-mode   |     native-mode                                        
       with bpf       |                                                        
                      |                                                        
      ----------      |     ----------                                         
      |  veth1  | --------- |  veth0  |  (underlay network)                    
      ----------    peer    ----------                                         

Device Configuration
--------------------
Root namespace with metadata-mode tunnel + BPF
Device names and addresses:

       veth1 IP: 172.16.1.200, IPv6: 00::22 (underlay)                         
       tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200 (overlay)              

Namespace at_ns0 with native tunnel
Device names and addresses:

       veth0 IPv4: 172.16.1.100, IPv6: 00::11 (underlay)                       
       tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100 (overlay)              

End-to-end ping packet flow
---------------------------
Most of the tests start by namespace creation, device configuration, then ping the underlay and overlay network. When doing 'ping 10.1.1.100' from root namespace, the following operations happen:
1) Route lookup shows 10.1.1.100/24 belongs to tnl dev, fwd to tnl dev.
2) Tnl device's egress BPF program is triggered and set the tunnel metadata,

    with remote_ip=172.16.1.200 and others.                                    

3) Outer tunnel header is prepended and route the packet to veth1's egress
4) veth0's ingress queue receive the tunneled packet at namespace at_ns0
5) Tunnel protocol handler, ex: vxlan_rcv, decap the packet
6) Forward the packet to the overlay tnl dev

Test Cases
-----------------------------
Tunnel Type | BPF Programs
-----------------------------

 GRE:          gre_set_tunnel, gre_get_tunnel
 IP6GRE:       ip6gretap_set_tunnel, ip6gretap_get_tunnel
 ERSPAN:       erspan_set_tunnel, erspan_get_tunnel
 IP6ERSPAN:    ip4ip6erspan_set_tunnel, ip4ip6erspan_get_tunnel
 VXLAN:        vxlan_set_tunnel, vxlan_get_tunnel
 IP6VXLAN:     ip6vxlan_set_tunnel, ip6vxlan_get_tunnel
 GENEVE:       geneve_set_tunnel, geneve_get_tunnel
 IP6GENEVE:    ip6geneve_set_tunnel, ip6geneve_get_tunnel
 IPIP:         ipip_set_tunnel, ipip_get_tunnel
 IP6IP:        ipip6_set_tunnel, ipip6_get_tunnel,
Quoted 2 lines

ip6ip6_set_tunnel, ip6ip6_get_tunnel
XFRM: xfrm_get_state

Applied yesterday night to bpf-next (and now in net-next), thanks William!