I would have found this helpful when debugging a problem recently.

Signed-off-by: Ethan Jackson <et...@nicira.com>
---
 lib/lacp.c    |   16 +++++++++++-----
 tests/lacp.at |    3 +++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lib/lacp.c b/lib/lacp.c
index e1d365d..374d915 100644
--- a/lib/lacp.c
+++ b/lib/lacp.c
@@ -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));
diff --git a/tests/lacp.at b/tests/lacp.at
index 543aa25..7d96143 100644
--- a/tests/lacp.at
+++ b/tests/lacp.at
@@ -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
-- 
1.7.10.2

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

Reply via email to