In some cases, a controller may want to take an interface down for
forwarding purposes, but avoid completely deconfiguring CFM and
thus lose all connectivity monitoring.  The new 'cfm_opdown'
setting is a way to achieve this behavior.
---
 lib/cfm.c              |   62 +++++++++++++++++++++++++++++++++++++-----------
 lib/cfm.h              |    2 +
 ofproto/ofproto-dpif.c |    3 +-
 vswitchd/bridge.c      |    5 +++-
 vswitchd/vswitch.xml   |   10 +++++++
 5 files changed, 66 insertions(+), 16 deletions(-)

diff --git a/lib/cfm.c b/lib/cfm.c
index bb20572..47eeb75 100644
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -66,7 +66,8 @@ struct ccm {
     /* Defined by ITU-T Y.1731 should be zero */
     ovs_be16 interval_ms_x;      /* Transmission interval in ms. */
     ovs_be64 mpid64;             /* MPID in extended mode. */
-    uint8_t  zero[6];
+    uint8_t opdown;              /* Operationally down. */
+    uint8_t  zero[5];
 } __attribute__((packed));
 BUILD_ASSERT_DECL(CCM_LEN == sizeof(struct ccm));
 
@@ -78,6 +79,8 @@ struct cfm {
     bool extended;         /* Extended mode. */
     bool fault;            /* Indicates connectivity fault. */
     bool unexpected_recv;  /* Received an unexpected CCM. */
+    bool opdown;           /* Operationally down. */
+    bool remote_opdown;    /* Detected remote operationally down bit. */
 
     uint32_t seq;          /* The sequence number of our last CCM. */
     uint8_t ccm_interval;  /* The CCM transmission interval. */
@@ -104,6 +107,7 @@ struct remote_mp {
     bool recv;           /* CCM was received since last fault check. */
     bool rdi;            /* Remote Defect Indicator. Indicates remote_mp isn't
                             receiving CCMs that it's expecting to. */
+    bool opdown;         /* Operationally down. */
 };
 
 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
@@ -276,6 +280,7 @@ cfm_run(struct cfm *cfm)
         cfm->rmps_array = xmalloc(hmap_count(&cfm->remote_mps) *
                                   sizeof *cfm->rmps_array);
 
+        cfm->remote_opdown = false;
         HMAP_FOR_EACH_SAFE (rmp, rmp_next, node, &cfm->remote_mps) {
 
             if (!rmp->recv) {
@@ -298,6 +303,10 @@ cfm_run(struct cfm *cfm)
                     cfm->fault = true;
                 }
 
+                if (rmp->opdown) {
+                    cfm->remote_opdown = rmp->opdown;
+                }
+
                 cfm->rmps_array[cfm->rmps_array_len++] = rmp->mpid;
             }
         }
@@ -340,9 +349,11 @@ cfm_compose_ccm(struct cfm *cfm, struct ofpbuf *packet,
     if (cfm->extended) {
         ccm->mpid = htons(hash_mpid(cfm->mpid));
         ccm->mpid64 = htonll(cfm->mpid);
+        ccm->opdown = cfm->opdown;
     } else {
         ccm->mpid = htons(cfm->mpid);
         ccm->mpid64 = htonll(0);
+        ccm->opdown = 0;
     }
 
     if (cfm->ccm_interval == 0) {
@@ -375,6 +386,7 @@ cfm_configure(struct cfm *cfm, const struct cfm_settings *s)
 
     cfm->mpid = s->mpid;
     cfm->extended = s->extended;
+    cfm->opdown = s->opdown;
     interval = ms_to_ccm_interval(s->interval);
     interval_ms = ccm_interval_to_ms(interval);
 
@@ -446,8 +458,15 @@ cfm_process_heartbeat(struct cfm *cfm, const struct ofpbuf 
*p)
 
         struct remote_mp *rmp;
         uint64_t ccm_mpid;
+        bool ccm_opdown;
 
-        ccm_mpid = cfm->extended ? ntohll(ccm->mpid64) : ntohs(ccm->mpid);
+        if (cfm->extended) {
+            ccm_mpid = ntohll(ccm->mpid64);
+            ccm_opdown = ccm->opdown;
+        } else {
+            ccm_mpid = ntohs(ccm->mpid);
+            ccm_opdown = false;
+        }
 
         if (ccm_interval != cfm->ccm_interval) {
             VLOG_WARN_RL(&rl, "%s: received a CCM with an invalid interval"
@@ -463,20 +482,24 @@ cfm_process_heartbeat(struct cfm *cfm, const struct 
ofpbuf *p)
         }
 
         rmp = lookup_remote_mp(cfm, ccm_mpid);
+        if (!rmp) {
+            if (hmap_count(&cfm->remote_mps) < CFM_MAX_RMPS) {
+                rmp = xmalloc(sizeof *rmp);
+                hmap_insert(&cfm->remote_mps, &rmp->node, hash_mpid(ccm_mpid));
+            } else {
+                cfm->unexpected_recv = true;
+                VLOG_WARN_RL(&rl,
+                             "%s: dropped CCM with MPID %"PRIu64" from MAC "
+                             ETH_ADDR_FMT, cfm->name, ccm_mpid,
+                             ETH_ADDR_ARGS(eth->eth_src));
+            }
+        }
+
         if (rmp) {
-            rmp->recv = true;
-            rmp->rdi = ccm_rdi;
-        } else if (hmap_count(&cfm->remote_mps) < CFM_MAX_RMPS) {
-            rmp = xmalloc(sizeof *rmp);
             rmp->mpid = ccm_mpid;
             rmp->recv = true;
             rmp->rdi = ccm_rdi;
-            hmap_insert(&cfm->remote_mps, &rmp->node, hash_mpid(rmp->mpid));
-        } else {
-            cfm->unexpected_recv = true;
-            VLOG_WARN_RL(&rl, "%s: dropped CCM with MPID %"PRIu64" from MAC "
-                         ETH_ADDR_FMT, cfm->name, ccm_mpid,
-                         ETH_ADDR_ARGS(eth->eth_src));
+            rmp->opdown = ccm_opdown;
         }
 
         VLOG_DBG("%s: received CCM (seq %"PRIu32") (mpid %"PRIu64")"
@@ -493,6 +516,15 @@ cfm_get_fault(const struct cfm *cfm)
     return cfm->fault;
 }
 
+/* Gets the operationally down status of 'cfm'.  'cfm' is considered
+ * operationally down if it has received a CCM with the operationally down bit
+ * set from any of its remote maintenance points. */
+bool
+cfm_get_opdown(const struct cfm *cfm)
+{
+    return cfm->remote_opdown;
+}
+
 /* Populates 'rmps' with an array of remote maintenance points reachable by
  * 'cfm'. The number of remote maintenance points is written to 'n_rmps'.
  * 'cfm' retains ownership of the array written to 'rmps' */
@@ -523,9 +555,10 @@ cfm_print_details(struct ds *ds, const struct cfm *cfm)
     struct remote_mp *rmp;
 
     ds_put_format(ds, "---- %s ----\n", cfm->name);
-    ds_put_format(ds, "MPID %"PRIu64":%s%s%s\n", cfm->mpid,
+    ds_put_format(ds, "MPID %"PRIu64":%s%s%s%s\n", cfm->mpid,
                   cfm->extended ? " extended" : "",
                   cfm->fault ? " fault" : "",
+                  cfm->remote_opdown ? " remote_opdown" : "",
                   cfm->unexpected_recv ? " unexpected_recv" : "");
 
     ds_put_format(ds, "\tinterval: %dms\n", cfm->ccm_interval_ms);
@@ -535,8 +568,9 @@ cfm_print_details(struct ds *ds, const struct cfm *cfm)
                   timer_msecs_until_expired(&cfm->fault_timer));
 
     HMAP_FOR_EACH (rmp, node, &cfm->remote_mps) {
-        ds_put_format(ds, "Remote MPID %"PRIu64":%s\n",
+        ds_put_format(ds, "Remote MPID %"PRIu64":%s%s\n",
                       rmp->mpid,
+                      rmp->opdown ? " opdown" : "",
                       rmp->rdi ? " rdi" : "");
         ds_put_format(ds, "\trecv since check: %s\n",
                       rmp->recv ? "true" : "false");
diff --git a/lib/cfm.h b/lib/cfm.h
index a031ab2..4c37c64 100644
--- a/lib/cfm.h
+++ b/lib/cfm.h
@@ -28,6 +28,7 @@ struct cfm_settings {
     uint64_t mpid;              /* The MPID of this CFM. */
     int interval;               /* The requested transmission interval. */
     bool extended;              /* Run in extended mode. */
+    bool opdown;                /* Operationally down. */
 };
 
 void cfm_init(void);
@@ -41,6 +42,7 @@ bool cfm_configure(struct cfm *, const struct cfm_settings *);
 bool cfm_should_process_flow(const struct cfm *cfm, const struct flow *);
 void cfm_process_heartbeat(struct cfm *, const struct ofpbuf *packet);
 bool cfm_get_fault(const struct cfm *);
+bool cfm_get_opdown(const struct cfm *);
 void cfm_get_remote_mpids(const struct cfm *, const uint64_t **rmps,
                           size_t *n_rmps);
 
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 9e8b1fb..cc9ea83 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1568,7 +1568,8 @@ port_run(struct ofport_dpif *ofport)
             ofpbuf_uninit(&packet);
         }
 
-        enable = enable && !cfm_get_fault(ofport->cfm);
+        enable = enable && !cfm_get_fault(ofport->cfm)
+            && !cfm_get_opdown(ofport->cfm);
     }
 
     if (ofport->bundle) {
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index de3ffba..10841de 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2668,7 +2668,7 @@ static void
 iface_configure_cfm(struct iface *iface)
 {
     const struct ovsrec_interface *cfg = iface->cfg;
-    const char *extended_str;
+    const char *extended_str, *opdown_str;
     struct cfm_settings s;
 
     if (!cfg->n_cfm_mpid) {
@@ -2687,6 +2687,9 @@ iface_configure_cfm(struct iface *iface)
                                               "false");
     s.extended = !strcasecmp("true", extended_str);
 
+    opdown_str = get_interface_other_config(iface->cfg, "cfm_opdown", "false");
+    s.opdown = !strcasecmp("true", opdown_str);
+
     ofproto_port_set_cfm(iface->port->bridge->ofproto, iface->ofp_port, &s);
 }
 
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index b85d26c..bd013c0 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -1447,6 +1447,16 @@
         compatibility with 802.1ag compliant implementations.  Defaults to
         <code>false</code>.
       </column>
+      <column name="other_config" key="cfm_opdown">
+        When <code>true</code>, the CFM module marks all CCMs it generates as
+        operationally down without triggering a fault.  This allows remote
+        maintenance points to choose not to forward traffic to the
+        <ref table="Interface"/> on which this CFM module is running.
+        Currently, in Open vSwitch, the opdown bit of CCMs affects
+        <ref table="Interface"/>s participating in bonds, and the bundle
+        OpenFlow action. This setting is ignored when CFM is not in extended
+        mode.  Defaults to <code>false</code>.
+      </column>
     </group>
 
     <group title="Bonding Configuration">
-- 
1.7.6.1

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to