[ovs-dev] [PATCH] lacp: Notify LACP module when carrier changes.

Ethan Jackson ethan at nicira.com
Fri Mar 2 22:23:56 UTC 2012


This patch shouldn't actually affect the behavior of LACP bonds
because the bond module won't choose to send traffic out a slave
whose carrier is down.

Signed-off-by: Ethan Jackson <ethan at nicira.com>
---
 lib/lacp.c             |   10 ++++++----
 ofproto/ofproto-dpif.c |    7 +++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/lacp.c b/lib/lacp.c
index f7d5a82..9eac4fe 100644
--- a/lib/lacp.c
+++ b/lib/lacp.c
@@ -368,14 +368,16 @@ lacp_slave_unregister(struct lacp *lacp, const void *slave_)
 }
 
 /* This function should be called whenever the carrier status of 'slave_' has
- * changed. */
+ * changed.  If 'lacp' is null, this function has no effect.*/
 void
 lacp_slave_carrier_changed(const struct lacp *lacp, const void *slave_)
 {
-    struct slave *slave = slave_lookup(lacp, slave_);
+    if (lacp) {
+        struct slave *slave = slave_lookup(lacp, slave_);
 
-    if (slave->status == LACP_CURRENT || slave->lacp->active) {
-        slave_set_expired(slave);
+        if (slave->status == LACP_CURRENT || slave->lacp->active) {
+            slave_set_expired(slave);
+        }
     }
 }
 
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index d8d1e38..a8e4e30 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -416,6 +416,7 @@ struct ofport_dpif {
     tag_type tag;               /* Tag associated with this port. */
     uint32_t bond_stable_id;    /* stable_id to use as bond slave, or 0. */
     bool may_enable;            /* May be enabled in bonds. */
+    long long int carrier_seq;  /* Carrier status changes. */
 
     /* Spanning tree. */
     struct stp_port *stp_port;  /* Spanning Tree Protocol, if any. */
@@ -976,6 +977,7 @@ port_construct(struct ofport *port_)
     hmap_init(&port->priorities);
     port->realdev_ofp_port = 0;
     port->vlandev_vid = 0;
+    port->carrier_seq = netdev_get_carrier_resets(port->up.netdev);
 
     if (ofproto->sflow) {
         dpif_sflow_add_port(ofproto->sflow, port_);
@@ -2201,6 +2203,8 @@ ofproto_port_from_dpif_port(struct ofproto_port *ofproto_port,
 static void
 port_run(struct ofport_dpif *ofport)
 {
+    long long int carrier_seq = netdev_get_carrier_resets(ofport->up.netdev);
+    bool carrier_changed = carrier_seq != ofport->carrier_seq;
     bool enable = netdev_get_carrier(ofport->up.netdev);
 
     if (ofport->cfm) {
@@ -2221,6 +2225,9 @@ port_run(struct ofport_dpif *ofport)
 
     if (ofport->bundle) {
         enable = enable && lacp_slave_may_enable(ofport->bundle->lacp, ofport);
+        if (carrier_changed) {
+            lacp_slave_carrier_changed(ofport->bundle->lacp, ofport);
+        }
     }
 
     if (ofport->may_enable != enable) {
-- 
1.7.9.2




More information about the dev mailing list