ofproto: Take locks before calling classifier_count().
authorJoe Stringer <joestringer@nicira.com>
Thu, 30 Oct 2014 20:33:02 +0000 (13:33 -0700)
committerJoe Stringer <joestringer@nicira.com>
Fri, 31 Oct 2014 22:41:50 +0000 (15:41 -0700)
Commit 635e5bf55b (ofproto: Warn about excessive rule counts in OpenFlow
tables.) introduced an access of classifier_count() without taking the
corresponding locks first.

Found by clang.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto.c

index 7563cfd..98ed75d 100644 (file)
@@ -1478,6 +1478,9 @@ ofproto_run(struct ofproto *p)
                 continue;
             }
 
+            ovs_mutex_lock(&ofproto_mutex);
+            fat_rwlock_rdlock(&table->cls.rwlock);
+
             if (classifier_count(&table->cls) > 100000) {
                 static struct vlog_rate_limit count_rl =
                     VLOG_RATE_LIMIT_INIT(1, 1);
@@ -1486,8 +1489,6 @@ ofproto_run(struct ofproto *p)
                              classifier_count(&table->cls));
             }
 
-            ovs_mutex_lock(&ofproto_mutex);
-            fat_rwlock_rdlock(&table->cls.rwlock);
             cls_cursor_init(&cursor, &table->cls, NULL);
             CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
                 if (rule->idle_timeout || rule->hard_timeout) {