Without this patch, when a slave's carrier goes down, the LACP
module (as evidenced by ovs-appctl lacp/show) would consider the
slave current until it hadn't received LACP PDUs for the requisite
amount of time.  It should instead, immediately mark the slave
expired.  This 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 <et...@nicira.com>
---

Here's a version with an updated commit message that actually updates
carrier_seq.

---
 lib/lacp.c             |   10 ++++++----
 ofproto/ofproto-dpif.c |    9 +++++++++
 2 files changed, 15 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..e6c572d 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,8 +2203,12 @@ 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);
 
+    ofport->carrier_seq = carrier_seq;
+
     if (ofport->cfm) {
         cfm_run(ofport->cfm);
 
@@ -2221,6 +2227,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

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to