[ovs-dev] [PATCH 3/3] tests: Add basic vxlan tunnel sanity test.

Joe Stringer joestringer at nicira.com
Wed Jul 29 23:52:36 UTC 2015


Signed-off-by: Joe Stringer <joestringer at nicira.com>
---
 tests/kmod-macros.at  | 20 ++++++++++++++++++++
 tests/kmod-traffic.at | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)

diff --git a/tests/kmod-macros.at b/tests/kmod-macros.at
index 3487c67..be3c123 100644
--- a/tests/kmod-macros.at
+++ b/tests/kmod-macros.at
@@ -87,3 +87,23 @@ m4_define([ADD_VLAN],
       AT_CHECK([ip netns exec $2 ip addr add dev $1.$3 $4])
     ]
 )
+
+# ADD_NATIVE_TUNNEL([type], [port], [namespace], [local-addr], [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
+# 'local-addr' address configured as the underlay address within 'namespace',
+# and 'remote-addr' as the underlay address of the remote destination (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],
+    [ AT_CHECK([ip netns exec $3 ip link add dev $2 type $1 local $4 remote $5 $7])
+      AT_CHECK([ip netns exec $3 ip addr add dev $2 $6])
+      AT_CHECK([ip netns exec $3 ip link set dev $2 up])
+      AT_CHECK([ip netns exec $3 ip link set dev $2 mtu 1450])
+    ]
+)
diff --git a/tests/kmod-traffic.at b/tests/kmod-traffic.at
index 9df8b62..169078d 100644
--- a/tests/kmod-traffic.at
+++ b/tests/kmod-traffic.at
@@ -105,3 +105,52 @@ AT_CHECK([cat ping.output | grep "transmitted" | sed 's/time.*ms$/time 0ms/'], [
 
 OVS_KMOD_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([kmod - ping over vxlan tunnel])
+AT_SKIP_IF([! ip link help 2>&1 | grep vxlan >/dev/null])
+
+OVS_KMOD_VSWITCHD_START(
+   [set-fail-mode br0 standalone --])
+dnl Ensure that vport_* can be removed on exit.
+ON_EXIT([modprobe -r vport_vxlan])
+ON_EXIT([ovs-dpctl del-dp ovs-system])
+
+ADD_NAMESPACES(at_ns0)
+
+dnl Set up underlay link from host into the namespace using veth pair.
+AT_CHECK([ip link add p0 type veth peer name host-p0])
+AT_CHECK([ip addr add dev host-p0 "172.31.1.100/24"])
+AT_CHECK([ip link set dev host-p0 up])
+AT_CHECK([ip link set p0 netns at_ns0])
+AT_CHECK([ip netns exec at_ns0 ip addr add dev p0 "172.31.1.1/24"])
+AT_CHECK([ip netns exec at_ns0 ip link set dev p0 up])
+
+dnl Set up remote end of tunnel inside the namespace.
+ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.1], [172.31.1.100],
+    [10.1.1.1/24], [id 0 dstport 4789])
+
+dnl Set up local end of tunnel in default namespace.
+AT_CHECK([ovs-vsctl add-port br0 vxlan0 -- \
+    set int vxlan0 type=vxlan options:remote_ip=172.31.1.1])
+AT_CHECK([ip addr add dev br0 10.1.1.100/24])
+AT_CHECK([ip link set dev br0 up])
+AT_CHECK([ip link set dev br0 mtu 1450])
+
+AT_CAPTURE_FILE([ping.output])
+dnl First, check the underlay
+AT_CHECK([ip netns exec at_ns0 bash -c "ping -q -c 3 -i 0.3 -w 2 172.31.1.100 > ping.output"])
+
+dnl Okay, now check the overlay with different packet sizes
+AT_CHECK([ip netns exec at_ns0 bash -c "ping -q -c 3 -i 0.3 -w 2 10.1.1.100 >> ping.output"])
+AT_CHECK([ip netns exec at_ns0 bash -c "ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 >> ping.output"])
+AT_CHECK([ip netns exec at_ns0 bash -c "ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 >> ping.output"])
+
+AT_CHECK([cat ping.output | grep "transmitted" | sed 's/time.*ms$/time 0ms/'], [0], [dnl
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+])
+
+OVS_KMOD_VSWITCHD_STOP
+AT_CLEANUP
-- 
2.1.4




More information about the dev mailing list