lacp: Notify LACP module when carrier changes.
authorEthan Jackson <ethan@nicira.com>
Fri, 2 Mar 2012 20:24:55 +0000 (12:24 -0800)
committerEthan Jackson <ethan@nicira.com>
Wed, 7 Mar 2012 22:56:53 +0000 (14:56 -0800)
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 <ethan@nicira.com>
lib/lacp.c
ofproto/ofproto-dpif.c

index f7d5a82..9eac4fe 100644 (file)
@@ -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);
+        }
     }
 }
 
index 457bbb7..29918ba 100644 (file)
@@ -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_);
@@ -2203,8 +2205,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);
 
@@ -2223,6 +2229,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) {