aboutsummaryrefslogtreecommitdiff
path: root/vswitchd
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-04-20 10:05:57 -0700
committerBen Pfaff <blp@nicira.com>2010-04-20 11:01:44 -0700
commit79c9f2ee7883b52860c76c3730725f5731402874 (patch)
tree3e67694ef36566e35e66efbaf92e393afcc9065c /vswitchd
parent0ade584ebe8ca1a1de92fb7422566726f276918c (diff)
ofproto: Bundle all controller-related settings into a struct.
Many ofproto settings are controller-related. Upcoming commits will add to ofproto the ability to support multiple controllers, so it is important to be able to refer to controller settings as a group. Hence, this commit bundles them into a new "struct ofproto_controller".
Diffstat (limited to 'vswitchd')
-rw-r--r--vswitchd/bridge.c56
1 files changed, 23 insertions, 33 deletions
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 0cdf72f7..b9e39c9c 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1516,22 +1516,11 @@ bridge_reconfigure_controller(const struct ovsrec_open_vswitch *ovs_cfg,
br->controller = c ? xstrdup(c->target) : NULL;
if (c) {
- int max_backoff, probe;
- int rate_limit, burst_limit;
+ struct ofproto_controller oc;
- if (!strcmp(c->target, "discover")) {
- ofproto_set_discovery(br->ofproto, true,
- c->discover_accept_regex,
- c->discover_update_resolv_conf);
- } else {
+ if (strcmp(c->target, "discover")) {
struct iface *local_iface;
struct in_addr ip;
- bool in_band;
-
- in_band = (!c->connection_mode
- || !strcmp(c->connection_mode, "out-of-band"));
- ofproto_set_discovery(br->ofproto, false, NULL, NULL);
- ofproto_set_in_band(br->ofproto, in_band);
local_iface = bridge_get_local_iface(br);
if (local_iface && c->local_ip && inet_aton(c->local_ip, &ip)) {
@@ -1566,20 +1555,26 @@ bridge_reconfigure_controller(const struct ovsrec_open_vswitch *ovs_cfg,
}
}
- ofproto_set_failure(br->ofproto,
- (!c->fail_mode
- || !strcmp(c->fail_mode, "standalone")
- || !strcmp(c->fail_mode, "open")));
-
- probe = c->inactivity_probe ? *c->inactivity_probe / 1000 : 5;
- ofproto_set_probe_interval(br->ofproto, probe);
-
- max_backoff = c->max_backoff ? *c->max_backoff / 1000 : 8;
- ofproto_set_max_backoff(br->ofproto, max_backoff);
-
- rate_limit = c->controller_rate_limit ? *c->controller_rate_limit : 0;
- burst_limit = c->controller_burst_limit ? *c->controller_burst_limit : 0;
- ofproto_set_rate_limit(br->ofproto, rate_limit, burst_limit);
+ oc.target = c->target;
+ oc.max_backoff = c->max_backoff ? *c->max_backoff / 1000 : 8;
+ oc.probe_interval = (c->inactivity_probe
+ ? *c->inactivity_probe / 1000 : 5);
+ oc.fail = (!c->fail_mode
+ || !strcmp(c->fail_mode, "standalone")
+ || !strcmp(c->fail_mode, "open")
+ ? OFPROTO_FAIL_STANDALONE
+ : OFPROTO_FAIL_SECURE);
+ oc.band = (!c->connection_mode
+ || !strcmp(c->connection_mode, "in-band")
+ ? OFPROTO_IN_BAND
+ : OFPROTO_OUT_OF_BAND);
+ oc.accept_re = c->discover_accept_regex;
+ oc.update_resolv_conf = c->discover_update_resolv_conf;
+ oc.rate_limit = (c->controller_rate_limit
+ ? *c->controller_rate_limit : 0);
+ oc.burst_limit = (c->controller_burst_limit
+ ? *c->controller_burst_limit : 0);
+ ofproto_set_controller(br->ofproto, &oc);
} else {
union ofp_action action;
flow_t flow;
@@ -1593,13 +1588,8 @@ bridge_reconfigure_controller(const struct ovsrec_open_vswitch *ovs_cfg,
memset(&flow, 0, sizeof flow);
ofproto_add_flow(br->ofproto, &flow, OVSFW_ALL, 0, &action, 1, 0);
- ofproto_set_in_band(br->ofproto, false);
- ofproto_set_max_backoff(br->ofproto, 1);
- ofproto_set_probe_interval(br->ofproto, 5);
- ofproto_set_failure(br->ofproto, false);
+ ofproto_set_controller(br->ofproto, NULL);
}
-
- ofproto_set_controller(br->ofproto, br->controller);
}
static void