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 b0ce0b78f3a3cc113d79753fa7d58741c4f6abff..b31e8f00c833c18338bd8dcdf954b0f7de09401b 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 80f07c209cd03dd3f9727f6ca24ebadbd23f2b40..a9c7dcc25e6f90590ff8d95c31c7fe68eb168f1f 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 46060a2b250d03ebc954627870fd95db38b03f4f..7e675a149f8f314c3b102a3a443b7af9465359a5 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 b1143c7ad886123b477e45fd3733295f62243938..355bda2794f96b989edaaad7834d1748da7f9fcc 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);