From 25a72c9a80157fe87847582f14fa82e0c82a3dbb Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 14 May 2009 16:25:12 -0700 Subject: [PATCH] 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. --- secchan/netflow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 2.30.2