From eafed69b66fa5b7b69035fe5aa2ae2102d66d6f6 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Thu, 2 May 2013 15:39:06 -0700 Subject: [PATCH] ofproto-dpif: Update 'facet->rule' stats in facet_push_stats(). 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 Signed-off-by: Ethan Jackson --- ofproto/ofproto-dpif.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index eb847e6ac..8e51655de 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -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 -- 2.43.0