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 <ja...@ovn.org>
---
 ofproto/ofproto-dpif.c     | 23 ++---------------------
 ofproto/ofproto-provider.h |  5 +++--
 ofproto/ofproto.c          |  8 ++++++--
 3 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index a1e0407..ac85dcb 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1656,9 +1656,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)
 {
@@ -3946,15 +3946,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;
@@ -4106,16 +4097,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
@@ -5523,7 +5504,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,
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index d7fd50e..4f99eed 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -1198,8 +1198,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.
      *
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index ae527a4..18e6812 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1473,7 +1473,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);
@@ -2803,7 +2805,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);
 }
 
-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to