From: Justin Pettit Date: Sat, 13 Sep 2008 01:57:21 +0000 (-0700) Subject: Keep old stats when a Flow Add replaces an existing entry. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f9d8317154a927e1e1113401154207effcba129;p=openvswitch Keep old stats when a Flow Add replaces an existing entry. --- diff --git a/datapath/table-hash.c b/datapath/table-hash.c index b0ce0b78..b31e8f00 100644 --- a/datapath/table-hash.c +++ b/datapath/table-hash.c @@ -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; diff --git a/datapath/table-linear.c b/datapath/table-linear.c index 80f07c20..a9c7dcc2 100644 --- a/datapath/table-linear.c +++ b/datapath/table-linear.c @@ -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); diff --git a/switch/table-hash.c b/switch/table-hash.c index 46060a2b..7e675a14 100644 --- a/switch/table-hash.c +++ b/switch/table-hash.c @@ -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; diff --git a/switch/table-linear.c b/switch/table-linear.c index b1143c7a..355bda27 100644 --- a/switch/table-linear.c +++ b/switch/table-linear.c @@ -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);