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 af6dda78cc1c58060abb45c4dc642127eed9d681..37b18ffd3e3b911d218c335f6e602a0e5ad53ca4 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 f6fad62b092f92eb0d8e6ce7c8e6bd5449b9b887..58fe7cb37ba249024b67dff43d987cc43352877d 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 c50e18389e5fbe123693662e18eab3bcb5f1a992..4403a53448fd8f1708d5004312ef3b0f9f7d2451 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;