summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-05-27 15:16:08 -0700
committerBen Pfaff <blp@nicira.com>2011-06-14 11:21:52 -0700
commit5e9d0469fcaa30f4de0209392a1329b4c52d8d63 (patch)
treeff562c92b2f694967f6b5912634c0b3b4916c868 /ofproto
parent7ee20df120d4d56df894abc00a60fe1bc43a058d (diff)
downloadopenvswitch-5e9d0469fcaa30f4de0209392a1329b4c52d8d63.tar.gz
Define UINT64_MAX as "unknown" in Open vSwitch specific interfaces.
Some hardware supports reporting packet or byte counters but not both, so OVS has to be prepared for that. Suggested-by: Justin Pettit <jpettit@nicira.com>
Diffstat (limited to 'ofproto')
-rw-r--r--ofproto/ofproto.c22
-rw-r--r--ofproto/private.h3
2 files changed, 22 insertions, 3 deletions
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index ff5cb0149..27c370e2d 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1990,6 +1990,7 @@ handle_aggregate_stats_request(struct ofconn *ofconn,
struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct flow_stats_request request;
struct ofputil_aggregate_stats stats;
+ bool unknown_packets, unknown_bytes;
struct ofpbuf *reply;
struct list rules;
struct rule *rule;
@@ -2007,6 +2008,7 @@ handle_aggregate_stats_request(struct ofconn *ofconn,
}
memset(&stats, 0, sizeof stats);
+ unknown_packets = unknown_bytes = false;
LIST_FOR_EACH (rule, ofproto_node, &rules) {
uint64_t packet_count;
uint64_t byte_count;
@@ -2014,10 +2016,26 @@ handle_aggregate_stats_request(struct ofconn *ofconn,
ofproto->ofproto_class->rule_get_stats(rule, &packet_count,
&byte_count);
- stats.packet_count += packet_count;
- stats.byte_count += byte_count;
+ if (packet_count == UINT64_MAX) {
+ unknown_packets = true;
+ } else {
+ stats.packet_count += packet_count;
+ }
+
+ if (byte_count == UINT64_MAX) {
+ unknown_bytes = true;
+ } else {
+ stats.byte_count += byte_count;
+ }
+
stats.flow_count++;
}
+ if (unknown_packets) {
+ stats.packet_count = UINT64_MAX;
+ }
+ if (unknown_bytes) {
+ stats.byte_count = UINT64_MAX;
+ }
reply = ofputil_encode_aggregate_stats_reply(&stats, osm);
ofconn_send_reply(ofconn, reply);
diff --git a/ofproto/private.h b/ofproto/private.h
index 1dca46ec5..41487e7d8 100644
--- a/ofproto/private.h
+++ b/ofproto/private.h
@@ -690,7 +690,8 @@ struct ofproto_class {
/* Obtains statistics for 'rule', storing the number of packets that have
* matched it in '*packet_count' and the number of bytes in those packets
- * in '*byte_count'. */
+ * in '*byte_count'. UINT64_MAX indicates that the packet count or byte
+ * count is unknown. */
void (*rule_get_stats)(struct rule *rule, uint64_t *packet_count,
uint64_t *byte_count);