aboutsummaryrefslogtreecommitdiff
path: root/vswitchd
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-03-21 14:30:33 -0700
committerBen Pfaff <blp@nicira.com>2011-04-01 15:52:20 -0700
commitbb5bc6c042a22103612205483558f472f8929356 (patch)
tree1b2805764326feed79b365d0a8d695f3e34cba7b /vswitchd
parent7a6735157c0df93375e9daadf0bbd1dca4160533 (diff)
lacp: Encapsulate configuration into new structs.
This makes it easier to pass configuration between modules.
Diffstat (limited to 'vswitchd')
-rw-r--r--vswitchd/bridge.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index b52fd8b0..b87dfdff 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -4233,14 +4233,28 @@ enable_lacp(struct port *port, bool *activep)
}
static void
+iface_update_lacp(struct iface *iface)
+{
+ struct lacp_slave_settings s;
+ int priority;
+
+ s.name = iface->name;
+ s.id = iface->dp_ifidx;
+ priority = atoi(get_interface_other_config(
+ iface->cfg, "lacp-port-priority", "0"));
+ s.priority = (priority >= 0 && priority <= UINT16_MAX ? priority
+ : UINT16_MAX);
+
+ lacp_slave_register(iface->port->lacp, iface, &s);
+}
+
+static void
port_update_lacp(struct port *port)
{
+ struct lacp_settings s;
struct iface *iface;
- int priority;
- bool active;
- bool fast;
- if (!enable_lacp(port, &active)) {
+ if (!enable_lacp(port, &s.active)) {
lacp_destroy(port->lacp);
port->lacp = NULL;
return;
@@ -4250,28 +4264,21 @@ port_update_lacp(struct port *port)
port->lacp = lacp_create();
}
- fast = !strcmp(get_port_other_config(port->cfg, "lacp-time", "slow"),
- "fast");
-
- priority = atoi(get_port_other_config(port->cfg, "lacp-system-priority",
+ s.name = port->name;
+ memcpy(s.id, port->bridge->ea, ETH_ADDR_LEN);
+ s.priority = atoi(get_port_other_config(port->cfg, "lacp-system-priority",
"0"));
- if (priority <= 0 || priority > UINT16_MAX) {
+ s.fast = !strcmp(get_port_other_config(port->cfg, "lacp-time", "slow"),
+ "fast");
+
+ if (s.priority <= 0 || s.priority > UINT16_MAX) {
/* Prefer bondable links if unspecified. */
- priority = UINT16_MAX - (port->n_ifaces > 1);
+ s.priority = UINT16_MAX - (port->n_ifaces > 1);
}
- lacp_configure(port->lacp, port->name, port->bridge->ea, priority,
- active, fast);
-
+ lacp_configure(port->lacp, &s);
LIST_FOR_EACH (iface, port_elem, &port->ifaces) {
- priority = atoi(get_interface_other_config(
- iface->cfg, "lacp-port-priority", "0"));
- if (priority <= 0 || priority > UINT16_MAX) {
- priority = UINT16_MAX;
- }
-
- lacp_slave_register(port->lacp, iface, iface->name,
- iface->dp_ifidx, priority);
+ iface_update_lacp(iface);
}
}