cfm: Prevent interval fault when demand mode is enabled on one end.
authoralex wang <alexw@nicira.com>
Fri, 20 Sep 2013 06:13:33 +0000 (06:13 +0000)
committerEthan Jackson <ethan@nicira.com>
Fri, 20 Sep 2013 00:49:14 +0000 (17:49 -0700)
This commit prevents cfm from raising 'interval' fault when demand
mode is only enabled on one end of link.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
lib/cfm.c
tests/automake.mk
tests/cfm.at [new file with mode: 0644]
tests/testsuite.at
vswitchd/vswitch.xml

index 4a46c05..e1866ff 100644 (file)
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -255,9 +255,13 @@ cfm_fault_interval(struct cfm *cfm) OVS_REQUIRES(mutex)
      * as a fault (likely due to a configuration error).  Thus we can check all
      * MPs at once making this quite a bit simpler.
      *
-     * According to the specification we should check when (ccm_interval_ms *
-     * 3.5)ms have passed. */
-    return (cfm->ccm_interval_ms * 7) / 2;
+     * When cfm is not in demand mode, we check when (ccm_interval_ms * 3.5) ms
+     * have passed.  When cfm is in demand mode, we check when
+     * (MAX(ccm_interval_ms, 500) * 3.5) ms have passed.  This ensures that
+     * ovs-vswitchd has enough time to pull statistics from the datapath. */
+
+    return (MAX(cfm->ccm_interval_ms, cfm->demand ? 500 : cfm->ccm_interval_ms)
+            * 7) / 2;
 }
 
 static uint8_t
@@ -611,7 +615,6 @@ cfm_configure(struct cfm *cfm, const struct cfm_settings *s)
     }
 
     if (s->extended && s->demand) {
-        interval_ms = MAX(interval_ms, 500);
         if (!cfm->demand) {
             cfm->demand = true;
             cfm->rx_packets = cfm_rx_packets(cfm);
index f531bf9..f15dcf5 100644 (file)
@@ -22,6 +22,7 @@ TESTSUITE_AT = \
        tests/odp.at \
        tests/multipath.at \
        tests/bfd.at \
+       tests/cfm.at \
        tests/lacp.at \
        tests/learn.at \
        tests/vconn.at \
diff --git a/tests/cfm.at b/tests/cfm.at
new file mode 100644 (file)
index 0000000..638e03f
--- /dev/null
@@ -0,0 +1,57 @@
+AT_BANNER([cfm])
+
+m4_define([CFM_CHECK_EXTENDED], [
+AT_CHECK([ovs-appctl cfm/show $1 | sed -e '/next CCM tx:/d' | sed -e '/next fault check:/d' | sed -e  '/recv since check:/d'],[0],
+[dnl
+---- $1 ----
+MPID $2: extended
+       average health: $3
+       opstate: $4
+       remote_opstate: $5
+       interval: $6
+Remote MPID $7
+       opstate: $8
+])
+])
+
+# test cfm under demand mode.
+AT_SETUP([cfm - demand mode])
+#Create 2 bridges connected by patch ports and enable BFD
+OVS_VSWITCHD_START([add-br br1 -- \
+                    set bridge br1 datapath-type=dummy \
+                    other-config:hwaddr=aa:55:aa:56:00:00 -- \
+                    add-port br1 p1 -- set Interface p1 type=patch \
+                    options:peer=p0 -- \
+                    add-port br0 p0 -- set Interface p0 type=patch \
+                    options:peer=p1 -- \
+                    set Interface p0 cfm_mpid=1 other_config:cfm_interval=300 other_config:cfm_extended=true -- \
+                    set Interface p1 cfm_mpid=2 other_config:cfm_interval=300 other_config:cfm_extended=true ])
+
+ovs-appctl time/stop
+# wait for a while to stablize cfm.
+for i in `seq 0 100`; do ovs-appctl time/warp 100; done
+CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
+CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
+
+# turn on demand mode on one end.
+AT_CHECK([ovs-vsctl set interface p0 other_config:cfm_demand=true])
+
+# cfm should never go down.
+for i in `seq 0 100`
+do
+    ovs-appctl time/warp 100
+    CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
+    CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
+done
+
+# turn on demand mode on the other end.
+AT_CHECK([ovs-vsctl set interface p1 other_config:cfm_demand=true])
+for i in `seq 0 100`
+do
+    ovs-appctl time/warp 100
+    CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
+    CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
+done
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
index c9bcad9..9f261a1 100644 (file)
@@ -68,6 +68,7 @@ m4_include([tests/ovsdb-macros.at])
 m4_include([tests/ofproto-macros.at])
 
 m4_include([tests/bfd.at])
+m4_include([tests/cfm.at])
 m4_include([tests/lacp.at])
 m4_include([tests/library.at])
 m4_include([tests/heap.at])
index 4b42ec7..5fd5b3b 100644 (file)
           <ul>
             <li>
               To ensure that ovs-vswitchd has enough time to pull statistics
-              from the datapath, the minimum
-              <ref column="other_config" key="cfm_interval"/> is 500ms.
+              from the datapath, the fault detection interval is set to
+              3.5 * MAX(<ref column="other_config" key="cfm_interval"/>, 500)
+              ms.
             </li>
 
             <li>