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 85144e4..4535f19 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); @@ -485,7 +485,7 @@ subtable_replace_head_rule(struct classifier *cls OVS_UNUSED, * superset of their flows and has higher priority. */ 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_match *new = cls_match_alloc(rule); struct cls_subtable *subtable; @@ -497,7 +497,7 @@ classifier_replace(struct classifier *cls, struct cls_rule *rule) uint32_t hash; int i; - rule->cls_match = new; + CONST_CAST(struct cls_rule *, rule)->cls_match = new; subtable = find_subtable(cls, &rule->match.mask); if (!subtable) { @@ -602,7 +602,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. */ @@ -611,7 +612,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); /* Rule was added, not replaced. Update 'subtable's 'max_priority' and * 'max_count', if necessary. @@ -643,7 +645,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 c35bc3a..fa41334 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -4287,7 +4287,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) { @@ -6777,7 +6777,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