From a4cc13892f8982000a0584f3f68e17eafaa85b48 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 30 Aug 2013 15:27:33 -0700 Subject: [PATCH] ofproto: Merge ofproto_rule_delete() and ofproto_delete_rule(). These functions were identical but had different names (one just called the other). Make them a single function. Signed-off-by: Ben Pfaff Acked-by: Ethan Jackson --- ofproto/ofproto.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 622df5fa5..7cc9da30e 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1110,10 +1110,20 @@ ofproto_get_snoops(const struct ofproto *ofproto, struct sset *snoops) /* Deletes 'rule' from 'cls' within 'ofproto'. * + * Within an ofproto implementation, this function allows an ofproto + * implementation to destroy any rules that remain when its ->destruct() + * function is called. This function is not suitable for use elsewhere in an + * ofproto implementation. + * + * This function is also used internally in ofproto.c. + * + * This function implements steps 4.4 and 4.5 in the section titled "Rule Life + * Cycle" in ofproto-provider.h. + * The 'cls' argument is redundant (it is &ofproto->tables[rule->table_id].cls) * but it allows Clang to do better checking. */ -static void -ofproto_delete_rule(struct ofproto *ofproto, struct classifier *cls, +void +ofproto_rule_delete(struct ofproto *ofproto, struct classifier *cls, struct rule *rule) OVS_REQ_WRLOCK(cls->rwlock) { @@ -1151,7 +1161,7 @@ ofproto_flush__(struct ofproto *ofproto) cls_cursor_init(&cursor, &table->cls, NULL); CLS_CURSOR_FOR_EACH_SAFE (rule, next_rule, cr, &cursor) { if (!rule->pending) { - ofproto_delete_rule(ofproto, &table->cls, rule); + ofproto_rule_delete(ofproto, &table->cls, rule); } } ovs_rwlock_unlock(&table->cls.rwlock); @@ -1783,7 +1793,7 @@ ofproto_delete_flow(struct ofproto *ofproto, } else { /* Initiate deletion -> success. */ ovs_rwlock_wrlock(&cls->rwlock); - ofproto_delete_rule(ofproto, cls, rule); + ofproto_rule_delete(ofproto, cls, rule); ovs_rwlock_unlock(&cls->rwlock); return true; @@ -2298,21 +2308,6 @@ ofproto_rule_destroy__(struct rule *rule) rule->ofproto->ofproto_class->rule_dealloc(rule); } -/* This function allows an ofproto implementation to destroy any rules that - * remain when its ->destruct() function is called. This function implements - * steps 4.4 and 4.5 in the section titled "Rule Life Cycle" in - * ofproto-provider.h. - * - * This function should only be called from an ofproto implementation's - * ->destruct() function. It is not suitable elsewhere. */ -void -ofproto_rule_delete(struct ofproto *ofproto, struct classifier *cls, - struct rule *rule) - OVS_REQ_WRLOCK(cls->rwlock) -{ - ofproto_delete_rule(ofproto, cls, rule); -} - /* Returns true if 'rule' has an OpenFlow OFPAT_OUTPUT or OFPAT_ENQUEUE action * that outputs to 'port' (output to OFPP_FLOOD and OFPP_ALL doesn't count). */ bool @@ -3963,7 +3958,7 @@ ofproto_rule_expire(struct rule *rule, uint8_t reason) ofproto_rule_send_removed(rule, reason); ovs_rwlock_wrlock(&cls->rwlock); - ofproto_delete_rule(ofproto, cls, rule); + ofproto_rule_delete(ofproto, cls, rule); ovs_rwlock_unlock(&cls->rwlock); } -- 2.20.1