From 29985e75480f5133a16b8921cbce6e5a4002f5f1 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Thu, 7 Jun 2012 14:21:36 -0700 Subject: [PATCH] lacp: Print may_enable flag in appctl output. I would have found this helpful when debugging a problem recently. Signed-off-by: Ethan Jackson --- 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 e1d365d3..374d915a 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 543aa257..7d96143c 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: /' < 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 -- 2.30.2