X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ofproto%2Fofproto.c;h=8cf6d9bcaae9bbbce57c9f9a378347db1fce2f43;hb=b74cb5d8fd1bee5bb9c79d1f9c203db0b1557ab5;hp=bd1f2c1ab40b430f6b936bbd5fea2e289c59cec3;hpb=a8e547c1ef6ff83adab8f0caaccd46fd4a6418d6;p=sliver-openvswitch.git diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index bd1f2c1ab..8cf6d9bca 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1115,10 +1115,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) { @@ -1156,7 +1166,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); @@ -1752,10 +1762,9 @@ ofproto_add_flow(struct ofproto *ofproto, const struct match *match, fm.match = *match; fm.priority = priority; fm.buffer_id = UINT32_MAX; - fm.ofpacts = xmemdup(ofpacts, ofpacts_len); + fm.ofpacts = ofpacts; fm.ofpacts_len = ofpacts_len; add_flow(ofproto, NULL, &fm, NULL); - free(fm.ofpacts); } } @@ -1795,7 +1804,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; @@ -2310,21 +2319,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 @@ -3528,8 +3522,7 @@ evict_rule_from_table(struct ofproto *ofproto, struct oftable *table) * error code on failure, or OFPROTO_POSTPONE if the operation cannot be * initiated now but may be retried later. * - * Upon successful return, takes ownership of 'fm->ofpacts'. On failure, - * ownership remains with the caller. + * The caller retains ownership of 'fm->ofpacts'. * * 'ofconn' is used to retrieve the packet buffer specified in ofm->buffer_id, * if any. */ @@ -3984,7 +3977,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); }