[ovs-dev] [threaded-learning 07/25] ofproto: Merge ofproto_rule_delete() and ofproto_delete_rule().

Ethan Jackson ethan at nicira.com
Wed Sep 11 20:12:06 UTC 2013


Acked-by: Ethan Jackson <ethan at nicira.com>


On Tue, Sep 10, 2013 at 10:27 PM, Ben Pfaff <blp at nicira.com> wrote:
> These functions were identical but had different names (one just called
> the other).  Make them a single function.
>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
>  ofproto/ofproto.c |   35 +++++++++++++++--------------------
>  1 file changed, 15 insertions(+), 20 deletions(-)
>
> diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
> index b027873..b365866 100644
> --- a/ofproto/ofproto.c
> +++ b/ofproto/ofproto.c
> @@ -1081,10 +1081,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)
>  {
> @@ -1122,7 +1132,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);
> @@ -1759,7 +1769,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;
> @@ -2274,21 +2284,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
> @@ -3862,7 +3857,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);
>  }
>
> --
> 1.7.10.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list