summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Wang <alexw@nicira.com>2014-06-19 17:53:58 -0700
committerAlex Wang <alexw@nicira.com>2014-06-22 20:28:20 -0700
commit0af883d0e8d8801a1e98eac960dfb5cfc6ee5e1c (patch)
treec1b557f38cc9bd2cc897b7630eb231bd26c585ff
parent881cdb3caafc435ec7de337a8cf8dd811a20fbe3 (diff)
downloadopenvswitch-0af883d0e8d8801a1e98eac960dfb5cfc6ee5e1c.tar.gz
ofproto-dpif: Configure datapath max-idle through ovs-vsctl.
This patch adds a new configuration option, "max-idle" to the Open_vSwitch "other-config" column. This sets how long datapath flows are cached in the datapath before ovs-vswitchd thread expire them. This commit is a backport of commit 72310b04 (upcall: Configure datapath max-idle through ovs-vsctl.). Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Joe Stringer <joestringer@nicira.com>
-rw-r--r--ofproto/ofproto-dpif.c6
-rw-r--r--ofproto/ofproto-provider.h6
-rw-r--r--ofproto/ofproto.c9
-rw-r--r--ofproto/ofproto.h1
-rw-r--r--vswitchd/bridge.c1
5 files changed, 23 insertions, 0 deletions
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index ede75334c..d9fe46981 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3804,6 +3804,12 @@ subfacet_max_idle(const struct dpif_backer *backer)
long long int now;
int i;
+ /* If ofproto_max_idle is specified, uses it instead of doing the
+ * calculation. */
+ if (ofproto_max_idle) {
+ return ofproto_max_idle;
+ }
+
total = hmap_count(&backer->subfacets);
if (total <= flow_eviction_threshold) {
return N_BUCKETS * BUCKET_WIDTH;
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index 8a6e96029..588d6f0d5 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -435,6 +435,12 @@ void rule_collection_destroy(struct rule_collection *);
* ofproto-dpif implementation */
extern unsigned flow_eviction_threshold;
+/* Maximum idle time (in ms) for flows to be cached in the datapath.
+ * This option should only be used for testing. Each ofproto-class
+ * implementation should have its own algorithm of calculating the
+ * idle time. */
+extern unsigned ofproto_max_idle;
+
/* Number of upcall handler threads. Only affects the ofproto-dpif
* implementation. */
extern unsigned n_handler_threads;
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 29becbc37..6cc34059a 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -283,6 +283,7 @@ struct ovs_mutex ofproto_mutex = OVS_MUTEX_INITIALIZER;
unsigned flow_eviction_threshold = OFPROTO_FLOW_EVICTION_THRESHOLD_DEFAULT;
unsigned n_handler_threads;
enum ofproto_flow_miss_model flow_miss_model = OFPROTO_HANDLE_MISS_AUTO;
+unsigned ofproto_max_idle;
/* Map from datapath name to struct ofproto, for use by unixctl commands. */
static struct hmap all_ofprotos = HMAP_INITIALIZER(&all_ofprotos);
@@ -656,6 +657,14 @@ ofproto_set_flow_miss_model(unsigned model)
flow_miss_model = model;
}
+/* Sets the maximum idle time for flows in the datapath before they are
+ * expired. */
+void
+ofproto_set_max_idle(unsigned max_idle)
+{
+ ofproto_max_idle = max_idle;
+}
+
/* If forward_bpdu is true, the NORMAL action will forward frames with
* reserved (e.g. STP) destination Ethernet addresses. if forward_bpdu is false,
* the NORMAL action will drop these frames. */
diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
index 9adda2cca..f015c17e5 100644
--- a/ofproto/ofproto.h
+++ b/ofproto/ofproto.h
@@ -248,6 +248,7 @@ void ofproto_set_extra_in_band_remotes(struct ofproto *,
void ofproto_set_in_band_queue(struct ofproto *, int queue_id);
void ofproto_set_flow_eviction_threshold(unsigned threshold);
void ofproto_set_flow_miss_model(unsigned model);
+void ofproto_set_max_idle(unsigned max_idle);
void ofproto_set_forward_bpdu(struct ofproto *, bool forward_bpdu);
void ofproto_set_mac_table_config(struct ofproto *, unsigned idle_time,
size_t max_entries);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index e3c565f24..63be309bb 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -501,6 +501,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
ofproto_set_flow_eviction_threshold(
smap_get_int(&ovs_cfg->other_config, "flow-eviction-threshold",
OFPROTO_FLOW_EVICTION_THRESHOLD_DEFAULT));
+ ofproto_set_max_idle(smap_get_int(&ovs_cfg->other_config, "max-idle", 0));
ofproto_set_n_handler_threads(
smap_get_int(&ovs_cfg->other_config, "n-handler-threads", 0));