diff options
| author | Ethan Jackson <ethan@nicira.com> | 2011-08-16 13:50:00 -0700 |
|---|---|---|
| committer | Ethan Jackson <ethan@nicira.com> | 2011-08-16 14:14:55 -0700 |
| commit | bbb5d219de99cc99f0b88d25313a03ecaef13f9c (patch) | |
| tree | d809a9aeb22d2e13ed0808f0ad4556d2f3291a09 /ofproto | |
| parent | 0fa0fcdc5a3ab75b5e3846229ccb4aef96866ce7 (diff) | |
| download | openvswitch-bbb5d219de99cc99f0b88d25313a03ecaef13f9c.tar.gz | |
ofproto: Clear packet and byte counters on flow additions.
When a flow is added to the flow table, its packet and byte
counters should be reset. This patch efficiently approximates this
behavior. It also does some minor code refactoring.
Bug #3183.
Diffstat (limited to 'ofproto')
| -rw-r--r-- | ofproto/ofproto-dpif.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index a6e1782e4..fdd205718 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -269,6 +269,7 @@ static void facet_update_time(struct ofproto_dpif *, struct facet *, long long int used); static void facet_update_stats(struct ofproto_dpif *, struct facet *, const struct dpif_flow_stats *); +static void facet_reset_counters(struct facet *); static void facet_reset_dp_stats(struct facet *, struct dpif_flow_stats *); static void facet_push_stats(struct facet *); static void facet_account(struct ofproto_dpif *, struct facet *, @@ -2371,11 +2372,7 @@ facet_flush_stats(struct ofproto_dpif *ofproto, struct facet *facet) /* Reset counters to prevent double counting if 'facet' ever gets * reinstalled. */ - facet->packet_count = 0; - facet->byte_count = 0; - facet->rs_packet_count = 0; - facet->rs_byte_count = 0; - facet->accounted_bytes = 0; + facet_reset_counters(facet); netflow_flow_clear(&facet->nf_flow); } @@ -2538,6 +2535,16 @@ facet_update_stats(struct ofproto_dpif *ofproto, struct facet *facet, } static void +facet_reset_counters(struct facet *facet) +{ + facet->packet_count = 0; + facet->byte_count = 0; + facet->rs_packet_count = 0; + facet->rs_byte_count = 0; + facet->accounted_bytes = 0; +} + +static void facet_push_stats(struct facet *facet) { uint64_t rs_packets, rs_bytes; @@ -2663,6 +2670,13 @@ rule_construct(struct rule *rule_) rule->facets = victim->facets; list_moved(&rule->facets); LIST_FOR_EACH (facet, list_node, &rule->facets) { + /* XXX: We're only clearing our local counters here. It's possible + * that quite a few packets are unaccounted for in the datapath + * statistics. These will be accounted to the new rule instead of + * cleared as required. This could be fixed by clearing out the + * datapath statistics for this facet, but currently it doesn't + * seem worth it. */ + facet_reset_counters(facet); facet->rule = rule; } } else { |
