lacp: Print may_enable flag in appctl output.
authorEthan Jackson <ethan@nicira.com>
Thu, 7 Jun 2012 21:21:36 +0000 (14:21 -0700)
committerEthan Jackson <ethan@nicira.com>
Fri, 8 Jun 2012 00:29:46 +0000 (17:29 -0700)
I would have found this helpful when debugging a problem recently.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
lib/lacp.c
tests/lacp.at

index e1d365d..374d915 100644 (file)
@@ -362,6 +362,14 @@ lacp_slave_carrier_changed(const struct lacp *lacp, const void *slave_)
     }
 }
 
+static bool
+slave_may_enable__(struct slave *slave)
+{
+    /* The slave may be enabled if it's attached to an aggregator and its
+     * partner is synchronized.*/
+    return slave->attached && (slave->partner.state & LACP_STATE_SYNC);
+}
+
 /* This function should be called before enabling 'slave_' to send or receive
  * traffic.  If it returns false, 'slave_' should not enabled.  As a
  * convenience, returns true if 'lacp' is NULL. */
@@ -369,11 +377,7 @@ bool
 lacp_slave_may_enable(const struct lacp *lacp, const void *slave_)
 {
     if (lacp) {
-        struct slave *slave = slave_lookup(lacp, slave_);
-
-        /* The slave may be enabled if it's attached to an aggregator and its
-         * partner is synchronized.*/
-        return slave->attached && (slave->partner.state & LACP_STATE_SYNC);
+        return slave_may_enable__(slave_lookup(lacp, slave_));
     } else {
         return true;
     }
@@ -788,6 +792,8 @@ lacp_print_details(struct ds *ds, struct lacp *lacp)
                       slave->attached ? "attached" : "detached");
         ds_put_format(ds, "\tport_id: %u\n", slave->port_id);
         ds_put_format(ds, "\tport_priority: %u\n", slave->port_priority);
+        ds_put_format(ds, "\tmay_enable: %s\n", (slave_may_enable__(slave)
+                                                 ? "true" : "false"));
 
         ds_put_format(ds, "\n\tactor sys_id: " ETH_ADDR_FMT "\n",
                       ETH_ADDR_ARGS(actor.sys_id));
index 543aa25..7d96143 100644 (file)
@@ -17,6 +17,7 @@ AT_CHECK([ovs-appctl lacp/show], [0], [dnl
 slave: p1: expired attached
        port_id: 1
        port_priority: 65535
+       may_enable: false
 
        actor sys_id: aa:55:aa:55:00:00
        actor sys_priority: 65535
@@ -64,6 +65,7 @@ AT_CHECK([sed -e 's/aggregation key:.*/aggregation key: <omitted>/' < stdout], [
 slave: p1: expired attached
        port_id: 11
        port_priority: 111
+       may_enable: false
 
        actor sys_id: 11:22:33:44:55:66
        actor sys_priority: 54321
@@ -82,6 +84,7 @@ slave: p1: expired attached
 slave: p2: expired attached
        port_id: 22
        port_priority: 222
+       may_enable: false
 
        actor sys_id: 11:22:33:44:55:66
        actor sys_priority: 54321