Skip to content

Commit

Permalink
ofproto: Reinterpret meaning of OpenFlow hard timeouts with OFPFC_MOD…
Browse files Browse the repository at this point in the history
…IFY.

I finally found a good use for hard timeouts in OpenFlow, but they require
a slight reinterpretation of the meaning of hard timeouts.  Until now, a
hard timeout meant that a flow would be removed the specified number of
seconds after a flow was created.  Intervening modifications with
OFPFC_MODIFY(_STRICT) had no effect on the hard timeout; the flow would
still be deleted the specified number of seconds after its original
creation.

This commit changes the effect of OFPFC_MODIFY(_STRICT).  Now, modifying
a flow resets its hard timeout counter.  A flow will time out the specified
number of seconds after creation or after the last time it is modified,
whichever comes later.
  • Loading branch information
blp committed Sep 13, 2011
1 parent a75531e commit 308881a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ofproto/ofproto-dpif.c
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ rule_expire(struct rule_dpif *rule)
/* Has 'rule' expired? */
now = time_msec();
if (rule->up.hard_timeout
&& now > rule->up.created + rule->up.hard_timeout * 1000) {
&& now > rule->up.modified + rule->up.hard_timeout * 1000) {
reason = OFPRR_HARD_TIMEOUT;
} else if (rule->up.idle_timeout && list_is_empty(&rule->facets)
&& now > rule->used + rule->up.idle_timeout * 1000) {
Expand Down
3 changes: 2 additions & 1 deletion ofproto/ofproto-provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ struct rule {
ovs_be64 flow_cookie; /* Controller-issued identifier. */

long long int created; /* Creation time. */
long long int modified; /* Time of last modification. */
uint16_t idle_timeout; /* In seconds from time of last use. */
uint16_t hard_timeout; /* In seconds from time of creation. */
uint16_t hard_timeout; /* In seconds from last modification. */
uint8_t table_id; /* Index in ofproto's 'tables' array. */
bool send_flow_removed; /* Send a flow removed message? */

Expand Down
8 changes: 6 additions & 2 deletions ofproto/ofproto.c
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn,
rule->cr = fm->cr;
rule->pending = NULL;
rule->flow_cookie = fm->cookie;
rule->created = time_msec();
rule->created = rule->modified = time_msec();
rule->idle_timeout = fm->idle_timeout;
rule->hard_timeout = fm->hard_timeout;
rule->table_id = table - ofproto->tables;
Expand Down Expand Up @@ -2315,6 +2315,8 @@ modify_flows__(struct ofproto *ofproto, struct ofconn *ofconn,
rule->actions = ofputil_actions_clone(fm->actions, fm->n_actions);
rule->n_actions = fm->n_actions;
rule->ofproto->ofproto_class->rule_modify_actions(rule);
} else {
rule->modified = time_msec();
}
rule->flow_cookie = fm->cookie;
}
Expand Down Expand Up @@ -2944,7 +2946,9 @@ ofoperation_complete(struct ofoperation *op, int error)
break;

case OFOPERATION_MODIFY:
if (error) {
if (!error) {
rule->modified = time_msec();
} else {
free(rule->actions);
rule->actions = op->actions;
rule->n_actions = op->n_actions;
Expand Down

0 comments on commit 308881a

Please sign in to comment.