-/* Copyright (c) 2011 Nicira Networks
+/* Copyright (c) 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <config.h>
#include "lacp.h"
-#include <assert.h>
#include <stdlib.h>
#include "dynamic-string.h"
void
lacp_configure(struct lacp *lacp, const struct lacp_settings *s)
{
- assert(!eth_addr_is_zero(s->id));
+ ovs_assert(!eth_addr_is_zero(s->id));
if (!lacp->name || strcmp(s->name, lacp->name)) {
free(lacp->name);
}
}
+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. */
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;
}
ds_put_format(ds, "\tsys_priority: %u\n", lacp->sys_priority);
ds_put_cstr(ds, "\taggregation key: ");
if (lacp->key_slave) {
- ds_put_format(ds, "%u", lacp->key_slave->port_id);
+ ds_put_format(ds, "%u", lacp->key_slave->key
+ ? lacp->key_slave->key
+ : lacp->key_slave->port_id);
} else {
ds_put_cstr(ds, "none");
}
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));