Skip to content

Commit

Permalink
ofproto-dpif: Configure datapath max-idle through ovs-vsctl.
Browse files Browse the repository at this point in the history
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 72310b0 (upcall: Configure
datapath max-idle through ovs-vsctl.).

Signed-off-by: Alex Wang <[email protected]>
Acked-by: Joe Stringer <[email protected]>
  • Loading branch information
yew011 committed Jun 23, 2014
1 parent c736bbc commit cc54535
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ofproto/ofproto-dpif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ofproto/ofproto-provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
8 changes: 8 additions & 0 deletions ofproto/ofproto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
1 change: 1 addition & 0 deletions ofproto/ofproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions vswitchd/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cc54535

Please sign in to comment.