[ovs-dev] [PATCH v2 04/26] ofproto: Make flow handling more symmetric.

Jarno Rajahalme jarno at ovn.org
Fri Jul 29 00:55:56 UTC 2016


Remove flow from ofproto data structures in the 'start' phase, even if
we may need to add them back in 'revert' phase.

This makes bundled group mods easier, as a group delete may also
delete flows, and we need the referring flows to be updated in the
'start' phase so that we will not have stale references to the
referring flows.

Signed-off-by: Jarno Rajahalme <jarno at ovn.org>
---
 ofproto/ofproto.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 83fe3a1..83719a5 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -4933,6 +4933,9 @@ replace_rule_start(struct ofproto *ofproto, ovs_version_t version,
     if (old_rule) {
         /* Mark the old rule for removal in the next version. */
         cls_rule_make_invisible_in_version(&old_rule->cr, version);
+
+        /* Remove the old rule from data structures. */
+        ofproto_rule_remove__(ofproto, old_rule);
     } else {
         table->n_flows++;
     }
@@ -4951,6 +4954,9 @@ static void replace_rule_revert(struct ofproto *ofproto,
     struct oftable *table = &ofproto->tables[new_rule->table_id];
 
     if (old_rule) {
+        /* Restore the old rule to data structures. */
+        ofproto_rule_insert__(ofproto, old_rule);
+
         /* Restore the original visibility of the old rule. */
         cls_rule_restore_visibility(&old_rule->cr);
     } else {
@@ -4992,10 +4998,6 @@ replace_rule_finish(struct ofproto *ofproto, struct ofputil_flow_mod *fm,
     if (old_rule) {
         const struct rule_actions *old_actions = rule_get_actions(old_rule);
 
-        /* Remove the old rule from data structures.  Removal from the
-         * classifier and the deletion of the rule is RCU postponed by the
-         * caller. */
-        ofproto_rule_remove__(ofproto, old_rule);
         learned_cookies_dec(ofproto, old_actions, dead_cookies);
 
         if (replaced_rule) {
@@ -5209,6 +5211,9 @@ delete_flows_start__(struct ofproto *ofproto, ovs_version_t version,
 
         table->n_flows--;
         cls_rule_make_invisible_in_version(&rule->cr, version);
+
+        /* Remove rule from ofproto data structures. */
+        ofproto_rule_remove__(ofproto, rule);
     }
 }
 
@@ -5236,7 +5241,6 @@ delete_flows_finish__(struct ofproto *ofproto,
             /* Send Vacancy Event for OF1.4+. */
             send_table_status(ofproto, rule->table_id);
 
-            ofproto_rule_remove__(ofproto, rule);
             learned_cookies_dec(ofproto, rule_get_actions(rule),
                                 &dead_cookies);
         }
@@ -5300,6 +5304,9 @@ delete_flows_revert(struct ofproto *ofproto, struct ofproto_flow_mod *ofm)
         struct rule *rule = rules->rules[i];
         struct oftable *table = &ofproto->tables[rule->table_id];
 
+        /* Add rule back to ofproto data structures. */
+        ofproto_rule_insert__(ofproto, rule);
+
         /* Restore table's rule count. */
         table->n_flows++;
 
-- 
2.1.4




More information about the dev mailing list