lib/ofproto: Add comments about races in ofproto_flush().
authorJarno Rajahalme <jrajahalme@nicira.com>
Mon, 27 Oct 2014 17:57:28 +0000 (10:57 -0700)
committerJarno Rajahalme <jrajahalme@nicira.com>
Mon, 27 Oct 2014 20:15:12 +0000 (13:15 -0700)
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto.c

index 30b1b97..b8f0e62 100644 (file)
@@ -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;
@@ -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);
 }