diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2017-06-01 14:38:29 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2017-06-01 14:38:29 +0000 |
commit | 5ef4e5461b94c69b6dbd62a05e712afe4056f060 (patch) | |
tree | b63be9ac2619f650dd04912224e72b462417da65 /usr.bin | |
parent | 3198637a38915ed04a55611b4783c1f97a5c6dd2 (diff) |
Return time_uptime as value for when pf was enabled instead of
time_second. Since time_second changes depending on the wall-
clock time, time_second is not a reliable source for the status.
We can even end up with a negative time delta. Thus, use the
monotonically growing time_uptime and export it to userland.
ok bluhm@ mikeb@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/systat/pf.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/systat/pf.c b/usr.bin/systat/pf.c index 6e282bb7359..96b214da26d 100644 --- a/usr.bin/systat/pf.c +++ b/usr.bin/systat/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.8 2016/01/02 20:03:28 benno Exp $ */ +/* $OpenBSD: pf.c,v 1.9 2017/06/01 14:38:28 patrick Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org> * @@ -220,7 +220,8 @@ void print_pf(void) { char *debug; - time_t tm; + time_t tm = 0; + struct timespec uptime; int i; struct pf_status *s = &status; @@ -229,7 +230,8 @@ print_pf(void) if (end > num_disp) end = num_disp; - tm = time(NULL) - s->since; + if (!clock_gettime(CLOCK_UPTIME, &uptime)) + tm = uptime.tv_sec - s->since; ADD_LINE_S("pf", "Status", s->running ? "Enabled" : "Disabled"); ADD_LINE_A("pf", "Since", tm); |