[ovs-dev] [PATCH 2/3] ofproto-dpif-monitor: Add ofproto-dpif-monitor module.

Alex Wang alexw at nicira.com
Wed Sep 25 23:23:14 UTC 2013


This commit adds a new module ofproto-dpif-monitor in ofproto
directory.  This module is in charge of executing the periodic
functions of monitoring code (e.g. bfd and cfm).

Signed-off-by: Alex Wang <alexw at nicira.com>
---
 ofproto/automake.mk            |    2 +
 ofproto/ofproto-dpif-monitor.c |  182 ++++++++++++++++++++++++++++++++++++++++
 ofproto/ofproto-dpif-monitor.h |   31 +++++++
 ofproto/ofproto-dpif-xlate.c   |   56 ++++++++++++-
 ofproto/ofproto-dpif-xlate.h   |   17 +++-
 ofproto/ofproto-dpif.c         |   58 ++-----------
 tests/bfd.at                   |   23 ++---
 7 files changed, 306 insertions(+), 63 deletions(-)
 create mode 100644 ofproto/ofproto-dpif-monitor.c
 create mode 100644 ofproto/ofproto-dpif-monitor.h

diff --git a/ofproto/automake.mk b/ofproto/automake.mk
index 47ca1b8..432f083 100644
--- a/ofproto/automake.mk
+++ b/ofproto/automake.mk
@@ -28,6 +28,8 @@ ofproto_libofproto_a_SOURCES = \
 	ofproto/ofproto-dpif-ipfix.h \
 	ofproto/ofproto-dpif-mirror.c \
 	ofproto/ofproto-dpif-mirror.h \
+	ofproto/ofproto-dpif-monitor.c \
+	ofproto/ofproto-dpif-monitor.h \
 	ofproto/ofproto-dpif-sflow.c \
 	ofproto/ofproto-dpif-sflow.h \
 	ofproto/ofproto-dpif-upcall.c \
diff --git a/ofproto/ofproto-dpif-monitor.c b/ofproto/ofproto-dpif-monitor.c
new file mode 100644
index 0000000..e76dac6
--- /dev/null
+++ b/ofproto/ofproto-dpif-monitor.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <config.h>
+#include "ofproto-dpif-monitor.h"
+
+#include "bfd.h"
+#include "cfm.h"
+#include "hash.h"
+#include "hmap.h"
+#include "ofpbuf.h"
+#include "ofproto-dpif.h"
+#include "ofproto-dpif-xlate.h"
+#include "util.h"
+#include "vlog.h"
+
+VLOG_DEFINE_THIS_MODULE(ofproto_dpif_monitor);
+
+struct xport;
+
+/* Monitor struct. */
+struct monitor {
+    struct hmap hmap;        /* hmap that contains all port monitors. */
+};
+
+/* Monitored port.  It has reference to xport. */
+struct mport {
+    struct hmap_node hmap_node;       /* In monitor's hmap. */
+    const struct xport *xport;        /* The corresponding xport. */
+};
+
+static struct monitor monitor;
+
+static void ofproto_dpif_monitor_init(void);
+static struct mport *mport_find(const struct xport *)
+    OVS_REQ_WRLOCK(xlate_rwlock);
+
+/* Initializes the monitor struct.  The init function can only be
+ * called once. */
+static void
+ofproto_dpif_monitor_init(void) {
+    static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+
+    if (ovsthread_once_start(&once)) {
+        hmap_init(&monitor.hmap);
+        ovsthread_once_done(&once);
+    }
+}
+
+/* Tries finding and returning the 'mport' from the monitor's hash map.
+ * If there is no such 'mport', returns NULL. */
+static struct mport *
+mport_find(const struct xport *xport) OVS_REQ_WRLOCK(xlate_rwlock)
+{
+    struct mport *mport = NULL;
+    struct mport *node;
+
+    HMAP_FOR_EACH_WITH_HASH (node, hmap_node, hash_pointer(xport, 0),
+                             &monitor.hmap) {
+        if (node->xport == xport) {
+            mport = node;
+            break;
+        }
+    }
+    return mport;
+}
+
+
+/* Creates a new mport and inserts it into monitor.hmap. */
+void
+ofproto_dpif_monitor_mport_create(const struct xport *xport)
+{
+    struct mport *mport = mport_find(xport);
+    if (!mport) {
+        mport = xmalloc(sizeof *mport);
+        mport->xport = xport;
+        hmap_insert(&monitor.hmap, &mport->hmap_node, hash_pointer(xport, 0));
+    }
+}
+
+/* Removes mport from monitor's hmap and frees it. */
+void
+ofproto_dpif_monitor_mport_delete(const struct xport *xport)
+{
+    struct mport *mport = mport_find(xport);
+    if (mport) {
+        hmap_remove(&monitor.hmap, &mport->hmap_node);
+        free(mport);
+    }
+}
+
+/* Checks the sending of control packets on all mports.  Sends the control
+ * packets if needed. */
+void
+ofproto_dpif_monitor_run_fast(void)
+{
+    struct mport *mport;
+
+    ofproto_dpif_monitor_init();
+
+    ovs_rwlock_rdlock(&xlate_rwlock);
+    HMAP_FOR_EACH (mport, hmap_node, &monitor.hmap) {
+        struct monitor_info *info = xlate_get_monitor_info(mport->xport);
+
+        if (info->cfm && cfm_should_send_ccm(info->cfm)) {
+            struct ofpbuf packet;
+
+            ofpbuf_init(&packet, 0);
+            cfm_compose_ccm(info->cfm, &packet, info->hw_addr);
+            ofproto_dpif_send_packet(info->ofport, &packet);
+            ofpbuf_uninit(&packet);
+        }
+        if (info->bfd && bfd_should_send_packet(info->bfd)) {
+            struct ofpbuf packet;
+
+            ofpbuf_init(&packet, 0);
+            bfd_put_packet(info->bfd, &packet, info->hw_addr);
+            ofproto_dpif_send_packet(info->ofport, &packet);
+            ofpbuf_uninit(&packet);
+        }
+        xlate_clear_monitor_info(info);
+    }
+    ovs_rwlock_unlock(&xlate_rwlock);
+}
+
+/* Executes bfd_run(), cfm_run() on all mports. */
+void
+ofproto_dpif_monitor_run(void)
+{
+    struct mport *mport;
+
+    ofproto_dpif_monitor_init();
+    ovs_rwlock_rdlock(&xlate_rwlock);
+    HMAP_FOR_EACH (mport, hmap_node, &monitor.hmap) {
+        struct monitor_info *info = xlate_get_monitor_info(mport->xport);
+
+        if (info->cfm) {
+            cfm_run(info->cfm);
+        }
+        if (info->bfd) {
+            bfd_run(info->bfd);
+        }
+        xlate_clear_monitor_info(info);
+    }
+    ovs_rwlock_unlock(&xlate_rwlock);
+}
+
+/* Executes the bfd_wait() and cfm_wait() functions on all mports. */
+void
+ofproto_dpif_monitor_wait(void)
+{
+    struct mport *mport;
+
+    ofproto_dpif_monitor_init();
+
+    ovs_rwlock_rdlock(&xlate_rwlock);
+    HMAP_FOR_EACH (mport, hmap_node, &monitor.hmap) {
+        struct monitor_info *info = xlate_get_monitor_info(mport->xport);
+
+        if (info->cfm) {
+            cfm_wait(info->cfm);
+        }
+        if (info->bfd) {
+            bfd_wait(info->bfd);
+        }
+        xlate_clear_monitor_info(info);
+    }
+    ovs_rwlock_unlock(&xlate_rwlock);
+}
diff --git a/ofproto/ofproto-dpif-monitor.h b/ofproto/ofproto-dpif-monitor.h
new file mode 100644
index 0000000..44f2ab6
--- /dev/null
+++ b/ofproto/ofproto-dpif-monitor.h
@@ -0,0 +1,31 @@
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. */
+
+#ifndef OFPROTO_DPIF_MONITOR_H
+#define OFPROTO_DPIF_MONITOR_H 1
+
+#include "compiler.h"
+
+struct xport;
+
+extern struct ovs_rwlock xlate_rwlock;
+
+void ofproto_dpif_monitor_run(void);
+void ofproto_dpif_monitor_run_fast(void);
+void ofproto_dpif_monitor_wait(void);
+
+void ofproto_dpif_monitor_mport_create(const struct xport *) OVS_REQ_WRLOCK(xlate_rwlock);
+void ofproto_dpif_monitor_mport_delete(const struct xport *) OVS_REQ_WRLOCK(xlate_rwlock);
+
+#endif /* ofproto-dpif-monitor.h */
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index bb160b5..fcad832 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -42,6 +42,7 @@
 #include "ofp-actions.h"
 #include "ofproto/ofproto-dpif-ipfix.h"
 #include "ofproto/ofproto-dpif-mirror.h"
+#include "ofproto/ofproto-dpif-monitor.h"
 #include "ofproto/ofproto-dpif-sflow.h"
 #include "ofproto/ofproto-dpif.h"
 #include "ofproto/ofproto-provider.h"
@@ -131,6 +132,8 @@ struct xport {
 
     struct cfm *cfm;                 /* CFM handle or null. */
     struct bfd *bfd;                 /* BFD handle or null. */
+
+    uint8_t *hw_addr;                /* Hardware address. */
 };
 
 struct xlate_ctx {
@@ -189,6 +192,12 @@ static struct hmap xbridges = HMAP_INITIALIZER(&xbridges);
 static struct hmap xbundles = HMAP_INITIALIZER(&xbundles);
 static struct hmap xports = HMAP_INITIALIZER(&xports);
 
+/* Since there will be only one monitor thread.  This is
+ * thread safe. */
+static struct monitor_info info;
+
+static void monitor_update(const struct xport *) OVS_REQ_WRLOCK(xlate_rwlock);
+
 static bool may_receive(const struct xport *, struct xlate_ctx *);
 static void do_xlate_actions(const struct ofpact *, size_t ofpacts_len,
                              struct xlate_ctx *);
@@ -372,10 +381,11 @@ xlate_ofport_set(struct ofproto_dpif *ofproto, struct ofbundle *ofbundle,
                  struct ofport_dpif *peer, int stp_port_no,
                  const struct ofproto_port_queue *qdscp_list, size_t n_qdscp,
                  enum ofputil_port_config config, bool is_tunnel,
-                 bool may_enable)
+                 uint8_t *hw_addr, bool may_enable)
 {
     struct xport *xport = xport_lookup(ofport);
     size_t i;
+    bool update_monitor = false;
 
     if (!xport) {
         xport = xzalloc(sizeof *xport);
@@ -396,6 +406,7 @@ xlate_ofport_set(struct ofproto_dpif *ofproto, struct ofbundle *ofbundle,
     xport->is_tunnel = is_tunnel;
     xport->may_enable = may_enable;
     xport->odp_port = odp_port;
+    xport->hw_addr = hw_addr;
 
     if (xport->netdev != netdev) {
         netdev_close(xport->netdev);
@@ -405,11 +416,13 @@ xlate_ofport_set(struct ofproto_dpif *ofproto, struct ofbundle *ofbundle,
     if (xport->cfm != cfm) {
         cfm_unref(xport->cfm);
         xport->cfm = cfm_ref(cfm);
+        update_monitor = true;
     }
 
     if (xport->bfd != bfd) {
         bfd_unref(xport->bfd);
         xport->bfd = bfd_ref(bfd);
+        update_monitor = true;
     }
 
     if (xport->peer) {
@@ -428,6 +441,10 @@ xlate_ofport_set(struct ofproto_dpif *ofproto, struct ofbundle *ofbundle,
         list_insert(&xport->xbundle->xports, &xport->bundle_node);
     }
 
+    /* Updates the monitor hmap. */
+    if (update_monitor) {
+        monitor_update(xport);
+    }
     clear_skb_priorities(xport);
     for (i = 0; i < n_qdscp; i++) {
         struct skb_priority_to_dscp *pdscp;
@@ -472,10 +489,47 @@ xlate_ofport_remove(struct ofport_dpif *ofport)
 
     netdev_close(xport->netdev);
     cfm_unref(xport->cfm);
+    xport->cfm = NULL;
     bfd_unref(xport->bfd);
+    xport->bfd = NULL;
+    /* Remove xport from monitor hmap. */
+    monitor_update(xport);
     free(xport);
 }
 
+/* Creates the mport in monitor module if either bfd or cfm
+ * is configured.  Otherwise, deletes the mport. */
+static void
+monitor_update(const struct xport *xport) OVS_REQ_WRLOCK(xlate_rwlock)
+{
+    if (!xport->cfm && !xport->bfd) {
+        ofproto_dpif_monitor_mport_delete(xport);
+    } else {
+        ofproto_dpif_monitor_mport_create(xport);
+    }
+}
+
+/* Returns a monitor_info struct. */
+struct monitor_info*
+xlate_get_monitor_info(const struct xport *xport)
+{
+    info.ofport = xport->ofport;
+    info.bfd = bfd_ref(xport->bfd);
+    info.cfm = cfm_ref(xport->cfm);
+    info.hw_addr = xport->hw_addr;
+    return &info;
+}
+
+/* Unref the bfd/cfm references in monitor_info struct. */
+void
+xlate_clear_monitor_info(struct monitor_info *info)
+{
+    if (info) {
+        bfd_unref(info->bfd);
+        cfm_ref(info->cfm);
+    }
+}
+
 /* Given a datpath, packet, and flow metadata ('backer', 'packet', and 'key'
  * respectively), populates 'flow' with the result of odp_flow_key_to_flow().
  * Optionally, if nonnull, populates 'fitnessp' with the fitness of 'flow' as
diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h
index 98c0746..f60aa02 100644
--- a/ofproto/ofproto-dpif-xlate.h
+++ b/ofproto/ofproto-dpif-xlate.h
@@ -15,6 +15,8 @@
 #ifndef OFPROTO_DPIF_XLATE_H
 #define OFPROTO_DPIF_XLATE_H 1
 
+#include <stdint.h>
+
 #include "flow.h"
 #include "meta-flow.h"
 #include "odp-util.h"
@@ -26,11 +28,13 @@
 
 struct bfd;
 struct bond;
+struct cfm;
 struct dpif;
 struct lacp;
 struct dpif_ipfix;
 struct dpif_sflow;
 struct mac_learning;
+struct xport;
 
 struct xlate_out {
     /* Wildcards relevant in translation.  Any fields that were used to
@@ -114,6 +118,16 @@ struct xlate_in {
 
 extern struct ovs_rwlock xlate_rwlock;
 
+/* Information used by monitor module. */
+struct monitor_info {
+    struct ofport_dpif *ofport;
+    struct bfd *bfd;
+    struct cfm *cfm;
+    uint8_t *hw_addr;
+};
+struct monitor_info *xlate_get_monitor_info(const struct xport *) OVS_REQ_RDLOCK(xlate_rwlock);
+void xlate_clear_monitor_info(struct monitor_info *) OVS_REQ_RDLOCK(xlate_rwlock);
+
 void xlate_ofproto_set(struct ofproto_dpif *, const char *name,
                        struct dpif *, struct rule_dpif *miss_rule,
                        struct rule_dpif *no_packet_in_rule,
@@ -137,7 +151,8 @@ void xlate_ofport_set(struct ofproto_dpif *, struct ofbundle *,
                       const struct bfd *, struct ofport_dpif *peer,
                       int stp_port_no, const struct ofproto_port_queue *qdscp,
                       size_t n_qdscp, enum ofputil_port_config, bool is_tunnel,
-                      bool may_enable) OVS_REQ_WRLOCK(xlate_rwlock);
+                      uint8_t *hw_addr, bool may_enable)
+                      OVS_REQ_WRLOCK(xlate_rwlock);
 void xlate_ofport_remove(struct ofport_dpif *) OVS_REQ_WRLOCK(xlate_rwlock);
 
 int xlate_receive(const struct dpif_backer *, struct ofpbuf *packet,
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 44f5fbf..038b701 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -52,6 +52,7 @@
 #include "ofproto-dpif-governor.h"
 #include "ofproto-dpif-ipfix.h"
 #include "ofproto-dpif-mirror.h"
+#include "ofproto-dpif-monitor.h"
 #include "ofproto-dpif-sflow.h"
 #include "ofproto-dpif-upcall.h"
 #include "ofproto-dpif-xlate.h"
@@ -360,8 +361,6 @@ ofport_dpif_cast(const struct ofport *ofport)
 }
 
 static void port_run(struct ofport_dpif *);
-static void port_run_fast(struct ofport_dpif *);
-static void port_wait(struct ofport_dpif *);
 static int set_bfd(struct ofport *, const struct smap *);
 static int set_cfm(struct ofport *, const struct cfm_settings *);
 static void ofport_update_peer(struct ofport_dpif *);
@@ -817,7 +816,7 @@ type_run(const char *type)
                                  ofport->bfd, ofport->peer, stp_port,
                                  ofport->qdscp, ofport->n_qdscp,
                                  ofport->up.pp.config, ofport->is_tunnel,
-                                 ofport->may_enable);
+                                 ofport->up.pp.hw_addr, ofport->may_enable);
             }
             ovs_rwlock_unlock(&xlate_rwlock);
 
@@ -1449,7 +1448,6 @@ run_fast(struct ofproto *ofproto_)
 {
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
     struct ofputil_packet_in *pin, *next_pin;
-    struct ofport_dpif *ofport;
     struct list pins;
 
     /* Do not perform any periodic activity required by 'ofproto' while
@@ -1466,10 +1464,7 @@ run_fast(struct ofproto *ofproto_)
         free(pin);
     }
 
-    HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
-        port_run_fast(ofport);
-    }
-
+    ofproto_dpif_monitor_run_fast();
     return 0;
 }
 
@@ -1511,6 +1506,9 @@ run(struct ofproto *ofproto_)
         dpif_ipfix_run(ofproto->ipfix);
     }
 
+    ofproto_dpif_monitor_run_fast();
+    ofproto_dpif_monitor_run();
+
     HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
         port_run(ofport);
     }
@@ -1555,7 +1553,6 @@ static void
 wait(struct ofproto *ofproto_)
 {
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
-    struct ofport_dpif *ofport;
     struct ofbundle *bundle;
 
     if (ofproto_get_flow_restore_wait()) {
@@ -1568,9 +1565,7 @@ wait(struct ofproto *ofproto_)
     if (ofproto->ipfix) {
         dpif_ipfix_wait(ofproto->ipfix);
     }
-    HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
-        port_wait(ofport);
-    }
+    ofproto_dpif_monitor_wait();
     HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
         bundle_wait(bundle);
     }
@@ -1977,7 +1972,6 @@ set_bfd(struct ofport *ofport_, const struct smap *cfg)
     if (ofport->bfd != old) {
         ofproto->backer->need_revalidate = REV_RECONFIGURE;
     }
-
     return 0;
 }
 
@@ -2863,28 +2857,6 @@ ofport_update_peer(struct ofport_dpif *ofport)
 }
 
 static void
-port_run_fast(struct ofport_dpif *ofport)
-{
-    if (ofport->cfm && cfm_should_send_ccm(ofport->cfm)) {
-        struct ofpbuf packet;
-
-        ofpbuf_init(&packet, 0);
-        cfm_compose_ccm(ofport->cfm, &packet, ofport->up.pp.hw_addr);
-        ofproto_dpif_send_packet(ofport, &packet);
-        ofpbuf_uninit(&packet);
-    }
-
-    if (ofport->bfd && bfd_should_send_packet(ofport->bfd)) {
-        struct ofpbuf packet;
-
-        ofpbuf_init(&packet, 0);
-        bfd_put_packet(ofport->bfd, &packet, ofport->up.pp.hw_addr);
-        ofproto_dpif_send_packet(ofport, &packet);
-        ofpbuf_uninit(&packet);
-    }
-}
-
-static void
 port_run(struct ofport_dpif *ofport)
 {
     long long int carrier_seq = netdev_get_carrier_resets(ofport->up.netdev);
@@ -2895,12 +2867,9 @@ port_run(struct ofport_dpif *ofport)
 
     ofport->carrier_seq = carrier_seq;
 
-    port_run_fast(ofport);
-
     if (ofport->cfm) {
         int cfm_opup = cfm_get_opup(ofport->cfm);
 
-        cfm_run(ofport->cfm);
         cfm_enable = !cfm_get_fault(ofport->cfm);
 
         if (cfm_opup >= 0) {
@@ -2909,7 +2878,6 @@ port_run(struct ofport_dpif *ofport)
     }
 
     if (ofport->bfd) {
-        bfd_run(ofport->bfd);
         bfd_enable = bfd_forwarding(ofport->bfd);
     }
 
@@ -2932,18 +2900,6 @@ port_run(struct ofport_dpif *ofport)
     ofport->may_enable = enable;
 }
 
-static void
-port_wait(struct ofport_dpif *ofport)
-{
-    if (ofport->cfm) {
-        cfm_wait(ofport->cfm);
-    }
-
-    if (ofport->bfd) {
-        bfd_wait(ofport->bfd);
-    }
-}
-
 static int
 port_query_by_name(const struct ofproto *ofproto_, const char *devname,
                    struct ofproto_port *ofproto_port)
diff --git a/tests/bfd.at b/tests/bfd.at
index 0b2b7cc..cc6755c 100644
--- a/tests/bfd.at
+++ b/tests/bfd.at
@@ -260,10 +260,16 @@ OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
 
 ovs-appctl time/stop
 
-# wait for local session state to go from down to up.
-for i in `seq 0 1`; do ovs-appctl time/warp 500; done
-BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [init], [No Diagnostic])
-
+# check which port sends the first bfd control packet.
+if [ ovs-appctl bfd/show p0 | grep "Remote Session State: init" ]
+then
+# if p0 sends first, it should have gone up already.
+    BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [init], [No Diagnostic])
+else
+# if p1 sends first, wait 1000ms for p0 to go up.
+    BFD_CHECK([p0], [false], [false], [none], [init], [No Diagnostic], [none], [down], [No Diagnostic])
+    for i in `seq 0 1`; do ovs-appctl time/warp 500; done
+fi
 
 # Test-1 BFD decay: decay to decay_min_rx
 # bfd:decay_min_rx is set to 3000ms after the local state of p0 goes up,
@@ -450,7 +456,7 @@ done
 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=3000 -- set interface p1 bfd:min_tx=5000])
 # there will be poll sequences from both sides. and it is hard to determine the
 # order. so just skip 10000ms and check the RX/TX. at that time, p0 should be in decay already.
-for i in `seq 0 19`; do echo $i; ovs-appctl bfd/show; ovs-appctl time/warp 500; done
+for i in `seq 0 19`; do ovs-appctl time/warp 500; done
 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
 BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
@@ -493,15 +499,12 @@ BFD_CHECK_RX([p0], [300ms], [300ms], [1ms])
 
 # resume the bfd on p1. the bfd should not go to decay mode direclty.
 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true])
-for i in `seq 0 1`; do ovs-appctl time/warp 500; done
-BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
+for i in `seq 0 3`; do ovs-appctl time/warp 500; done
 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
 
-# since the decay_min_rx is still 3000ms, so after 3000ms, there should be the decay and poll sequence.
+# since the decay_min_rx is still 3000ms, so after 3000ms, there should be the decay.
 for i in `seq 0 5`; do ovs-appctl time/warp 500; done
-BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [final], [up], [No Diagnostic])
-BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], [up], [Control Detection Time Expired])
 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
 # End of Test-8 ################################################################
-- 
1.7.9.5




More information about the dev mailing list