ofproto: Set to revalidate when a new version is available.
authorJarno Rajahalme <jarno@ovn.org>
Tue, 21 Jun 2016 16:41:02 +0000 (09:41 -0700)
committerJarno Rajahalme <jarno@ovn.org>
Tue, 21 Jun 2016 16:42:12 +0000 (09:42 -0700)
There is no need to set the revalidate flag after each flow mod
separately, as we can do it once after the whole transaction is
finished.  It is not done at all if the transaction fails.

In the successful case this change makes no functional difference,
since the revalidation thread is triggered by the main thread only
after a bundle transaction has been fully processed.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
ofproto/ofproto-dpif.c
ofproto/ofproto-provider.h
ofproto/ofproto.c

index 8a3c525..100e8d5 100644 (file)
@@ -1663,9 +1663,9 @@ set_tables_version(struct ofproto *ofproto_, cls_version_t version)
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
 
     atomic_store_relaxed(&ofproto->tables_version, version);
+    ofproto->backer->need_revalidate = REV_FLOW_TABLE;
 }
 
-
 static struct ofport *
 port_alloc(void)
 {
@@ -3972,15 +3972,6 @@ out:
     return rule;
 }
 
-static void
-complete_operation(struct rule_dpif *rule)
-    OVS_REQUIRES(ofproto_mutex)
-{
-    struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule->up.ofproto);
-
-    ofproto->backer->need_revalidate = REV_FLOW_TABLE;
-}
-
 static struct rule_dpif *rule_dpif_cast(const struct rule *rule)
 {
     return rule ? CONTAINER_OF(rule, struct rule_dpif, up) : NULL;
@@ -4132,16 +4123,6 @@ rule_insert(struct rule *rule_, struct rule *old_rule_, bool forward_stats)
         ovs_mutex_unlock(&rule->stats_mutex);
         ovs_mutex_unlock(&old_rule->stats_mutex);
     }
-
-    complete_operation(rule);
-}
-
-static void
-rule_delete(struct rule *rule_)
-    OVS_REQUIRES(ofproto_mutex)
-{
-    struct rule_dpif *rule = rule_dpif_cast(rule_);
-    complete_operation(rule);
 }
 
 static void
@@ -5558,7 +5539,7 @@ const struct ofproto_class ofproto_dpif_class = {
     rule_alloc,
     rule_construct,
     rule_insert,
-    rule_delete,
+    NULL,                       /* rule_delete */
     rule_destruct,
     rule_dealloc,
     rule_get_stats,
index e139632..ae6c08d 100644 (file)
@@ -858,8 +858,11 @@ struct ofproto_class {
                          struct ofputil_table_stats *stats);
 
     /* Sets the current tables version the provider should use for classifier
-     * lookups. */
+     * lookups.  This must be called with a new version number after each set
+     * of flow table changes has been completed, so that datapath revalidation
+     * can be triggered. */
     void (*set_tables_version)(struct ofproto *ofproto, cls_version_t version);
+
 /* ## ---------------- ## */
 /* ## ofport Functions ## */
 /* ## ---------------- ## */
@@ -1198,8 +1201,9 @@ struct ofproto_class {
      * ========
      *
      * The ofproto base code removes 'rule' from its flow table before it calls
-     * ->rule_delete().  ->rule_delete() must remove 'rule' from the datapath
-     * flow table and return only after this has completed successfully.
+     * ->rule_delete() (if non-null).  ->rule_delete() must remove 'rule' from
+     * the datapath flow table and return only after this has completed
+     * successfully.
      *
      * Rule deletion must not fail.
      *
index 2c558a6..087b321 100644 (file)
@@ -1533,7 +1533,9 @@ ofproto_rule_delete(struct ofproto *ofproto, struct rule *rule)
             OVS_NOT_REACHED();
         }
         ofproto_rule_remove__(rule->ofproto, rule);
-        ofproto->ofproto_class->rule_delete(rule);
+        if (ofproto->ofproto_class->rule_delete) {
+            ofproto->ofproto_class->rule_delete(rule);
+        }
         ofproto_rule_unref(rule);
     }
     ovs_mutex_unlock(&ofproto_mutex);
@@ -2883,7 +2885,9 @@ remove_rule_rcu__(struct rule *rule)
     if (!classifier_remove(&table->cls, &rule->cr)) {
         OVS_NOT_REACHED();
     }
-    ofproto->ofproto_class->rule_delete(rule);
+    if (ofproto->ofproto_class->rule_delete) {
+        ofproto->ofproto_class->rule_delete(rule);
+    }
     ofproto_rule_unref(rule);
 }