From: Ethan Jackson Date: Fri, 2 Mar 2012 20:24:55 +0000 (-0800) Subject: lacp: Notify LACP module when carrier changes. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e5b3fdbf52cee41142ed8e2bf5cab9f49146d97;p=openvswitch lacp: Notify LACP module when carrier changes. 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 --- diff --git a/lib/lacp.c b/lib/lacp.c index f7d5a82f..9eac4fe9 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 457bbb78..29918bac 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_); @@ -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) {