Skip to content

Commit

Permalink
lib/ofproto: Add comments about races in ofproto_flush().
Browse files Browse the repository at this point in the history
Signed-off-by: Jarno Rajahalme <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
Jarno Rajahalme committed Oct 27, 2014
1 parent ea71c54 commit 3948503
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ofproto/ofproto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,10 +1357,17 @@ ofproto_flush__(struct ofproto *ofproto)
{
struct oftable *table;

/* This will flush all datapath flows. */
if (ofproto->ofproto_class->flush) {
ofproto->ofproto_class->flush(ofproto);
}

/* XXX: There is a small race window here, where new datapath flows can be
* created by upcall handlers based on the existing flow table. We can not
* call ofproto class flush while holding 'ofproto_mutex' to prevent this,
* as then we could deadlock on syncing with the handler threads waiting on
* the same mutex. */

ovs_mutex_lock(&ofproto_mutex);
OFPROTO_FOR_EACH_TABLE (table, ofproto) {
struct rule *rule;
Expand All @@ -1373,6 +1380,9 @@ ofproto_flush__(struct ofproto *ofproto)
ofproto_rule_delete__(rule, OFPRR_DELETE);
}
}
/* XXX: Concurrent handler threads may insert new learned flows based on
* learn actions of the now deleted flows right after we release
* 'ofproto_mutex'. */
ovs_mutex_unlock(&ofproto_mutex);
}

Expand Down

0 comments on commit 3948503

Please sign in to comment.