From 4029c0435aa80f7a301f3915fe5eeaf38cb9ad44 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 28 Feb 2014 13:12:04 -0800 Subject: [PATCH] datapath: Correctly report flow used times for first 5 minutes after boot. The kernel starts out its "jiffies" timer as 5 minutes below zero, as shown in include/linux/jiffies.h: /* * Have the 32 bit jiffies value wrap 5 minutes after boot * so jiffies wrap bugs show up earlier. */ #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ)) The loop in ovs_flow_stats_get() starts out with 'used' set to 0, then takes any "later" time. This means that for the first five minutes after boot, flows will always be reported as never used, since 0 is greater than any time already seen. Bug #1192516. Signed-off-by: Ben Pfaff Acked-by: Pravin B Shelar --- datapath/flow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datapath/flow.c b/datapath/flow.c index c3e3fcb64..e9a2a2725 100644 --- a/datapath/flow.c +++ b/datapath/flow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2013 Nicira, Inc. + * Copyright (c) 2007-2014 Nicira, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -148,7 +148,7 @@ void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats, * block bottom-halves here. */ spin_lock_bh(&stats->lock); - if (time_after(stats->used, *used)) + if (!*used || time_after(stats->used, *used)) *used = stats->used; *tcp_flags |= stats->tcp_flags; ovs_stats->n_packets += stats->packet_count; -- 2.47.0