summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcanacar <canacar@openbsd.org>2016-01-16 03:30:26 +0000
committercanacar <canacar@openbsd.org>2016-01-16 03:30:26 +0000
commit5ddc7cc14c69f81eb428c98a483b7bee3b1cf8e0 (patch)
tree90a260699312c2bb4c616410c1adba9267dda428
parentInterface status printing (at exit and USR1) was broken for a while. (diff)
downloadwireguard-openbsd-5ddc7cc14c69f81eb428c98a483b7bee3b1cf8e0.tar.xz
wireguard-openbsd-5ddc7cc14c69f81eb428c98a483b7bee3b1cf8e0.zip
fix a number of minor issues in the state view:
1. peak and rate computations were using uint32 size which caused the fields from working for states that transferred more than 4GB also fix an unnecessary cast to double found while looking for the bug. 2. When creating new cache entries for existing states, start time from 0 rather than the current time to prevent a "spike" in rate and peak.
-rw-r--r--usr.bin/systat/cache.c4
-rw-r--r--usr.bin/systat/cache.h4
-rw-r--r--usr.bin/systat/pftop.c4
3 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/systat/cache.c b/usr.bin/systat/cache.c
index 7f55e645a79..e20c802bbd2 100644
--- a/usr.bin/systat/cache.c
+++ b/usr.bin/systat/cache.c
@@ -1,4 +1,4 @@
-/* $Id: cache.c,v 1.5 2014/10/08 04:10:04 doug Exp $ */
+/* $Id: cache.c,v 1.6 2016/01/16 03:30:26 canacar Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org>
*
@@ -123,7 +123,7 @@ add_state(struct pfsync_state *st)
ent->bytes = COUNTER(st->bytes[0]) + COUNTER(st->bytes[1]);
ent->peak = 0;
ent->rate = 0;
- ent->t = time(NULL);
+ ent->t = 0;
RB_INSERT(sc_tree, &sctree, ent);
TAILQ_INSERT_HEAD(scq_act, ent, qlink);
diff --git a/usr.bin/systat/cache.h b/usr.bin/systat/cache.h
index 5bff5c1ce88..ba875047205 100644
--- a/usr.bin/systat/cache.h
+++ b/usr.bin/systat/cache.h
@@ -1,4 +1,4 @@
-/* $Id: cache.h,v 1.4 2011/11/29 10:19:15 dlg Exp $ */
+/* $Id: cache.h,v 1.5 2016/01/16 03:30:26 canacar Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org>
*
@@ -30,7 +30,7 @@ struct sc_ent {
double peak;
double rate;
time_t t;
- u_int32_t bytes;
+ u_int64_t bytes;
};
int cache_init(int);
diff --git a/usr.bin/systat/pftop.c b/usr.bin/systat/pftop.c
index 33479c5e7b1..cde86867503 100644
--- a/usr.bin/systat/pftop.c
+++ b/usr.bin/systat/pftop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pftop.c,v 1.32 2015/08/20 22:32:42 deraadt Exp $ */
+/* $OpenBSD: pftop.c,v 1.33 2016/01/16 03:30:26 canacar Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar
* Copyright (c) 2001 Daniel Hartmeier
@@ -896,7 +896,7 @@ print_state(struct pfsync_state * s, struct sc_ent * ent)
COUNTER(s->packets[1]));
print_fld_size(FLD_BYTES, sz);
print_fld_rate(FLD_SA, (s->creation) ?
- ((double)sz/ntohl((double)s->creation)) : -1);
+ ((double)sz/(double)ntohl(s->creation)) : -1);
print_fld_uint(FLD_RULE, ntohl(s->rule));
if (cachestates && ent != NULL) {