diff options
author | cheloha <cheloha@openbsd.org> | 2020-05-15 00:56:03 +0000 |
---|---|---|
committer | cheloha <cheloha@openbsd.org> | 2020-05-15 00:56:03 +0000 |
commit | e45b97acc68240287380c19ce0d763926c796dbd (patch) | |
tree | 3a9177dba04e863ce3fa2762be6d85a79102a4fc /usr.sbin/snmpd | |
parent | be little bit more verbose what went wrong in mkostemp (diff) | |
download | wireguard-openbsd-e45b97acc68240287380c19ce0d763926c796dbd.tar.xz wireguard-openbsd-e45b97acc68240287380c19ce0d763926c796dbd.zip |
pf(4): use CLOCK_BOOTTIME to get time_uptime(9) in userspace
In pf(4), the pf_status.since timestamp is set with time_uptime(9).
This is a low-res snapshot of nanouptime(9). nanouptime(9) is used to
implement CLOCK_BOOTTIME for clock_gettime(2). It is not used to
implement CLOCK_UPTIME, though. The names are misleading.
Switch to CLOCK_BOOTTIME in places in userspace where we use
pf_status.since so we are working with the right clock.
Technically CLOCK_MONOTONIC is equivalent, but we shouldn't use that
here. CLOCK_MONOTONIC is not necessarily the "time since boot": the
standard says its absolute value is meaningless.
ok patrick@ bluhm@
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r-- | usr.sbin/snmpd/mib.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c index ac59d669c79..8df725ba2ae 100644 --- a/usr.sbin/snmpd/mib.c +++ b/usr.sbin/snmpd/mib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.c,v 1.98 2020/01/02 10:55:53 florian Exp $ */ +/* $OpenBSD: mib.c,v 1.99 2020/05/15 00:56:03 cheloha Exp $ */ /* * Copyright (c) 2012 Joel Knight <joel@openbsd.org> @@ -1681,7 +1681,7 @@ mib_pfinfo(struct oid *oid, struct ber_oid *o, struct ber_element **elm) *elm = ober_add_integer(*elm, s.running); break; case 2: - if (!clock_gettime(CLOCK_UPTIME, &uptime)) + if (!clock_gettime(CLOCK_BOOTTIME, &uptime)) runtime = uptime.tv_sec - s.since; runtime *= 100; *elm = ober_add_integer(*elm, runtime); |