aboutsummaryrefslogtreecommitdiff
path: root/lib/lacp.c
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2011-11-29 14:21:26 -0800
committerEthan Jackson <ethan@nicira.com>2011-11-30 14:52:00 -0800
commit431d6a6acf6da61ecfeb433cb1fb10e1b39e9773 (patch)
treea923c6b5cad00398e9623ab7fe7ea1e005cf6219 /lib/lacp.c
parent1c1df7f1a76ff7d32d123e916b9c9e75254a4d87 (diff)
lacp: Sort slaves in appctl output.
This will simplify unit tests added in a future patch.
Diffstat (limited to 'lib/lacp.c')
-rw-r--r--lib/lacp.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/lacp.c b/lib/lacp.c
index 5303053f..2b779961 100644
--- a/lib/lacp.c
+++ b/lib/lacp.c
@@ -25,6 +25,7 @@
#include "ofpbuf.h"
#include "packets.h"
#include "poll-loop.h"
+#include "shash.h"
#include "timer.h"
#include "timeval.h"
#include "unixctl.h"
@@ -761,7 +762,11 @@ ds_put_lacp_state(struct ds *ds, uint8_t state)
static void
lacp_print_details(struct ds *ds, struct lacp *lacp)
{
+ struct shash slave_shash = SHASH_INITIALIZER(&slave_shash);
+ const struct shash_node **sorted_slaves = NULL;
+
struct slave *slave;
+ int i;
ds_put_format(ds, "---- %s ----\n", lacp->name);
ds_put_format(ds, "\tstatus: %s", lacp->active ? "active" : "passive");
@@ -799,9 +804,15 @@ lacp_print_details(struct ds *ds, struct lacp *lacp)
}
HMAP_FOR_EACH (slave, node, &lacp->slaves) {
+ shash_add(&slave_shash, slave->name, slave);
+ }
+ sorted_slaves = shash_sort(&slave_shash);
+
+ for (i = 0; i < shash_count(&slave_shash); i++) {
char *status;
struct lacp_info actor;
+ slave = sorted_slaves[i]->data;
slave_get_actor(slave, &actor);
switch (slave->status) {
case LACP_CURRENT:
@@ -850,6 +861,9 @@ lacp_print_details(struct ds *ds, struct lacp *lacp)
ds_put_lacp_state(ds, slave->partner.state);
ds_put_cstr(ds, "\n");
}
+
+ shash_destroy(&slave_shash);
+ free(sorted_slaves);
}
static void