Fixes a bug where per ofproto moving average stats did not update
when there is no active dp flows.

Reported-by: Justin Pettit <jpet...@nicira.com>
Signed-off-by: Andy Zhou <az...@nicira.com>
---
 ofproto/ofproto-dpif.c |    8 ++++++--
 tests/ofproto-dpif.at  |    4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 32ed091..5b7d6a1 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -4264,13 +4264,13 @@ update_stats(struct dpif_backer *backer)
     const struct dpif_flow_stats *stats;
     struct dpif_flow_dump dump;
     const struct nlattr *key;
+    struct ofproto_dpif *ofproto;
     size_t key_len;
 
     dpif_flow_dump_start(&dump, backer->dpif);
     while (dpif_flow_dump_next(&dump, &key, &key_len, NULL, NULL, &stats)) {
         struct flow flow;
         struct subfacet *subfacet;
-        struct ofproto_dpif *ofproto;
         struct ofport_dpif *ofport;
         uint32_t key_hash;
 
@@ -4281,7 +4281,6 @@ update_stats(struct dpif_backer *backer)
 
         ofproto->total_subfacet_count += hmap_count(&ofproto->subfacets);
         ofproto->n_update_stats++;
-        update_moving_averages(ofproto);
 
         ofport = get_ofp_port(ofproto, flow.in_port);
         if (ofport && ofport->tnl_port) {
@@ -4313,6 +4312,11 @@ update_stats(struct dpif_backer *backer)
         run_fast_rl();
     }
     dpif_flow_dump_done(&dump);
+
+    HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+        update_moving_averages(ofproto);
+    }
+
 }
 
 /* Calculates and returns the number of milliseconds of idle time after which
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index 06ebf23..b1d2f26 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -1937,8 +1937,8 @@ AT_CHECK([ovs-appctl dpif/show | sed 's/ 
10[[0-9]]\{3\}(ms)$/ 10000(ms)/'], [0],
 br0 (dummy@ovs-dummy):
        lookups: hit:0 missed:61
        flows: cur: 0, avg: 1.000, max: 1, life span: 10000(ms)
-               hourly avg: add rate: 0.641/min, del rate: 0.635/min
-               overall avg: add rate: 1.000/min, del rate: 0.984/min
+               hourly avg: add rate: 0.641/min, del rate: 0.641/min
+               overall avg: add rate: 1.000/min, del rate: 1.000/min
        br0 65534/100: (dummy)
        p1 1/1: (dummy)
        p2 2/2: (dummy)
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to