-/* 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"
bool fast; /* True if using fast probe interval. */
bool negotiated; /* True if LACP negotiations were successful. */
bool update; /* True if lacp_update() needs to be called. */
- bool heartbeat; /* LACP heartbeat mode. */
};
struct slave {
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);
}
if (!eth_addr_equals(lacp->sys_id, s->id)
- || lacp->sys_priority != s->priority
- || lacp->heartbeat != s->heartbeat) {
+ || lacp->sys_priority != s->priority) {
memcpy(lacp->sys_id, s->id, ETH_ADDR_LEN);
lacp->sys_priority = s->priority;
- lacp->heartbeat = s->heartbeat;
lacp->update = true;
}
}
}
+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;
}
struct lacp_info lead_pri;
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 10);
- if (lacp->heartbeat) {
- HMAP_FOR_EACH (slave, node, &lacp->slaves) {
- slave->attached = slave->status != LACP_DEFAULTED;
- }
- return;
- }
-
lacp->update = false;
lead = NULL;
state |= LACP_STATE_EXP;
}
- if (lacp->heartbeat || hmap_count(&lacp->slaves) > 1) {
+ if (hmap_count(&lacp->slaves) > 1) {
state |= LACP_STATE_AGG;
}
ds_put_format(ds, "---- %s ----\n", lacp->name);
ds_put_format(ds, "\tstatus: %s", lacp->active ? "active" : "passive");
- if (lacp->heartbeat) {
- ds_put_cstr(ds, " heartbeat");
- }
if (lacp->negotiated) {
ds_put_cstr(ds, " negotiated");
}
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));