[ovs-dev] [cfm 7/7] bond: Use CFM for slave status.

Ethan Jackson ethan at nicira.com
Fri May 20 01:53:26 UTC 2011


With this patch, if CFM is configured on a slave, and in a faulted
state, it will be disabled by the bond module.
---
 lib/bond.c             |   19 +++++++++----------
 lib/bond.h             |    4 +---
 ofproto/ofproto-dpif.c |    6 +++++-
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/lib/bond.c b/lib/bond.c
index 5cb218d..409fe7a 100644
--- a/lib/bond.c
+++ b/lib/bond.c
@@ -65,7 +65,7 @@ struct bond_slave {
     long long delay_expires;    /* Time after which 'enabled' may change. */
     bool up;                    /* Last link status read from netdev. */
     bool enabled;               /* May be chosen for flows? */
-    bool lacp_may_enable;       /* LACP considers this interface bondable. */
+    bool may_enable;            /* LACP considers this interface bondable. */
     tag_type tag;               /* Tag associated with this slave. */
 
     /* Rebalancing info.  Used only by bond_rebalance(). */
@@ -456,13 +456,12 @@ bond_slave_unregister(struct bond *bond, const void *slave_)
     }
 }
 
-/* Should be called on each slave in 'bond' before bond_run() to indicate the
- * results of lacp_slave_may_enable() on 'slave_'. */
+/* Should be called on each slave in 'bond' before bond_run() to indicate
+ * whether or not 'slave_' may be enabled. */
 void
-bond_slave_set_lacp_may_enable(struct bond *bond, void *slave_,
-                               bool may_enable)
+bond_slave_set_may_enable(struct bond *bond, void *slave_, bool may_enable)
 {
-    bond_slave_lookup(bond, slave_)->lacp_may_enable = may_enable;
+    bond_slave_lookup(bond, slave_)->may_enable = may_enable;
 }
 
 /* Performs periodic maintenance on 'bond'.  The caller must provide 'tags' to
@@ -1046,8 +1045,8 @@ bond_unixctl_show(struct unixctl_conn *conn,
                           slave->delay_expires - time_msec());
         }
 
-        ds_put_format(&ds, "\tlacp_may_enable: %s\n",
-                      slave->lacp_may_enable ? "true" : "false");
+        ds_put_format(&ds, "\tmay_enable: %s\n",
+                      slave->may_enable ? "true" : "false");
 
         if (!bond_is_balanced(bond)) {
             continue;
@@ -1361,7 +1360,7 @@ bond_link_status_update(struct bond_slave *slave, struct tag_set *tags)
     struct bond *bond = slave->bond;
     bool up;
 
-    up = slave->up && slave->lacp_may_enable;
+    up = slave->up && slave->may_enable;
     if ((up == slave->enabled) != (slave->delay_expires == LLONG_MAX)) {
         static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
         VLOG_INFO_RL(&rl, "interface %s: link state %s",
@@ -1510,7 +1509,7 @@ bond_choose_slave(const struct bond *bond)
     best = NULL;
     HMAP_FOR_EACH (slave, hmap_node, &bond->slaves) {
         if (slave->delay_expires != LLONG_MAX
-            && slave->lacp_may_enable
+            && slave->may_enable
             && (!best || slave->delay_expires < best->delay_expires)) {
             best = slave;
         }
diff --git a/lib/bond.h b/lib/bond.h
index fe58792..bd05bcd 100644
--- a/lib/bond.h
+++ b/lib/bond.h
@@ -82,9 +82,7 @@ void bond_slave_unregister(struct bond *, const void *slave);
 void bond_run(struct bond *, struct tag_set *, bool lacp_negotiated);
 void bond_wait(struct bond *);
 
-/* LACP. */
-void bond_slave_set_lacp_may_enable(struct bond *, void *slave_,
-                                    bool may_enable);
+void bond_slave_set_may_enable(struct bond *, void *slave_, bool may_enable);
 
 /* Special MAC learning support for SLB bonding. */
 bool bond_should_send_learning_packets(struct bond *);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index da3c465..3520beb 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1137,7 +1137,11 @@ bundle_run(struct ofbundle *bundle)
 
         LIST_FOR_EACH (port, bundle_node, &bundle->ports) {
             bool may_enable = lacp_slave_may_enable(bundle->lacp, port);
-            bond_slave_set_lacp_may_enable(bundle->bond, port, may_enable);
+
+            if (may_enable && port->cfm) {
+                may_enable = !cfm_get_fault(port->cfm);
+            }
+            bond_slave_set_may_enable(bundle->bond, port, may_enable);
         }
 
         bond_run(bundle->bond, &bundle->ofproto->revalidate_set,
-- 
1.7.4.4




More information about the dev mailing list