Keep old stats when a Flow Add replaces an existing entry.
authorJustin Pettit <jpettit@nicira.com>
Sat, 13 Sep 2008 01:57:21 +0000 (18:57 -0700)
committerJustin Pettit <jpettit@nicira.com>
Sat, 13 Sep 2008 01:57:21 +0000 (18:57 -0700)
datapath/table-hash.c
datapath/table-linear.c
switch/table-hash.c
switch/table-linear.c

index b0ce0b7..b31e8f0 100644 (file)
@@ -60,6 +60,11 @@ static int table_hash_insert(struct sw_table *swt, struct sw_flow *flow)
        } else {
                struct sw_flow *old_flow = *bucket;
                if (flow_keys_equal(&old_flow->key, &flow->key)) {
+                       /* Keep stats from the original flow */
+                       flow->init_time = old_flow->init_time;
+                       flow->packet_count = old_flow->packet_count;
+                       flow->byte_count = old_flow->byte_count;
+
                        rcu_assign_pointer(*bucket, flow);
                        flow_deferred_free(old_flow);
                        retval = 1;
index 80f07c2..a9c7dcc 100644 (file)
@@ -48,6 +48,11 @@ static int table_linear_insert(struct sw_table *swt, struct sw_flow *flow)
                if (f->priority == flow->priority
                                && f->key.wildcards == flow->key.wildcards
                                && flow_matches_2wild(&f->key, &flow->key)) {
+                       /* Keep stats from the original flow */
+                       flow->init_time = f->init_time;
+                       flow->packet_count = f->packet_count;
+                       flow->byte_count = f->byte_count;
+
                        flow->serial = f->serial;
                        list_replace_rcu(&f->node, &flow->node);
                        list_replace_rcu(&f->iter_node, &flow->iter_node);
index 46060a2..7e675a1 100644 (file)
@@ -81,6 +81,12 @@ static int table_hash_insert(struct sw_table *swt, struct sw_flow *flow)
     } else {
         struct sw_flow *old_flow = *bucket;
         if (!flow_compare(&old_flow->key.flow, &flow->key.flow)) {
+            /* Keep stats from the original flow */
+            flow->used = old_flow->used;
+            flow->created = old_flow->created;
+            flow->packet_count = old_flow->packet_count;
+            flow->byte_count = old_flow->byte_count;
+
             *bucket = flow;
             flow_free(old_flow);
             retval = 1;
index b1143c7..355bda2 100644 (file)
@@ -74,6 +74,12 @@ static int table_linear_insert(struct sw_table *swt, struct sw_flow *flow)
         if (f->priority == flow->priority
                 && f->key.wildcards == flow->key.wildcards
                 && flow_matches_2wild(&f->key, &flow->key)) {
+            /* Keep stats from the original flow */
+            flow->used = f->used;
+            flow->created = f->created;
+            flow->packet_count = f->packet_count;
+            flow->byte_count = f->byte_count;
+
             flow->serial = f->serial;
             list_replace(&flow->node, &f->node);
             list_replace(&flow->iter_node, &f->iter_node);