[ovs-dev] [cleanups 04/13] ofproto: Avoid clearing NetFlow stats twice upon rule creation.

Ethan Jackson ethan at nicira.com
Thu Nov 11 03:40:49 UTC 2010


This feels like premature optimization to me but I think we can go
ahead and put it in.

Ethan

On Fri, Oct 29, 2010 at 4:37 PM, Ben Pfaff <blp at nicira.com> wrote:
> This seems cleaner to me: it seems risky to "clear" something that has not
> been initialized yet.  It's also a super-minor optimization, I suppose.
> ---
>  ofproto/netflow.c |    8 ++++++++
>  ofproto/netflow.h |    1 +
>  ofproto/ofproto.c |    2 +-
>  3 files changed, 10 insertions(+), 1 deletions(-)
>
> diff --git a/ofproto/netflow.c b/ofproto/netflow.c
> index af6dda7..37b18ff 100644
> --- a/ofproto/netflow.c
> +++ b/ofproto/netflow.c
> @@ -283,6 +283,14 @@ netflow_destroy(struct netflow *nf)
>     }
>  }
>
> +/* Initializes a new 'nf_flow' given that the caller has already cleared it to
> + * all-zero-bits. */
> +void
> +netflow_flow_init(struct netflow_flow *nf_flow OVS_UNUSED)
> +{
> +    /* Nothing to do. */
> +}
> +
>  void
>  netflow_flow_clear(struct netflow_flow *nf_flow)
>  {
> diff --git a/ofproto/netflow.h b/ofproto/netflow.h
> index f6fad62..58fe7cb 100644
> --- a/ofproto/netflow.h
> +++ b/ofproto/netflow.h
> @@ -62,6 +62,7 @@ void netflow_expire(struct netflow *, struct netflow_flow *,
>                     struct ofexpired *);
>  void netflow_run(struct netflow *);
>
> +void netflow_flow_init(struct netflow_flow *);
>  void netflow_flow_clear(struct netflow_flow *);
>  void netflow_flow_update_time(struct netflow *, struct netflow_flow *,
>                               long long int used);
> diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
> index 6638def..76803b0 100644
> --- a/ofproto/ofproto.c
> +++ b/ofproto/ofproto.c
> @@ -1860,7 +1860,7 @@ rule_create(struct ofproto *ofproto, struct rule *super,
>         rule->n_actions = n_actions;
>         rule->actions = xmemdup(actions, n_actions * sizeof *actions);
>     }
> -    netflow_flow_clear(&rule->nf_flow);
> +    netflow_flow_init(&rule->nf_flow);
>     netflow_flow_update_time(ofproto->netflow, &rule->nf_flow, rule->created);
>
>     return rule;
> --
> 1.7.1
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
>




More information about the dev mailing list