ofproto: Hold ofproto_mutex when enabling or disabling eviction.
authorBen Pfaff <blp@nicira.com>
Thu, 2 Jul 2015 19:50:59 +0000 (12:50 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 2 Jul 2015 19:54:06 +0000 (12:54 -0700)
ofproto_enable_eviction() and ofproto_disable_eviction() require
ofproto_mutex (and they were even annotated that way, though not on their
prototypes but only at definition), but it wasn't being held.  This fixes
the problem.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
ofproto/ofproto.c

index 263635b..42bbc9b 100644 (file)
@@ -83,10 +83,12 @@ static void oftable_set_name(struct oftable *, const char *name);
 
 static enum ofperr evict_rules_from_table(struct oftable *)
     OVS_REQUIRES(ofproto_mutex);
-static void oftable_disable_eviction(struct oftable *);
+static void oftable_disable_eviction(struct oftable *)
+    OVS_REQUIRES(ofproto_mutex);
 static void oftable_enable_eviction(struct oftable *,
                                     const struct mf_subfield *fields,
-                                    size_t n_fields);
+                                    size_t n_fields)
+    OVS_REQUIRES(ofproto_mutex);
 
 /* A set of rules within a single OpenFlow table (oftable) that have the same
  * values for the oftable's eviction_fields.  A rule to be evicted, when one is
@@ -1418,20 +1420,18 @@ ofproto_configure_table(struct ofproto *ofproto, int table_id,
         return;
     }
 
-    if (s->groups) {
-        oftable_enable_eviction(table, s->groups, s->n_groups);
-    } else {
-        oftable_disable_eviction(table);
-    }
-
-    table->max_flows = s->max_flows;
-
     if (classifier_set_prefix_fields(&table->cls,
                                      s->prefix_fields, s->n_prefix_fields)) {
         /* XXX: Trigger revalidation. */
     }
 
     ovs_mutex_lock(&ofproto_mutex);
+    if (s->groups) {
+        oftable_enable_eviction(table, s->groups, s->n_groups);
+    } else {
+        oftable_disable_eviction(table);
+    }
+    table->max_flows = s->max_flows;
     evict_rules_from_table(table);
     ovs_mutex_unlock(&ofproto_mutex);
 }
@@ -7439,7 +7439,9 @@ static void
 oftable_destroy(struct oftable *table)
 {
     ovs_assert(classifier_is_empty(&table->cls));
+    ovs_mutex_lock(&ofproto_mutex);
     oftable_disable_eviction(table);
+    ovs_mutex_unlock(&ofproto_mutex);
     classifier_destroy(&table->cls);
     free(table->name);
 }