[ovs-dev] [PATCHv2 5/5] kmod-traffic: Add basic vxlan tunnel sanity test.

Joe Stringer joestringer at nicira.com
Wed Aug 12 21:01:30 UTC 2015


This test is skipped if the 'ip' command cannot interpret the vxlan 'dstport'
option; this is used as a proxy for detecting native kernel support for this
tunnel type.

Signed-off-by: Joe Stringer <joestringer at nicira.com>
---
This initial sanity test uses a linux device tunnel in combination with an
OVS-based tunnel, so I think it is reasonable to limit its operation to newer
kernels and distributions with newer iptools. In future it would also be good
to have tests which use two OVS tunnel endpoints which could be run on any
kernel version and with the userspace datapath as well.
---
 tests/system-common-macros.at | 38 ++++++++++++++++++++++++++++++++++++++
 tests/system-kmod-macros.at   | 10 ++++++++--
 tests/system-traffic.at       | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at
index 11b29fc..91792af 100644
--- a/tests/system-common-macros.at
+++ b/tests/system-common-macros.at
@@ -76,6 +76,44 @@ m4_define([ADD_VLAN],
     ]
 )
 
+# ADD_OVS_TUNNEL([type], [bridge], [port], [remote-addr], [overlay-addr])
+#
+# Add an ovs-based tunnel device in the root namespace, with name 'port' and
+# type 'type'. The tunnel device will be configured as point-to-point with the
+# 'remote-addr' as the underlay address of the remote tunnel endpoint.
+#
+# 'port will be configured with the address 'overlay-addr'.
+#
+m4_define([ADD_OVS_TUNNEL],
+   [AT_CHECK([ovs-vsctl add-port $2 $3 -- \
+              set int $3 type=$1 options:remote_ip=$4])
+    AT_CHECK([ip addr add dev $2 $5])
+    AT_CHECK([ip link set dev $2 up])
+    AT_CHECK([ip link set dev $2 mtu 1450])
+    ON_EXIT([ip addr del dev $2 $5])
+   ]
+)
+
+# ADD_NATIVE_TUNNEL([type], [port], [namespace], [remote-addr], [overlay-addr],
+#                   [link-args])
+#
+# Add a native tunnel device within 'namespace', with name 'port' and type
+# 'type'. The tunnel device will be configured as point-to-point with the
+# 'remote-addr' as the underlay address of the remote tunnel endpoint (as
+# viewed from the perspective of that namespace).
+#
+# 'port' will be configured with the address 'overlay-addr'. 'link-args' is
+# made available so that additional arguments can be passed to "ip link",
+# for instance to configure the vxlan destination port.
+#
+m4_define([ADD_NATIVE_TUNNEL],
+   [NS_CHECK_EXEC([$3], [ip link add dev $2 type $1 remote $4 $6])
+    NS_CHECK_EXEC([$3], [ip addr add dev $2 $5])
+    NS_CHECK_EXEC([$3], [ip link set dev $2 up])
+    NS_CHECK_EXEC([$3], [ip link set dev $2 mtu 1450])
+   ]
+)
+
 # FORMAT_PING([])
 #
 # Strip variant pieces from ping output so the output can be reliably compared.
diff --git a/tests/system-kmod-macros.at b/tests/system-kmod-macros.at
index 2e2bf4e..5fab7b7 100644
--- a/tests/system-kmod-macros.at
+++ b/tests/system-kmod-macros.at
@@ -13,9 +13,15 @@ m4_define([_ADD_BR], [[add-br $1]])
 # output (e.g. because it includes "create" commands) then 'vsctl-output'
 # specifies the expected output after filtering through uuidfilt.pl.
 #
+# Best-effort loading of all available vport modules is performed.
+#
 m4_define([OVS_TRAFFIC_VSWITCHD_START],
-  [ AT_CHECK([modprobe openvswitch])
-    ON_EXIT([modprobe -r openvswitch])
+  [AT_CHECK([modprobe openvswitch])
+   ON_EXIT([modprobe -r openvswitch])
+   m4_foreach([mod], [[vport_geneve], [vport_gre], [vport_lisp], [vport_stt], [vport_vxlan]],
+              [modprobe -q mod || echo "Module mod not loaded."
+               ON_EXIT([modprobe -q -r mod])])
+   ON_EXIT([ovs-dpctl del-dp ovs-system])
    _OVS_VSWITCHD_START([])
    dnl Add bridges, ports, etc.
    AT_CHECK([ovs-vsctl -- _ADD_BR([br0]) -- set bridge br0 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15]] fail-mode=secure -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2])
diff --git a/tests/system-traffic.at b/tests/system-traffic.at
index 8324480..7dbed68 100644
--- a/tests/system-traffic.at
+++ b/tests/system-traffic.at
@@ -101,3 +101,41 @@ NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PI
 
 OVS_TRAFFIC_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([datapath - ping over vxlan tunnel])
+AT_SKIP_IF([! ip link add foo type vxlan help 2>&1 | grep dstport >/dev/null])
+
+OVS_TRAFFIC_VSWITCHD_START(
+   [set-fail-mode br0 standalone -- ])
+ADD_BR([br-underlay], [set-fail-mode br-underlay standalone])
+ADD_NAMESPACES(at_ns0)
+
+dnl Set up underlay link from host into the namespace using veth pair.
+ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24")
+AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"])
+AT_CHECK([ip link set dev br-underlay up])
+
+dnl Set up tunnel endpoints on OVS outside the namespace and with a native
+dnl linux device inside the namespace.
+ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24])
+ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24],
+                  [id 0 dstport 4789])
+
+dnl First, check the underlay
+NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+])
+
+dnl Okay, now check the overlay with different packet sizes
+NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+])
+NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+])
+NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+])
+
+OVS_TRAFFIC_VSWITCHD_STOP
+AT_CLEANUP
-- 
2.1.4




More information about the dev mailing list