From: Joe Stringer Date: Wed, 12 Aug 2015 21:01:30 +0000 (-0700) Subject: system-traffic: Add basic vxlan tunnel sanity test. X-Git-Tag: v2.5.0~722 X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=810e178585cab3f96fdd3c8cbf0ea23a3f9f9ef3;hp=5390d18598e9eff8925d577655a703a42d417d70;p=cascardo%2Fovs.git system-traffic: Add basic vxlan tunnel sanity test. 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 Acked-by: Daniele Di Proietto --- diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at index 8144db98b..2761c088a 100644 --- a/tests/system-common-macros.at +++ b/tests/system-common-macros.at @@ -75,6 +75,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 2e2bf4ee8..5fab7b7f0 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 83244801f..7dbed68d8 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