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 <[email protected]>
---
Maybe this is not problematic, but clang refuses to compile without a
fix like this. The code on master has changed considerably and just
turns off threadsafety annotations in classifier_count(). I'm not sure
if the same fix is applicable for branch-2.3.
---
 ofproto/ofproto.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 7563cfd..98ed75d 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -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) {
-- 
1.7.10.4

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to