From cc545357bd0a1604be7457f06e5505617d24cdd4 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Thu, 19 Jun 2014 18:31:19 -0700 Subject: ofproto-dpif: Configure datapath max-idle through ovs-vsctl. This patch adds a new configuration option, "max-idle" to the Bridge "other-config" column. This sets how long datapath flows, for the configured bridge, are cached in the datapath before ovs-vswitchd thread expires them. This commit is a backport of commit 72310b04 (upcall: Configure datapath max-idle through ovs-vsctl.). Signed-off-by: Alex Wang Acked-by: Joe Stringer --- ofproto/ofproto-dpif.c | 6 ++++++ ofproto/ofproto-provider.h | 1 + ofproto/ofproto.c | 8 ++++++++ ofproto/ofproto.h | 1 + vswitchd/bridge.c | 18 ++++++++++++++++++ 5 files changed, 34 insertions(+) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index b0e94435a..a2dc2019b 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -4387,6 +4387,12 @@ subfacet_max_idle(const struct ofproto_dpif *ofproto) long long int now; int i; + /* If 'max_idle' is specified, uses it instead of doing the + * calculation. */ + if (ofproto->up.max_idle) { + return ofproto->up.max_idle; + } + total = hmap_count(&ofproto->subfacets); if (total <= ofproto->up.flow_eviction_threshold) { return N_BUCKETS * BUCKET_WIDTH; diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h index 95bda33a1..18ab362d4 100644 --- a/ofproto/ofproto-provider.h +++ b/ofproto/ofproto-provider.h @@ -50,6 +50,7 @@ struct ofproto { unsigned flow_eviction_threshold; /* Threshold at which to begin flow * table eviction. Only affects the * ofproto-dpif implementation */ + unsigned max_idle; bool forward_bpdu; /* Option to allow forwarding of BPDU frames * when NORMAL action is invoked. */ char *mfr_desc; /* Manufacturer (NULL for default)b. */ diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 448cf1d03..c4d57b6a3 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -570,6 +570,14 @@ ofproto_set_flow_eviction_threshold(struct ofproto *ofproto, unsigned threshold) } } +/* Sets the maximum idle time for flows of 'ofproto' in the datapath before + * they are expired. */ +void +ofproto_set_max_idle(struct ofproto *ofproto, 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 c3f59b252..659cb563d 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -222,6 +222,7 @@ void ofproto_set_extra_in_band_remotes(struct ofproto *, const struct sockaddr_in *, size_t n); void ofproto_set_in_band_queue(struct ofproto *, int queue_id); void ofproto_set_flow_eviction_threshold(struct ofproto *, unsigned threshold); +void ofproto_set_max_idle(struct ofproto *, 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 186bdd072..a95fe3925 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -199,6 +199,7 @@ static void bridge_configure_flow_eviction_threshold(struct bridge *); static void bridge_configure_netflow(struct bridge *); static void bridge_configure_forward_bpdu(struct bridge *); static void bridge_configure_mac_table(struct bridge *); +static void bridge_configure_max_idle(struct bridge *); static void bridge_configure_sflow(struct bridge *, int *sflow_bridge_number); static void bridge_configure_stp(struct bridge *); static void bridge_configure_tables(struct bridge *); @@ -610,6 +611,7 @@ bridge_reconfigure_continue(const struct ovsrec_open_vswitch *ovs_cfg) bridge_configure_flow_eviction_threshold(br); bridge_configure_forward_bpdu(br); bridge_configure_mac_table(br); + bridge_configure_max_idle(br); bridge_configure_remotes(br, managers, n_managers); bridge_configure_netflow(br); bridge_configure_sflow(br, &sflow_bridge_number); @@ -1493,6 +1495,22 @@ bridge_configure_flow_eviction_threshold(struct bridge *br) ofproto_set_flow_eviction_threshold(br->ofproto, threshold); } +static void +bridge_configure_max_idle(struct bridge *br) +{ + const char *max_idle_str; + unsigned max_idle; + + max_idle_str = smap_get(&br->cfg->other_config, + "max-idle"); + if (max_idle_str) { + max_idle = strtoul(max_idle_str, NULL, 10); + } else { + max_idle = 0; + } + ofproto_set_max_idle(br->ofproto, max_idle); +} + /* Set forward BPDU option. */ static void bridge_configure_forward_bpdu(struct bridge *br) -- cgit v1.2.1