We can use the rule's removed_reason instead.

Signed-off-by: Jarno Rajahalme <ja...@ovn.org>
---
 include/openvswitch/ofp-util.h |  3 ---
 lib/learn.c                    |  1 -
 lib/ofp-parse.c                |  1 -
 lib/ofp-util.c                 |  4 ----
 ofproto/ofproto-dpif.c         |  1 -
 ofproto/ofproto.c              | 21 ++++++---------------
 utilities/ovs-ofctl.c          |  1 -
 7 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/include/openvswitch/ofp-util.h b/include/openvswitch/ofp-util.h
index c2dfe9d..177bf2b 100644
--- a/include/openvswitch/ofp-util.h
+++ b/include/openvswitch/ofp-util.h
@@ -325,9 +325,6 @@ struct ofputil_flow_mod {
     uint16_t importance;     /* Eviction precedence. */
     struct ofpact *ofpacts;  /* Series of "struct ofpact"s. */
     size_t ofpacts_len;      /* Length of ofpacts, in bytes. */
-
-    /* Reason for delete; ignored for non-delete commands */
-    enum ofp_flow_removed_reason delete_reason;
 };
 
 enum ofperr ofputil_decode_flow_mod(struct ofputil_flow_mod *,
diff --git a/lib/learn.c b/lib/learn.c
index 33d4169..a8469fa 100644
--- a/lib/learn.c
+++ b/lib/learn.c
@@ -111,7 +111,6 @@ learn_execute(const struct ofpact_learn *learn, const 
struct flow *flow,
     }
     fm->ofpacts = NULL;
     fm->ofpacts_len = 0;
-    fm->delete_reason = OFPRR_DELETE;
 
     if (learn->fin_idle_timeout || learn->fin_hard_timeout) {
         struct ofpact_fin_timeout *oft;
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 780c9df..d3ef140 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -340,7 +340,6 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, 
char *string,
         .buffer_id = UINT32_MAX,
         .out_port = OFPP_ANY,
         .out_group = OFPG_ANY,
-        .delete_reason = OFPRR_DELETE,
     };
     /* For modify, by default, don't update the cookie. */
     if (command == OFPFC_MODIFY || command == OFPFC_MODIFY_STRICT) {
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index b62827e..ccb06fe 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1576,10 +1576,6 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
 {
     ovs_be16 raw_flags;
     enum ofperr error;
-
-    /* Ignored for non-delete actions */
-    fm->delete_reason = OFPRR_DELETE;
-
     struct ofpbuf b = ofpbuf_const_initializer(oh, ntohs(oh->length));
     enum ofpraw raw = ofpraw_pull_assert(&b);
     if (raw == OFPRAW_OFPT11_FLOW_MOD) {
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index d57068d..aa933b1 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -5559,7 +5559,6 @@ ofproto_dpif_add_internal_flow(struct ofproto_dpif 
*ofproto,
         .flags = OFPUTIL_FF_HIDDEN_FIELDS | OFPUTIL_FF_NO_READONLY,
         .ofpacts = ofpacts->data,
         .ofpacts_len = ofpacts->size,
-        .delete_reason = OVS_OFPRR_NONE,
     };
 
     error = ofproto_flow_mod(&ofproto->up, &ofm);
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 83a4282..f467125 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2113,7 +2113,6 @@ flow_mod_init(struct ofputil_flow_mod *fm,
         .out_group = OFPG_ANY,
         .ofpacts = CONST_CAST(struct ofpact *, ofpacts),
         .ofpacts_len = ofpacts_len,
-        .delete_reason = OFPRR_DELETE,
     };
 }
 
@@ -4866,7 +4865,7 @@ add_flow_start(struct ofproto *ofproto, struct 
ofproto_flow_mod *ofm)
             eviction_group_remove_rule(rule);
             /* Marks '*old_rule' as an evicted rule rather than replaced rule.
              */
-            fm->delete_reason = OFPRR_EVICTION;
+            rule->removed_reason = OFPRR_EVICTION;
             *old_rule = rule;
         }
     } else {
@@ -4892,11 +4891,10 @@ static void
 add_flow_revert(struct ofproto *ofproto, struct ofproto_flow_mod *ofm)
     OVS_REQUIRES(ofproto_mutex)
 {
-    struct ofputil_flow_mod *fm = &ofm->fm;
     struct rule *old_rule = rule_collection_stub(&ofm->old_rules)[0];
     struct rule *new_rule = rule_collection_stub(&ofm->new_rules)[0];
 
-    if (old_rule && fm->delete_reason == OFPRR_EVICTION) {
+    if (old_rule && old_rule->removed_reason == OFPRR_EVICTION) {
         /* Revert the eviction. */
         eviction_group_add_rule(old_rule);
     }
@@ -4979,7 +4977,7 @@ replace_rule_create(struct ofproto *ofproto, struct 
ofputil_flow_mod *fm,
     rule->modify_seqno = 0;
 
     /* Copy values from old rule for modify semantics. */
-    if (old_rule && fm->delete_reason != OFPRR_EVICTION) {
+    if (old_rule && old_rule->removed_reason != OFPRR_EVICTION) {
         bool change_cookie = (fm->modify_cookie
                               && fm->new_cookie != OVS_BE64_MAX
                               && fm->new_cookie != old_rule->flow_cookie);
@@ -5076,7 +5074,8 @@ replace_rule_finish(struct ofproto *ofproto, struct 
ofputil_flow_mod *fm,
     bool forward_counts = !(new_rule->flags & OFPUTIL_FF_RESET_COUNTS);
     struct rule *replaced_rule;
 
-    replaced_rule = fm->delete_reason != OFPRR_EVICTION ? old_rule : NULL;
+    replaced_rule = (old_rule && old_rule->removed_reason != OFPRR_EVICTION)
+        ? old_rule : NULL;
 
     /* Insert the new flow to the ofproto provider.  A non-NULL 'replaced_rule'
      * is a duplicate rule the 'new_rule' is replacing.  The provider should
@@ -5113,9 +5112,6 @@ replace_rule_finish(struct ofproto *ofproto, struct 
ofputil_flow_mod *fm,
             }
         } else {
             /* XXX: This is slight duplication with delete_flows_finish__() */
-
-            old_rule->removed_reason = OFPRR_EVICTION;
-
             ofmonitor_report(ofproto->connmgr, old_rule, NXFME_DELETED,
                              OFPRR_EVICTION,
                              req ? req->ofconn : NULL,
@@ -5170,10 +5166,6 @@ modify_flows_start__(struct ofproto *ofproto, struct 
ofproto_flow_mod *ofm)
                  || fm->new_cookie == OVS_BE64_MAX)) {
         /* No match, add a new flow. */
         error = add_flow_start(ofproto, ofm);
-        if (!error) {
-            ovs_assert(fm->delete_reason == OFPRR_EVICTION
-                       || !rule_collection_rules(old_rules)[0]);
-        }
         new_rules->collection.n = 1;
     } else {
         error = 0;
@@ -5427,8 +5419,7 @@ delete_flows_finish(struct ofproto *ofproto,
                     const struct openflow_mod_requester *req)
     OVS_REQUIRES(ofproto_mutex)
 {
-    delete_flows_finish__(ofproto, &ofm->old_rules, ofm->fm.delete_reason,
-                          req);
+    delete_flows_finish__(ofproto, &ofm->old_rules, OFPRR_DELETE, req);
 }
 
 /* Implements OFPFC_DELETE_STRICT. */
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 20d5acf..2937063 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -3171,7 +3171,6 @@ fte_make_flow_mod(const struct fte *fte, int index, 
uint16_t command,
         .out_port = OFPP_ANY,
         .out_group = OFPG_ANY,
         .flags = version->flags,
-        .delete_reason = OFPRR_DELETE,
     };
     minimatch_expand(&fte->rule.match, &fm.match);
     if (command == OFPFC_ADD || command == OFPFC_MODIFY ||
-- 
2.1.4

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

Reply via email to