From: Ben Pfaff Date: Fri, 29 Oct 2010 22:22:15 +0000 (-0700) Subject: ofproto: Avoid clearing NetFlow stats twice upon rule creation. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6de72a12fad59941409ac3ff57f1660ac5a28bb;p=openvswitch ofproto: Avoid clearing NetFlow stats twice upon rule creation. 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. --- diff --git a/ofproto/netflow.c b/ofproto/netflow.c index af6dda78..37b18ffd 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 f6fad62b..58fe7cb3 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 c50e1838..4403a534 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;