ofproto-dpif: Configure datapath max-idle through ovs-vsctl.
authorAlex Wang <alexw@nicira.com>
Fri, 20 Jun 2014 00:53:58 +0000 (17:53 -0700)
committerAlex Wang <alexw@nicira.com>
Mon, 23 Jun 2014 03:28:20 +0000 (20:28 -0700)
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>
ofproto/ofproto-dpif.c
ofproto/ofproto-provider.h
ofproto/ofproto.c
ofproto/ofproto.h
vswitchd/bridge.c

index ede7533..d9fe469 100644 (file)
@@ -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;
index 8a6e960..588d6f0 100644 (file)
@@ -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;
index 29becbc..6cc3405 100644 (file)
@@ -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. */
index 9adda2c..f015c17 100644 (file)
@@ -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);
index e3c565f..63be309 100644 (file)
@@ -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));