/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks.
+ * Copyright (c) 2009, 2010, 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 "fail-open.h"
#include "in-band.h"
#include "odp-util.h"
+#include "ofp-actions.h"
#include "ofp-util.h"
#include "ofpbuf.h"
#include "ofproto-provider.h"
#include "pktbuf.h"
#include "rconn.h"
#include "shash.h"
+#include "simap.h"
#include "stream.h"
#include "timeval.h"
#include "vconn.h"
}
}
+/* Adds some memory usage statistics for 'mgr' into 'usage', for use with
+ * memory_report(). */
+void
+connmgr_get_memory_usage(const struct connmgr *mgr, struct simap *usage)
+{
+ const struct ofconn *ofconn;
+ unsigned int packets = 0;
+ unsigned int ofconns = 0;
+
+ LIST_FOR_EACH (ofconn, node, &mgr->all_conns) {
+ int i;
+
+ ofconns++;
+
+ packets += rconn_count_txqlen(ofconn->rconn);
+ for (i = 0; i < N_SCHEDULERS; i++) {
+ packets += pinsched_count_txqlen(ofconn->schedulers[i]);
+ }
+ packets += pktbuf_count_packets(ofconn->pktbuf);
+ }
+ simap_increase(usage, "ofconns", ofconns);
+ simap_increase(usage, "packets", packets);
+}
+
/* Returns the ofproto that owns 'ofconn''s connmgr. */
struct ofproto *
ofconn_get_ofproto(const struct ofconn *ofconn)
if (!vconn_verify_name(c->target)) {
if (!find_controller_by_target(mgr, c->target)) {
+ VLOG_INFO("%s: added primary controller \"%s\"",
+ mgr->name, c->target);
add_controller(mgr, c->target, c->dscp);
}
} else if (!pvconn_verify_name(c->target)) {
if (!ofservice_lookup(mgr, c->target)) {
+ VLOG_INFO("%s: added service controller \"%s\"",
+ mgr->name, c->target);
ofservice_create(mgr, c->target, c->dscp);
}
} else {
/* Delete controllers that are no longer configured.
* Update configuration of all now-existing controllers. */
HMAP_FOR_EACH_SAFE (ofconn, next_ofconn, hmap_node, &mgr->controllers) {
+ const char *target = ofconn_get_target(ofconn);
struct ofproto_controller *c;
- c = shash_find_data(&new_controllers, ofconn_get_target(ofconn));
+ c = shash_find_data(&new_controllers, target);
if (!c) {
+ VLOG_INFO("%s: removed primary controller \"%s\"",
+ mgr->name, target);
ofconn_destroy(ofconn);
} else {
ofconn_reconfigure(ofconn, c);
/* Delete services that are no longer configured.
* Update configuration of all now-existing services. */
HMAP_FOR_EACH_SAFE (ofservice, next_ofservice, node, &mgr->services) {
+ const char *target = pvconn_get_name(ofservice->pvconn);
struct ofproto_controller *c;
- c = shash_find_data(&new_controllers,
- pvconn_get_name(ofservice->pvconn));
+ c = shash_find_data(&new_controllers, target);
if (!c) {
+ VLOG_INFO("%s: removed service controller \"%s\"",
+ mgr->name, target);
ofservice_destroy(mgr, ofservice);
} else {
ofservice_reconfigure(ofservice, c);
rconn_set_probe_interval(ofconn->rconn, probe_interval);
ofconn_set_rate_limit(ofconn, c->rate_limit, c->burst_limit);
+
+ /* If dscp value changed reconnect. */
+ if (c->dscp != rconn_get_dscp(ofconn->rconn)) {
+ rconn_set_dscp(ofconn->rconn, c->dscp);
+ rconn_reconnect(ofconn->rconn);
+ }
}
/* Returns true if it makes sense for 'ofconn' to receive and process OpenFlow
pin.send_len = pin.packet_len;
} else {
/* Caller should have initialized 'send_len' to 'max_len' specified in
- * struct ofp_action_output. */
+ * output action. */
}
if (pin.buffer_id != UINT32_MAX) {
pin.send_len = MIN(pin.send_len, ofconn->miss_send_len);
* traffic until a controller has been defined and it tells us to do so. */
if (!connmgr_has_controllers(mgr)
&& mgr->fail_mode == OFPROTO_FAIL_STANDALONE) {
- union ofp_action action;
+ struct ofpbuf ofpacts;
struct cls_rule rule;
- memset(&action, 0, sizeof action);
- action.type = htons(OFPAT10_OUTPUT);
- action.output.len = htons(sizeof action);
- action.output.port = htons(OFPP_NORMAL);
+ ofpbuf_init(&ofpacts, OFPACT_OUTPUT_SIZE);
+ ofpact_put_OUTPUT(&ofpacts)->port = OFPP_NORMAL;
+ ofpact_pad(&ofpacts);
+
cls_rule_init_catchall(&rule, 0);
- ofproto_add_flow(mgr->ofproto, &rule, &action, 1);
+ ofproto_add_flow(mgr->ofproto, &rule, ofpacts.data, ofpacts.size);
+
+ ofpbuf_uninit(&ofpacts);
}
}
\f