ofproto-dpif: Update 'facet->rule' stats in facet_push_stats().
authorEthan Jackson <ethan@nicira.com>
Thu, 2 May 2013 22:39:06 +0000 (15:39 -0700)
committerEthan Jackson <ethan@nicira.com>
Thu, 9 May 2013 19:44:47 +0000 (12:44 -0700)
Before this patch, stats for 'facet->rule' were handled differently
than stats which 'facet' resubmitted into.  The former were
maintained in 'facet' until it was destroyed, while the latter were
pushed regularly in facet_push_stats().

This inconsistent behavior was not only confusing, it was often
incorrect.  In some circumstances, if a facet changed rules, it
could carry the statistics from the entirety of its lifetime from
the old rule to the new one.  This patch remedies the issue by
handling all rule stats in facet_push_stats().

Reported-by: Tmusic <Tmusic987@gmail.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
ofproto/ofproto-dpif.c

index eb847e6..8e51655 100644 (file)
@@ -4834,9 +4834,6 @@ facet_flush_stats(struct facet *facet)
         netflow_expire(ofproto->netflow, &facet->nf_flow, &expired);
     }
 
-    facet->rule->packet_count += facet->packet_count;
-    facet->rule->byte_count += facet->byte_count;
-
     /* Reset counters to prevent double counting if 'facet' ever gets
      * reinstalled. */
     facet_reset_counters(facet);
@@ -5218,6 +5215,7 @@ facet_push_stats(struct facet *facet)
         facet->prev_byte_count = facet->byte_count;
         facet->prev_used = facet->used;
 
+        rule_credit_stats(facet->rule, &stats);
         flow_push_stats(facet, &stats);
 
         update_mirror_stats(ofproto_dpif_cast(facet->rule->up.ofproto),
@@ -5735,7 +5733,6 @@ static void
 rule_get_stats(struct rule *rule_, uint64_t *packets, uint64_t *bytes)
 {
     struct rule_dpif *rule = rule_dpif_cast(rule_);
-    struct facet *facet;
 
     /* push_all_stats() can handle flow misses which, when using the learn
      * action, can cause rules to be added and deleted.  This can corrupt our
@@ -5747,14 +5744,6 @@ rule_get_stats(struct rule *rule_, uint64_t *packets, uint64_t *bytes)
      * in facets.  This counts, for example, facets that have expired. */
     *packets = rule->packet_count;
     *bytes = rule->byte_count;
-
-    /* Add any statistics that are tracked by facets.  This includes
-     * statistical data recently updated by ofproto_update_stats() as well as
-     * stats for packets that were executed "by hand" via dpif_execute(). */
-    LIST_FOR_EACH (facet, list_node, &rule->facets) {
-        *packets += facet->packet_count;
-        *bytes += facet->byte_count;
-    }
 }
 
 static void