[ovs-dev] [PATCH v3 1/3] ofproto: Add reference count for Openflow groups.

Alex Wang alexw at nicira.com
Mon May 19 21:54:52 UTC 2014


Hey Andy,

Could you review the first two packets?

The second patch looks good to me,

For this patch, I'm concerned about the use of ovsrcu_postpone(), since
there is no
rcu protected variable in 'struct ofgroup'.  I suggest, we could move the
code in
group_destroy_cb() to ofproto_group_unref().


Want to hear about your comments on that.



> diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
> index 9b26da7..b5a59f8 100644
> --- a/ofproto/ofproto.c
> +++ b/ofproto/ofproto.c
> @@ -2647,6 +2647,31 @@ ofproto_rule_unref(struct rule *rule)
>      }
>  }
>
> +static void
> +group_destroy_cb(struct ofgroup *group)
> +{
> +    group->ofproto->ofproto_class->group_destruct(group);
> +    ofputil_bucket_list_destroy(&group->buckets);
> +    ovs_rwlock_destroy(&group->rwlock);
> +    group->ofproto->ofproto_class->group_dealloc(group);
> +}
> +
> +void
> +ofproto_group_ref(struct ofgroup *group)
> +{
> +    if (group) {
> +        ovs_refcount_ref(&group->ref_count);
> +    }
> +}
> +
> +void
> +ofproto_group_unref(struct ofgroup *group)
> +{
> +    if (group && ovs_refcount_unref(&group->ref_count) == 1) {
> +        ovsrcu_postpone(group_destroy_cb, group);
> +    }
> +}
> +
>  static uint32_t get_provider_meter_id(const struct ofproto *,
>                                        uint32_t of_meter_id);
>
> @@ -5622,6 +5647,7 @@ add_group(struct ofproto *ofproto, struct
> ofputil_group_mod *gm)
>      ofgroup->group_id = gm->group_id;
>      ofgroup->type     = gm->type;
>      ofgroup->created = ofgroup->modified = time_msec();
> +    ovs_refcount_init(&ofgroup->ref_count);
>
>      list_move(&ofgroup->buckets, &gm->buckets);
>      ofgroup->n_buckets = list_size(&ofgroup->buckets);
> @@ -5752,12 +5778,8 @@ delete_group__(struct ofproto *ofproto, struct
> ofgroup *ofgroup)
>      /* No-one can find this group any more. */
>      ofproto->n_groups[ofgroup->type]--;
>      ovs_rwlock_unlock(&ofproto->groups_rwlock);
> -
> -    ofproto->ofproto_class->group_destruct(ofgroup);
> -    ofputil_bucket_list_destroy(&ofgroup->buckets);
>      ovs_rwlock_unlock(&ofgroup->rwlock);
> -    ovs_rwlock_destroy(&ofgroup->rwlock);
> -    ofproto->ofproto_class->group_dealloc(ofgroup);
> +    ofproto_group_unref(ofgroup);
>  }
>
>  /* Implements OFPGC_DELETE. */
> --
> 1.7.9.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



Thanks,
Alex Wang,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20140519/8ebaa0b4/attachment-0005.html>


More information about the dev mailing list