thread safety for netdev_pltap and netdev_tunnel
[sliver-openvswitch.git] / tests / bfd.at
index d95f8ab..fb8b1d3 100644 (file)
@@ -35,7 +35,6 @@ AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/RX Interval/p'],[0],
 ])
 ])
 AT_SETUP([bfd - basic config on different bridges])
-ovs-appctl time/stop
 #Create 2 bridges connected by patch ports and enable BFD
 OVS_VSWITCHD_START(
    [add-br br1 -- \
@@ -47,6 +46,7 @@ OVS_VSWITCHD_START(
        options:peer=p1 -- \
     set Interface p0 bfd:enable=true -- \
     set Interface p1 bfd:enable=true ])
+ovs-appctl time/stop
 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
 
 #Verify that BFD has been enabled on both interfaces.
@@ -82,7 +82,6 @@ AT_SETUP([bfd - Verify tunnel down detection])
 #interfaces in br-bfd0 and br-bfd1. When br-sw is dropping all packets, BFD should detect
 # that the tunnel is down, and come back up when br-sw is working fine.
 
-ovs-appctl time/stop
 OVS_VSWITCHD_START(
    [add-br br-bfd0 -- \
        set bridge br-bfd0 datapath-type=dummy \
@@ -102,6 +101,7 @@ OVS_VSWITCHD_START(
     add-port br-bfd0 p0 -- set Interface p0 type=patch \
        options:peer=p0-sw bfd:enable=true --])
 
+ovs-appctl time/stop
 
 #Create 2 bridges connected by patch ports and enable BFD
 
@@ -158,12 +158,11 @@ AT_CLEANUP
 
 AT_SETUP([bfd - concatenated path down])
 #Create 2 bridges connected by patch ports and enable BFD
-ovs-appctl time/stop
 OVS_VSWITCHD_START()
+ovs-appctl time/stop
 AT_CHECK([ ovs-vsctl -- add-br br1 -- \
            set bridge br1 datapath-type=dummy \
            other-config:hwaddr=aa:55:aa:56:00:00 ])
-ovs-appctl time/stop
 AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
            options:peer=p0 ])
 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
@@ -186,9 +185,8 @@ AT_CLEANUP
 
 AT_SETUP([bfd - Edit the Min Tx/Rx values])
 #Create 2 bridges connected by patch ports and enable BFD
-ovs-appctl time/stop
-ovs-appctl vlog/set bfd:dbg
 OVS_VSWITCHD_START()
+ovs-appctl time/stop
 AT_CHECK([ ovs-vsctl -- add-br br1 -- \
            set bridge br1 datapath-type=dummy ])
 AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
@@ -197,7 +195,7 @@ AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
            options:peer=p1 ])
 AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
 AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
-for i in `seq 0 20`; do ovs-appctl time/warp 100; done
+for i in `seq 0 30`; do ovs-appctl time/warp 100; done
 #Verify that BFD has been enabled on both interfaces.
 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
@@ -215,3 +213,37 @@ BFD_CHECK_RX([p0], [1000ms], [300ms])
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
+
+AT_SETUP([bfd - check_tnl_key])
+OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
+                    options:remote_ip=2.2.2.2 options:key=1 ofport_request=1 -- \
+                    set interface p1 bfd:enable=true -- \
+                    set bridge br0 fail-mode=standalone])
+
+# by default check_tnl_key is false. so we should process a bfd packet with tun_id=1.
+AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x1,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,flags(key)),in_port(1),skb_mark(0/0),eth(src=00:11:22:33:44:55,dst=00:23:20:00:00:01),eth_type(0x0800),ipv4(src=169.254.1.0/0.0.0.0,dst=169.254.1.1/0.0.0.0,proto=17/0xff,tos=0/0,ttl=255/0,frag=no/0xff),udp(src=49152/0,dst=3784/0xffff)' -generate], [0], [stdout])
+# check that the packet should be handled as BFD packet.
+AT_CHECK([tail -2 stdout], [0], [dnl
+This flow is handled by the userspace slow path because it:
+       - Consists of BFD packets.
+], [])
+
+# turn on the check_tnl_key.
+AT_CHECK([ovs-vsctl set interface p1 bfd:check_tnl_key=true])
+AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x1,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,flags(key)),in_port(1),skb_mark(0/0),eth(src=00:11:22:33:44:55,dst=00:23:20:00:00:01),eth_type(0x0800),ipv4(src=169.254.1.0/0.0.0.0,dst=169.254.1.1/0.0.0.0,proto=17/0xff,tos=0/0,ttl=255/0,frag=no/0xff),udp(src=49152/0,dst=3784/0xffff)' -generate], [0], [stdout])
+# check that the packet should be handled as normal packet.
+AT_CHECK([tail -1 stdout], [0],[dnl
+Datapath actions: 100
+], [])
+
+# set the tunnel key to 0.
+AT_CHECK([ovs-vsctl set interface p1 options:key=0])
+AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x0,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,flags(key)),in_port(1),skb_mark(0/0),eth(src=00:11:22:33:44:55,dst=00:23:20:00:00:01),eth_type(0x0800),ipv4(src=169.254.1.0/0.0.0.0,dst=169.254.1.1/0.0.0.0,proto=17/0xff,tos=0/0,ttl=255/0,frag=no/0xff),udp(src=49152/0,dst=3784/0xffff)' -generate], [0], [stdout])
+# check that the packet should be handled as BFD packet.
+AT_CHECK([tail -2 stdout], [0], [dnl
+This flow is handled by the userspace slow path because it:
+       - Consists of BFD packets.
+], [])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP