ofproto: Avoid clearing NetFlow stats twice upon rule creation.
authorBen Pfaff <blp@nicira.com>
Fri, 29 Oct 2010 22:22:15 +0000 (15:22 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 11 Nov 2010 19:04:12 +0000 (11:04 -0800)
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
ofproto/netflow.h
ofproto/ofproto.c

index af6dda7..37b18ff 100644 (file)
@@ -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)
 {
index f6fad62..58fe7cb 100644 (file)
@@ -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);
index c50e183..4403a53 100644 (file)
@@ -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;