diff options
author | Ethan Jackson <ethan@nicira.com> | 2013-03-30 15:13:00 -0700 |
---|---|---|
committer | Ethan Jackson <ethan@nicira.com> | 2013-04-01 16:01:26 -0700 |
commit | 9eb0b058ce080da913900cece35e0ce2d1bb35b5 (patch) | |
tree | 45f6c24bf22953188c8be68dba0ea3b2d58e3e18 | |
parent | 7e844f8e5817fd71a4439e924658f882f748c5ef (diff) |
ofproto-dpif: Systematically push stats upon request.
Commit bf1e8ff (ofproto-dpif: Push statistics in rule_get_stats()),
started down the road towards pushing stats on demand, but it
didn't go quite far enough. First, it neglected to push stats in
port_get_stats() and mirror_get_stats(). Second, it only pushes
stats for a single ofproto, making it incomplete when patch ports
are used.
Signed-off-by: Ethan Jackson <ethan@nicira.com>
-rw-r--r-- | ofproto/ofproto-dpif.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 7fa44e83..f9228a4e 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -510,6 +510,7 @@ static void facet_reset_counters(struct facet *); static void facet_push_stats(struct facet *); static void facet_learn(struct facet *); static void facet_account(struct facet *); +static void push_all_stats(void); static bool facet_is_controller_flow(struct facet *); @@ -2957,6 +2958,8 @@ mirror_get_stats(struct ofproto *ofproto_, void *aux, return 0; } + push_all_stats(); + *packets = mirror->packet_count; *bytes = mirror->byte_count; @@ -3215,6 +3218,8 @@ port_get_stats(const struct ofport *ofport_, struct netdev_stats *stats) struct ofport_dpif *ofport = ofport_dpif_cast(ofport_); int error; + push_all_stats(); + error = netdev_get_stats(ofport->up.netdev, stats); if (!error && ofport_->ofp_port == OFPP_LOCAL) { @@ -5042,6 +5047,27 @@ facet_push_stats(struct facet *facet) } static void +push_all_stats(void) +{ + static long long int rl = LLONG_MIN; + struct ofproto_dpif *ofproto; + + if (time_msec() < rl) { + return; + } + + HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) { + struct facet *facet; + + HMAP_FOR_EACH (facet, hmap_node, &ofproto->facets) { + facet_push_stats(facet); + } + } + + rl = time_msec() + 100; +} + +static void rule_credit_stats(struct rule_dpif *rule, const struct dpif_flow_stats *stats) { rule->packet_count += stats->n_packets; @@ -5520,13 +5546,10 @@ rule_destruct(struct rule *rule_) static void rule_get_stats(struct rule *rule_, uint64_t *packets, uint64_t *bytes) { - struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule_->ofproto); struct rule_dpif *rule = rule_dpif_cast(rule_); struct facet *facet; - HMAP_FOR_EACH (facet, hmap_node, &ofproto->facets) { - facet_push_stats(facet); - } + push_all_stats(); /* Start from historical data for 'rule' itself that are no longer tracked * in facets. This counts, for example, facets that have expired. */ |