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 <al...@nicira.com> --- 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 ae40962..031efdb 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -4640,6 +4640,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 2f429e0..3db2ef1 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 7d94f8b..1b0a1ed 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -573,6 +573,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 e930dd6..5dd1c44 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -234,6 +234,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 20359fa..e1ea3f9 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_ipfix(struct bridge *); static void bridge_configure_stp(struct bridge *); @@ -611,6 +612,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); @@ -1572,6 +1574,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) -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev