aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2013-05-24 17:01:34 -0700
committerBen Pfaff <blp@nicira.com>2013-06-05 10:28:47 -0700
commit6d164b21fa3d72e03bede3bdfe3b673f8fe8bdd0 (patch)
tree3a52ce1dbb5d9d2e8375990437fdb18749508b55
parent5f418ef78e587ff988f08f573ba3b0d909d5b6d4 (diff)
ofproto-dpif: Don't count misses in OpenFlow table stats.
Originally no rule existed for packets that did not match an OpenFlow flow and therefore every packet with a rule could be counted as a hit. However, newer versions of OVS have hidden miss rules so this is no longer true. To return the correct table stats, this subtracts packets that hit the miss rule from the total and removes the separate counter. Reported-by: love you <thunder.love07@gmail.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
-rw-r--r--ofproto/ofproto-dpif.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 66739854e..2ac3cd52e 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -118,6 +118,7 @@ static struct rule_dpif *rule_dpif_lookup__(struct ofproto_dpif *,
static struct rule_dpif *rule_dpif_miss_rule(struct ofproto_dpif *ofproto,
const struct flow *flow);
+static void rule_get_stats(struct rule *, uint64_t *packets, uint64_t *bytes);
static void rule_credit_stats(struct rule_dpif *,
const struct dpif_flow_stats *);
static void flow_push_stats(struct facet *, const struct dpif_flow_stats *);
@@ -681,9 +682,6 @@ struct ofproto_dpif {
struct rule_dpif *miss_rule; /* Sends flow table misses to controller. */
struct rule_dpif *no_packet_in_rule; /* Drops flow table misses. */
- /* Statistics. */
- uint64_t n_matches;
-
/* Bridging. */
struct netflow *netflow;
struct dpif_sflow *sflow;
@@ -1367,8 +1365,6 @@ construct(struct ofproto *ofproto_)
max_ports = dpif_get_max_ports(ofproto->backer->dpif);
ofproto_init_max_ports(ofproto_, MIN(max_ports, OFPP_MAX));
- ofproto->n_matches = 0;
-
ofproto->netflow = NULL;
ofproto->sflow = NULL;
ofproto->ipfix = NULL;
@@ -1775,13 +1771,18 @@ get_tables(struct ofproto *ofproto_, struct ofp12_table_stats *ots)
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
struct dpif_dp_stats s;
+ uint64_t n_miss, n_no_pkt_in, n_bytes;
+ uint64_t n_lookup;
strcpy(ots->name, "classifier");
dpif_get_dp_stats(ofproto->backer->dpif, &s);
+ rule_get_stats(&ofproto->miss_rule->up, &n_miss, &n_bytes);
+ rule_get_stats(&ofproto->no_packet_in_rule->up, &n_no_pkt_in, &n_bytes);
- ots->lookup_count = htonll(s.n_hit + s.n_missed);
- ots->matched_count = htonll(s.n_hit + ofproto->n_matches);
+ n_lookup = s.n_hit + s.n_missed;
+ ots->lookup_count = htonll(n_lookup);
+ ots->matched_count = htonll(n_lookup - n_miss - n_no_pkt_in);
}
static struct ofport *
@@ -3613,8 +3614,6 @@ handle_flow_miss_common(struct rule_dpif *rule,
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule->up.ofproto);
- ofproto->n_matches++;
-
if (rule->up.cr.priority == FAIL_OPEN_PRIORITY) {
/*
* Extra-special case for fail-open mode.