From e1ce3f2dccb027ef5ebe6035ab4f6a71de4ccf1c Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Tue, 26 Apr 2011 15:39:58 -0700 Subject: [PATCH] lacp: Allow configurable aggregation keys. Users will the ability to manually set aggregation keys on a per-slave basis in order to use some of the more advanced LACP features. Most notably, LACP controlled active-backup bonding requires fine grained aggregation key configuration. --- lib/lacp.c | 14 ++++++++++++-- lib/lacp.h | 1 + vswitchd/bridge.c | 9 ++++++++- vswitchd/vswitch.xml | 5 +++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/lacp.c b/lib/lacp.c index 21d329eb..87f70bf7 100644 --- a/lib/lacp.c +++ b/lib/lacp.c @@ -63,6 +63,7 @@ struct slave { struct lacp *lacp; /* LACP object containing this slave. */ uint16_t port_id; /* Port ID. */ uint16_t port_priority; /* Port Priority. */ + uint16_t key; /* Aggregation Key. 0 if default. */ char *name; /* Name of this slave. */ enum slave_status status; /* Slave status. */ @@ -274,9 +275,12 @@ lacp_slave_register(struct lacp *lacp, void *slave_, slave->name = xstrdup(s->name); } - if (slave->port_id != s->id || slave->port_priority != s->priority) { + if (slave->port_id != s->id + || slave->port_priority != s->priority + || slave->key != s->key) { slave->port_id = s->id; slave->port_priority = s->priority; + slave->key = s->key; lacp->update = true; @@ -528,6 +532,7 @@ static void slave_get_actor(struct slave *slave, struct lacp_info *actor) { struct lacp *lacp = slave->lacp; + uint16_t key; uint8_t state = 0; if (lacp->active) { @@ -558,8 +563,13 @@ slave_get_actor(struct slave *slave, struct lacp_info *actor) state |= LACP_STATE_COL | LACP_STATE_DIST; } + key = lacp->key_slave->key; + if (!key) { + key = lacp->key_slave->port_id; + } + actor->state = state; - actor->key = htons(lacp->key_slave->port_id); + actor->key = htons(key); actor->port_priority = htons(slave->port_priority); actor->port_id = htons(slave->port_id); actor->sys_priority = htons(lacp->sys_priority); diff --git a/lib/lacp.h b/lib/lacp.h index 871056c4..fb91b4f1 100644 --- a/lib/lacp.h +++ b/lib/lacp.h @@ -107,6 +107,7 @@ struct lacp_slave_settings { char *name; uint16_t id; uint16_t priority; + uint16_t key; }; void lacp_slave_register(struct lacp *, void *slave_, diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 270ab800..b2dc55fb 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -3136,11 +3136,13 @@ static void iface_reconfigure_lacp(struct iface *iface) { struct lacp_slave_settings s; - int priority, portid; + int priority, portid, key; portid = atoi(get_interface_other_config(iface->cfg, "lacp-port-id", "0")); priority = atoi(get_interface_other_config(iface->cfg, "lacp-port-priority", "0")); + key = atoi(get_interface_other_config(iface->cfg, "lacp-aggregation-key", + "0")); if (portid <= 0 || portid > UINT16_MAX) { portid = iface->dp_ifidx; @@ -3150,9 +3152,14 @@ iface_reconfigure_lacp(struct iface *iface) priority = UINT16_MAX; } + if (key < 0 || key > UINT16_MAX) { + key = 0; + } + s.name = iface->name; s.id = portid; s.priority = priority; + s.key = key; lacp_slave_register(iface->port->lacp, iface, &s); } diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index e7548355..48315fa9 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -1301,6 +1301,11 @@ LACP negotiations s with numerically lower priorities are preferred for aggregation. Must be a number between 1 and 65535. +
lacp-aggregation-key
+
The LACP aggregation key of this . + s with different aggregation keys may not + be active within a given at the same time. Must + be a number between 1 and 65535.
-- 2.30.2