From: Ben Pfaff Date: Thu, 14 May 2009 23:25:12 +0000 (-0700) Subject: netflow: Report largest possible value when counters exceed 32 bits. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25a72c9a80157fe87847582f14fa82e0c82a3dbb;p=openvswitch netflow: Report largest possible value when counters exceed 32 bits. secchan tracks packets and bytes using 64-bit counters, but the corresponding NetFlow v5 fields are only 32 bits wide. Until now we would just report the lower 32 bits on overflow; this commit changes the behavior to reporting 0xffffffff instead. Bug #1316. --- diff --git a/secchan/netflow.c b/secchan/netflow.c index 16abed94..dc83a9b0 100644 --- a/secchan/netflow.c +++ b/secchan/netflow.c @@ -207,8 +207,8 @@ netflow_expire(struct netflow *nf, const struct ofexpired *expired) nf_rec->nexthop = htons(0); nf_rec->input = htons(expired->flow.in_port); nf_rec->output = htons(0); - nf_rec->packet_count = htonl(expired->packet_count); - nf_rec->byte_count = htonl(expired->byte_count); + nf_rec->packet_count = htonl(MIN(expired->packet_count, UINT32_MAX)); + nf_rec->byte_count = htonl(MIN(expired->byte_count, UINT32_MAX)); nf_rec->init_time = htonl(expired->created - nf->boot_time); nf_rec->used_time = htonl(MAX(expired->created, expired->used) - nf->boot_time);