classifier_remove() was recently changed to take a const struct
cls_rule *.  Make the corresponding change to classifier_replace() and
classifier_insert().  This simplifies existing calling sites in
ofproto.

Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com>
---
 lib/classifier.c  |   14 ++++++++------
 lib/classifier.h  |    4 ++--
 ofproto/ofproto.c |    4 ++--
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/lib/classifier.c b/lib/classifier.c
index ff54246..0d91035 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -36,7 +36,7 @@ struct trie_ctx;
 BUILD_ASSERT_DECL(TP_PORTS_OFS32 == offsetof(struct flow, tp_dst) / 4);
 
 static struct cls_match *
-cls_match_alloc(struct cls_rule *rule)
+cls_match_alloc(const struct cls_rule *rule)
 {
     int count = count_1bits(rule->match.flow.map);
 
@@ -499,7 +499,7 @@ subtable_replace_head_rule(struct classifier *cls 
OVS_UNUSED,
  * subtable list will only be visible after the subtable's max priority is
  * updated. */
 const struct cls_rule *
-classifier_replace(struct classifier *cls, struct cls_rule *rule)
+classifier_replace(struct classifier *cls, const struct cls_rule *rule)
 {
     struct cls_subtable *subtable;
     struct cls_match *head;
@@ -509,7 +509,7 @@ classifier_replace(struct classifier *cls, struct cls_rule 
*rule)
     size_t n_rules = 0;
     struct cls_match *new = cls_match_alloc(rule);
 
-    rule->cls_match = new;
+    CONST_CAST(struct cls_rule *, rule)->cls_match = new;
 
     subtable = find_subtable(cls, &rule->match.mask);
     if (!subtable) {
@@ -598,7 +598,8 @@ classifier_replace(struct classifier *cls, struct cls_rule 
*rule)
             /* No change in subtable's max priority or max count. */
 
             /* Make rule visible to iterators. */
-            rculist_replace(&rule->node, &old->node);
+            rculist_replace(&CONST_CAST(struct cls_rule *, rule)->node,
+                            &old->node);
 
             /* Return displaced rule.  Caller is responsible for keeping it
              * around until all threads quiesce. */
@@ -607,7 +608,8 @@ classifier_replace(struct classifier *cls, struct cls_rule 
*rule)
     }
 
     /* Make rule visible to iterators. */
-    rculist_push_back(&subtable->rules_list, &rule->node);
+    rculist_push_back(&subtable->rules_list,
+                      &CONST_CAST(struct cls_rule *, rule)->node);
 
     /* Update 'subtable's 'max_priority' and 'max_count', if necessary. */
     if (n_rules == 1) {
@@ -634,7 +636,7 @@ classifier_replace(struct classifier *cls, struct cls_rule 
*rule)
  * fixed fields, and priority).  Use classifier_find_rule_exactly() to find
  * such a rule. */
 void
-classifier_insert(struct classifier *cls, struct cls_rule *rule)
+classifier_insert(struct classifier *cls, const struct cls_rule *rule)
 {
     const struct cls_rule *displaced_rule = classifier_replace(cls, rule);
     ovs_assert(!displaced_rule);
diff --git a/lib/classifier.h b/lib/classifier.h
index f7ba46c..a11de5c 100644
--- a/lib/classifier.h
+++ b/lib/classifier.h
@@ -283,9 +283,9 @@ void classifier_destroy(struct classifier *);
 bool classifier_set_prefix_fields(struct classifier *,
                                   const enum mf_field_id *trie_fields,
                                   unsigned int n_trie_fields);
-void classifier_insert(struct classifier *, struct cls_rule *);
+void classifier_insert(struct classifier *, const struct cls_rule *);
 const struct cls_rule *classifier_replace(struct classifier *,
-                                          struct cls_rule *);
+                                          const struct cls_rule *);
 const struct cls_rule *classifier_remove(struct classifier *,
                                          const struct cls_rule *);
 
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 60390c0..dad4bb0 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -4272,7 +4272,7 @@ add_flow(struct ofproto *ofproto, struct ofputil_flow_mod 
*fm,
         meter_insert_rule(rule);
     }
 
-    classifier_insert(&table->cls, CONST_CAST(struct cls_rule *, &rule->cr));
+    classifier_insert(&table->cls, &rule->cr);
 
     error = ofproto->ofproto_class->rule_insert(rule);
     if (error) {
@@ -6649,7 +6649,7 @@ oftable_remove_rule__(struct ofproto *ofproto, struct 
rule *rule)
 {
     struct classifier *cls = &ofproto->tables[rule->table_id].cls;
 
-    classifier_remove(cls, CONST_CAST(struct cls_rule *, &rule->cr));
+    classifier_remove(cls, &rule->cr);
 
     cookies_remove(ofproto, rule);
 
-- 
1.7.10.4

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

Reply via email to