summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorcheloha <cheloha@openbsd.org>2020-06-24 22:03:40 +0000
committercheloha <cheloha@openbsd.org>2020-06-24 22:03:40 +0000
commit3209772dfcc3950dd5df01bc44eebf75e637511e (patch)
tree674a3736a2e3e277e801c3c22c1430cb8a2d032f /sys
parentFirst stab at making signal handling work. (diff)
downloadwireguard-openbsd-3209772dfcc3950dd5df01bc44eebf75e637511e.tar.xz
wireguard-openbsd-3209772dfcc3950dd5df01bc44eebf75e637511e.zip
kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)
time_second(9) and time_uptime(9) are widely used in the kernel to quickly get the system UTC or system uptime as a time_t. However, time_t is 64-bit everywhere, so it is not generally safe to use them on 32-bit platforms: you have a split-read problem if your hardware cannot perform atomic 64-bit reads. This patch replaces time_second(9) with gettime(9), a safer successor interface, throughout the kernel. Similarly, time_uptime(9) is replaced with getuptime(9). There is a performance cost on 32-bit platforms in exchange for eliminating the split-read problem: instead of two register reads you now have a lockless read loop to pull the values from the timehands. This is really not *too* bad in the grand scheme of things, but compared to what we were doing before it is several times slower. There is no performance cost on 64-bit (__LP64__) platforms. With input from visa@, dlg@, and tedu@. Several bugs squashed by visa@. ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/i386/apm.c4
-rw-r--r--sys/arch/loongson/dev/apm.c4
-rw-r--r--sys/arch/sparc64/sparc64/intr.c6
-rw-r--r--sys/crypto/idgen.c4
-rw-r--r--sys/dev/acpi/acpi.c6
-rw-r--r--sys/dev/gpio/gpiodcf.c6
-rw-r--r--sys/dev/ic/aac.c12
-rw-r--r--sys/dev/ic/ncr53c9x.c6
-rw-r--r--sys/dev/ic/wd33c93.c6
-rw-r--r--sys/dev/pci/drm/include/linux/timekeeping.h2
-rw-r--r--sys/dev/pci/mfii.c4
-rw-r--r--sys/dev/pv/vmmci.c4
-rw-r--r--sys/dev/pv/vmt.c4
-rw-r--r--sys/dev/usb/udcf.c6
-rw-r--r--sys/kern/sysv_msg.c10
-rw-r--r--sys/kern/sysv_sem.c8
-rw-r--r--sys/kern/sysv_shm.c10
-rw-r--r--sys/kern/vfs_sync.c6
-rw-r--r--sys/kern/vfs_syscalls.c4
-rw-r--r--sys/net/bridgectl.c6
-rw-r--r--sys/net/if_bpe.c12
-rw-r--r--sys/net/if_bridge.c6
-rw-r--r--sys/net/if_pflow.c32
-rw-r--r--sys/net/if_pfsync.c26
-rw-r--r--sys/net/if_ppp.c14
-rw-r--r--sys/net/pf.c40
-rw-r--r--sys/net/pf_if.c10
-rw-r--r--sys/net/pf_ioctl.c12
-rw-r--r--sys/net/pf_norm.c8
-rw-r--r--sys/net/pf_table.c20
-rw-r--r--sys/net/route.c8
-rw-r--r--sys/net/rtsock.c10
-rw-r--r--sys/netinet/if_ether.c24
-rw-r--r--sys/netinet/ip_ipsp.c6
-rw-r--r--sys/netinet/ip_output.c4
-rw-r--r--sys/netinet/ip_spd.c6
-rw-r--r--sys/netinet/ipsec_input.c10
-rw-r--r--sys/netinet/ipsec_output.c8
-rw-r--r--sys/netinet6/in6.c18
-rw-r--r--sys/netinet6/in6.h6
-rw-r--r--sys/netinet6/ip6_forward.c10
-rw-r--r--sys/netinet6/ip6_id.c6
-rw-r--r--sys/netinet6/ip6_mroute.c6
-rw-r--r--sys/netinet6/nd6.c24
-rw-r--r--sys/nfs/nfs_subs.c12
-rw-r--r--sys/nfs/nfs_vnops.c6
-rw-r--r--sys/ufs/ext2fs/ext2fs_alloc.c6
-rw-r--r--sys/ufs/ext2fs/ext2fs_vfsops.c10
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c4
-rw-r--r--sys/ufs/ufs/inode.h8
-rw-r--r--sys/ufs/ufs/ufs_quota.c24
-rw-r--r--sys/uvm/uvm_meter.c4
52 files changed, 259 insertions, 259 deletions
diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c
index 840f1f398b7..3fc4cf7d547 100644
--- a/sys/arch/i386/i386/apm.c
+++ b/sys/arch/i386/i386/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.124 2020/05/29 04:42:23 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.125 2020/06/24 22:03:40 cheloha Exp $ */
/*-
* Copyright (c) 1998-2001 Michael Shalayeff. All rights reserved.
@@ -270,7 +270,7 @@ apm_suspend(int state)
i8254_startclock();
if (initclock_func == i8254_initclocks)
rtcstart(); /* in i8254 mode, rtc is profclock */
- inittodr(time_second);
+ inittodr(gettime());
config_suspend_all(DVACT_RESUME);
cold = 0;
diff --git a/sys/arch/loongson/dev/apm.c b/sys/arch/loongson/dev/apm.c
index 42b3d7c61ba..250d69d248e 100644
--- a/sys/arch/loongson/dev/apm.c
+++ b/sys/arch/loongson/dev/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.37 2020/05/29 04:42:24 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.38 2020/06/24 22:03:40 cheloha Exp $ */
/*-
* Copyright (c) 2001 Alexander Guy. All rights reserved.
@@ -415,7 +415,7 @@ apm_suspend(int state)
if (rv == 0)
rv = sys_platform->resume();
}
- inittodr(time_second); /* Move the clock forward */
+ inittodr(gettime()); /* Move the clock forward */
config_suspend_all(DVACT_RESUME);
cold = 0;
diff --git a/sys/arch/sparc64/sparc64/intr.c b/sys/arch/sparc64/sparc64/intr.c
index c5a29a26b34..45abf2f94b7 100644
--- a/sys/arch/sparc64/sparc64/intr.c
+++ b/sys/arch/sparc64/sparc64/intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.c,v 1.60 2020/06/23 01:21:29 jmatthew Exp $ */
+/* $OpenBSD: intr.c,v 1.61 2020/06/24 22:03:40 cheloha Exp $ */
/* $NetBSD: intr.c,v 1.39 2001/07/19 23:38:11 eeh Exp $ */
/*
@@ -102,12 +102,12 @@ strayintr(const struct trapframe64 *fp, int vectored)
"vectored=%d\n", fp->tf_pil, fp->tf_pc, fp->tf_npc,
fp->tf_tstate >> TSTATE_PSTATE_SHIFT, PSTATE_BITS, vectored);
- timesince = time_second - straytime;
+ timesince = gettime() - straytime;
if (timesince <= 10) {
if (++nstray > 500)
panic("crazy interrupts");
} else {
- straytime = time_second;
+ straytime = gettime();
nstray = 1;
}
#ifdef DDB
diff --git a/sys/crypto/idgen.c b/sys/crypto/idgen.c
index 8eba716beda..4ce11b3b0bb 100644
--- a/sys/crypto/idgen.c
+++ b/sys/crypto/idgen.c
@@ -107,7 +107,7 @@ idgen32_rekey(struct idgen32_ctx *ctx)
ctx->id32_hibit ^= 0x80000000;
ctx->id32_offset = arc4random();
arc4random_buf(ctx->id32_key, sizeof(ctx->id32_key));
- ctx->id32_rekey_time = time_uptime + IDGEN32_REKEY_TIME;
+ ctx->id32_rekey_time = getuptime() + IDGEN32_REKEY_TIME;
}
void
@@ -126,7 +126,7 @@ idgen32(struct idgen32_ctx *ctx)
do {
/* Rekey a little early to avoid "card counting" attack */
if (ctx->id32_counter > IDGEN32_REKEY_LIMIT ||
- ctx->id32_rekey_time < time_uptime)
+ ctx->id32_rekey_time < getuptime())
idgen32_rekey(ctx);
ret = ctx->id32_hibit | idgen32_permute(ctx,
(ctx->id32_offset + ctx->id32_counter++) & 0x7fffffff);
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 99babcb5e4f..fc0f53b3cdd 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.387 2020/06/10 22:26:40 jca Exp $ */
+/* $OpenBSD: acpi.c,v 1.388 2020/06/24 22:03:41 cheloha Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -33,6 +33,7 @@
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <sys/sensors.h>
+#include <sys/timetc.h>
#ifdef HIBERNATE
#include <sys/hibernate.h>
@@ -2689,7 +2690,8 @@ fail_suspend:
splx(s);
acpibtn_disable_psw(); /* disable _LID for wakeup */
- inittodr(time_second);
+
+ inittodr(gettime());
/* 3rd resume AML step: _TTS(runstate) */
aml_node_setval(sc, sc->sc_tts, sc->sc_state);
diff --git a/sys/dev/gpio/gpiodcf.c b/sys/dev/gpio/gpiodcf.c
index 714fee43713..b839c60bccc 100644
--- a/sys/dev/gpio/gpiodcf.c
+++ b/sys/dev/gpio/gpiodcf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gpiodcf.c,v 1.8 2020/04/15 04:41:39 cheloha Exp $ */
+/* $OpenBSD: gpiodcf.c,v 1.9 2020/06/24 22:03:41 cheloha Exp $ */
/*
* Copyright (c) 2008 Marc Balmer <mbalmer@openbsd.org>
@@ -348,7 +348,7 @@ gpiodcf_mg_probe(void *xsc)
goto cleanbits;
}
- if (time_second - sc->sc_last_mg < 57) {
+ if (gettime() - sc->sc_last_mg < 57) {
DPRINTF(("\nunexpected gap, resync\n"));
sc->sc_sync = sc->sc_minute = 1;
goto cleanbits;
@@ -457,7 +457,7 @@ gpiodcf_mg_probe(void *xsc)
cleanbits:
timeout_add_msec(&sc->sc_to, T_MGSYNC); /* re-sync in 450 ms */
- sc->sc_last_mg = time_second;
+ sc->sc_last_mg = gettime();
sc->sc_tbits = 0LL;
sc->sc_mask = 1LL;
}
diff --git a/sys/dev/ic/aac.c b/sys/dev/ic/aac.c
index 529b1c70dac..08dcd1e16c4 100644
--- a/sys/dev/ic/aac.c
+++ b/sys/dev/ic/aac.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aac.c,v 1.77 2020/06/24 18:59:30 krw Exp $ */
+/* $OpenBSD: aac.c,v 1.78 2020/06/24 22:03:41 cheloha Exp $ */
/*-
* Copyright (c) 2000 Michael Smith
@@ -1202,7 +1202,7 @@ aac_init(struct aac_softc *sc)
/*
* First wait for the adapter to come ready.
*/
- then = time_uptime;
+ then = getuptime();
for (i = 0; i < AAC_BOOT_TIMEOUT * 1000; i++) {
code = AAC_GET_FWSTATUS(sc);
if (code & AAC_SELF_TEST_FAILED) {
@@ -1315,7 +1315,7 @@ aac_init(struct aac_softc *sc)
ip->HostPhysMemPages =
(ip->HostPhysMemPages + AAC_PAGE_SIZE) / AAC_PAGE_SIZE;
}
- ip->HostElapsedSeconds = time_uptime; /* reset later if invalid */
+ ip->HostElapsedSeconds = getuptime(); /* reset later if invalid */
/*
* Initialise FIB queues. Note that it appears that the layout of the
@@ -1787,7 +1787,7 @@ aac_command_timeout(struct aac_command *cm)
printf("%s: COMMAND %p (flags=%#x) TIMEOUT AFTER %d SECONDS\n",
sc->aac_dev.dv_xname, cm, cm->cm_flags,
- (int)(time_uptime - cm->cm_timestamp));
+ (int)(getuptime() - cm->cm_timestamp));
if (cm->cm_flags & AAC_CMD_TIMEDOUT)
return;
@@ -1818,7 +1818,7 @@ aac_timeout(struct aac_softc *sc)
* Traverse the busy command list and timeout any commands
* that are past their deadline.
*/
- deadline = time_uptime - AAC_CMD_TIMEOUT;
+ deadline = getuptime() - AAC_CMD_TIMEOUT;
TAILQ_FOREACH(cm, &sc->aac_busy, cm_link) {
if (cm->cm_timestamp < deadline)
aac_command_timeout(cm);
@@ -2301,7 +2301,7 @@ aac_scsi_cmd(struct scsi_xfer *xs)
cm->cm_datalen = xs->datalen;
cm->cm_complete = aac_bio_complete;
cm->cm_private = xs;
- cm->cm_timestamp = time_uptime;
+ cm->cm_timestamp = getuptime();
cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE;
cm->cm_blkno = blockno;
cm->cm_bcount = blockcnt;
diff --git a/sys/dev/ic/ncr53c9x.c b/sys/dev/ic/ncr53c9x.c
index 99387156291..b15c3b1f9e7 100644
--- a/sys/dev/ic/ncr53c9x.c
+++ b/sys/dev/ic/ncr53c9x.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncr53c9x.c,v 1.69 2020/04/15 02:18:39 cheloha Exp $ */
+/* $OpenBSD: ncr53c9x.c,v 1.70 2020/06/24 22:03:41 cheloha Exp $ */
/* $NetBSD: ncr53c9x.c,v 1.56 2000/11/30 14:41:46 thorpej Exp $ */
/*
@@ -787,7 +787,7 @@ ncr53c9x_scsi_probe(struct scsi_link *sc_link)
if (li == NULL)
return (ENOMEM);
- li->last_used = time_uptime;
+ li->last_used = getuptime();
li->lun = lun;
s = splbio();
@@ -1000,7 +1000,7 @@ ncr53c9x_sched(sc)
if (lun < NCR_NLUN)
ti->lun[lun] = li;
}
- li->last_used = time_uptime;
+ li->last_used = getuptime();
if (!tag) {
/* Try to issue this as an un-tagged command */
if (!li->untagged)
diff --git a/sys/dev/ic/wd33c93.c b/sys/dev/ic/wd33c93.c
index 5942f965e6b..32d521d52ff 100644
--- a/sys/dev/ic/wd33c93.c
+++ b/sys/dev/ic/wd33c93.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wd33c93.c,v 1.12 2020/06/19 19:18:59 krw Exp $ */
+/* $OpenBSD: wd33c93.c,v 1.13 2020/06/24 22:03:41 cheloha Exp $ */
/* $NetBSD: wd33c93.c,v 1.24 2010/11/13 13:52:02 uebayasi Exp $ */
/*
@@ -678,7 +678,7 @@ wd33c93_sched(struct wd33c93_softc *sc)
if (lun < SBIC_NLUN)
ti->lun[lun] = li;
}
- li->last_used = time_uptime;
+ li->last_used = getuptime();
/*
* We've found a potential command, but is the target/lun busy?
@@ -2284,7 +2284,7 @@ wd33c93_watchdog(void *arg)
struct wd33c93_linfo *li;
int t, s, l;
/* scrub LUN's that have not been used in the last 10min. */
- time_t old = time_uptime - (10 * 60);
+ time_t old = getuptime() - (10 * 60);
for (t = 0; t < SBIC_NTARG; t++) {
ti = &sc->sc_tinfo[t];
diff --git a/sys/dev/pci/drm/include/linux/timekeeping.h b/sys/dev/pci/drm/include/linux/timekeeping.h
index c6aa77583c7..cd596d2e9ec 100644
--- a/sys/dev/pci/drm/include/linux/timekeeping.h
+++ b/sys/dev/pci/drm/include/linux/timekeeping.h
@@ -3,7 +3,7 @@
#ifndef _LINUX_TIMEKEEPING_H
#define _LINUX_TIMEKEEPING_H
-#define get_seconds() time_second
+#define get_seconds() gettime()
#define getrawmonotonic(x) nanouptime(x)
#define ktime_mono_to_real(x) (x)
diff --git a/sys/dev/pci/mfii.c b/sys/dev/pci/mfii.c
index 6c399712763..3eadcdf81db 100644
--- a/sys/dev/pci/mfii.c
+++ b/sys/dev/pci/mfii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfii.c,v 1.70 2020/06/24 18:59:30 krw Exp $ */
+/* $OpenBSD: mfii.c,v 1.71 2020/06/24 22:03:41 cheloha Exp $ */
/*
* Copyright (c) 2012 David Gwynne <dlg@openbsd.org>
@@ -1966,7 +1966,7 @@ mfii_initialise_firmware(struct mfii_softc *sc)
htolem32(&iiq->system_request_frame_base_address_hi,
MFII_DMA_DVA(sc->sc_requests) >> 32);
- iiq->timestamp = htole64(time_uptime);
+ iiq->timestamp = htole64(getuptime());
ccb = scsi_io_get(&sc->sc_iopool, SCSI_NOSLEEP);
if (ccb == NULL) {
diff --git a/sys/dev/pv/vmmci.c b/sys/dev/pv/vmmci.c
index a88d1c35340..deff44ba869 100644
--- a/sys/dev/pv/vmmci.c
+++ b/sys/dev/pv/vmmci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmmci.c,v 1.7 2020/05/29 04:42:25 deraadt Exp $ */
+/* $OpenBSD: vmmci.c,v 1.8 2020/06/24 22:03:40 cheloha Exp $ */
/*
* Copyright (c) 2017 Reyk Floeter <reyk@openbsd.org>
@@ -174,7 +174,7 @@ vmmci_config_change(struct virtio_softc *vsc)
pvbus_reboot(&sc->sc_dev);
break;
case VMMCI_SYNCRTC:
- inittodr(time_second);
+ inittodr(gettime());
sc->sc_cmd = VMMCI_NONE;
break;
default:
diff --git a/sys/dev/pv/vmt.c b/sys/dev/pv/vmt.c
index 2dfeee97d87..e2fefdd112f 100644
--- a/sys/dev/pv/vmt.c
+++ b/sys/dev/pv/vmt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmt.c,v 1.18 2020/05/29 04:42:25 deraadt Exp $ */
+/* $OpenBSD: vmt.c,v 1.19 2020/06/24 22:03:40 cheloha Exp $ */
/*
* Copyright (c) 2007 David Crawshaw <david@zentus.com>
@@ -509,7 +509,7 @@ vmt_update_guest_uptime(struct vmt_softc *sc)
{
/* host wants uptime in hundredths of a second */
if (vm_rpc_send_rpci_tx(sc, "SetGuestInfo %d %lld00",
- VM_GUEST_INFO_UPTIME, (long long)time_uptime) != 0) {
+ VM_GUEST_INFO_UPTIME, (long long)getuptime()) != 0) {
DPRINTF("%s: unable to set guest uptime", DEVNAME(sc));
sc->sc_rpc_error = 1;
}
diff --git a/sys/dev/usb/udcf.c b/sys/dev/usb/udcf.c
index 0d9dac23f74..bf837e1683a 100644
--- a/sys/dev/usb/udcf.c
+++ b/sys/dev/usb/udcf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udcf.c,v 1.63 2019/08/10 23:29:59 cheloha Exp $ */
+/* $OpenBSD: udcf.c,v 1.64 2020/06/24 22:03:41 cheloha Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Marc Balmer <mbalmer@openbsd.org>
@@ -513,7 +513,7 @@ udcf_mg_probe(void *xsc)
goto cleanbits;
}
- if (time_second - sc->sc_last_mg < 57) {
+ if (gettime() - sc->sc_last_mg < 57) {
DPRINTF(("\nunexpected gap, resync\n"));
sc->sc_sync = sc->sc_minute = 1;
goto cleanbits;
@@ -622,7 +622,7 @@ udcf_mg_probe(void *xsc)
cleanbits:
timeout_add_msec(&sc->sc_to, T_MGSYNC); /* re-sync in 450 ms */
- sc->sc_last_mg = time_second;
+ sc->sc_last_mg = gettime();
sc->sc_tbits = 0LL;
sc->sc_mask = 1LL;
}
diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c
index d518837a6aa..d09e3b32e61 100644
--- a/sys/kern/sysv_msg.c
+++ b/sys/kern/sysv_msg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_msg.c,v 1.36 2019/12/30 15:48:12 mpi Exp $ */
+/* $OpenBSD: sysv_msg.c,v 1.37 2020/06/24 22:03:42 cheloha Exp $ */
/* $NetBSD: sysv_msg.c,v 1.19 1996/02/09 19:00:18 christos Exp $ */
/*
* Copyright (c) 2009 Bret S. Lambert <blambert@openbsd.org>
@@ -168,7 +168,7 @@ msgctl1(struct proc *p, int msqid, int cmd, caddr_t buf,
(que->msqid_ds.msg_perm.mode & ~0777) |
(tmp.msg_perm.mode & 0777);
que->msqid_ds.msg_qbytes = tmp.msg_qbytes;
- que->msqid_ds.msg_ctime = time_second;
+ que->msqid_ds.msg_ctime = gettime();
break;
case IPC_STAT:
@@ -414,7 +414,7 @@ que_create(key_t key, struct ucred *cred, int mode)
que->msqid_ds.msg_perm.mode = mode & 0777;
que->msqid_ds.msg_perm.seq = ++sequence & 0x7fff;
que->msqid_ds.msg_qbytes = msginfo.msgmnb;
- que->msqid_ds.msg_ctime = time_second;
+ que->msqid_ds.msg_ctime = gettime();
TAILQ_INIT(&que->que_msgs);
@@ -549,7 +549,7 @@ msg_enqueue(struct que *que, struct msg *msg, struct proc *p)
que->msqid_ds.msg_cbytes += msg->msg_len;
que->msqid_ds.msg_qnum++;
que->msqid_ds.msg_lspid = p->p_p->ps_pid;
- que->msqid_ds.msg_stime = time_second;
+ que->msqid_ds.msg_stime = gettime();
TAILQ_INSERT_TAIL(&que->que_msgs, msg, msg_next);
}
@@ -560,7 +560,7 @@ msg_dequeue(struct que *que, struct msg *msg, struct proc *p)
que->msqid_ds.msg_cbytes -= msg->msg_len;
que->msqid_ds.msg_qnum--;
que->msqid_ds.msg_lrpid = p->p_p->ps_pid;
- que->msqid_ds.msg_rtime = time_second;
+ que->msqid_ds.msg_rtime = gettime();
TAILQ_REMOVE(&que->que_msgs, msg, msg_next);
}
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index b2222ba92ba..f9dc776842b 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_sem.c,v 1.57 2020/01/08 15:03:10 mpi Exp $ */
+/* $OpenBSD: sysv_sem.c,v 1.58 2020/06/24 22:03:42 cheloha Exp $ */
/* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */
/*
@@ -293,7 +293,7 @@ semctl1(struct proc *p, int semid, int semnum, int cmd, union semun *arg,
semaptr->sem_perm.gid = sbuf.sem_perm.gid;
semaptr->sem_perm.mode = (semaptr->sem_perm.mode & ~0777) |
(sbuf.sem_perm.mode & 0777);
- semaptr->sem_ctime = time_second;
+ semaptr->sem_ctime = gettime();
break;
case IPC_STAT:
@@ -478,7 +478,7 @@ sys_semget(struct proc *p, void *v, register_t *retval)
(semseqs[semid] + 1) & 0x7fff;
semaptr_new->sem_nsems = nsems;
semaptr_new->sem_otime = 0;
- semaptr_new->sem_ctime = time_second;
+ semaptr_new->sem_ctime = gettime();
sema[semid] = semaptr_new;
semtot += nsems;
} else {
@@ -743,7 +743,7 @@ done:
semptr->sempid = p->p_p->ps_pid;
}
- semaptr->sem_otime = time_second;
+ semaptr->sem_otime = gettime();
/* Do a wakeup if any semaphore was up'd. */
if (do_wakeup) {
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index 96c5abeea75..1fd99f5b95d 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_shm.c,v 1.76 2020/03/04 08:04:48 anton Exp $ */
+/* $OpenBSD: sysv_shm.c,v 1.77 2020/06/24 22:03:42 cheloha Exp $ */
/* $NetBSD: sysv_shm.c,v 1.50 1998/10/21 22:24:29 tron Exp $ */
/*
@@ -169,7 +169,7 @@ shm_delete_mapping(struct vmspace *vm, struct shmmap_state *shmmap_s)
end = round_page(shmmap_s->va+shmseg->shm_segsz);
uvm_unmap(&vm->vm_map, trunc_page(shmmap_s->va), end);
shmmap_s->shmid = -1;
- shmseg->shm_dtime = time_second;
+ shmseg->shm_dtime = gettime();
if ((--shmseg->shm_nattch <= 0) &&
(shmseg->shm_perm.mode & SHMSEG_REMOVED)) {
shm_deallocate_segment(shmseg);
@@ -286,7 +286,7 @@ sys_shmat(struct proc *p, void *v, register_t *retval)
shmmap_s->va = attach_va;
shmmap_s->shmid = SCARG(uap, shmid);
shmseg->shm_lpid = p->p_p->ps_pid;
- shmseg->shm_atime = time_second;
+ shmseg->shm_atime = gettime();
*retval = attach_va;
return (0);
}
@@ -331,7 +331,7 @@ sys_shmctl(struct proc *p, void *v, register_t *retval)
shmseg->shm_perm.mode =
(shmseg->shm_perm.mode & ~ACCESSPERMS) |
(inbuf.shm_perm.mode & ACCESSPERMS);
- shmseg->shm_ctime = time_second;
+ shmseg->shm_ctime = gettime();
break;
case IPC_RMID:
if ((error = ipcperm(cred, &shmseg->shm_perm, IPC_M)) != 0)
@@ -449,7 +449,7 @@ shmget_allocate_segment(struct proc *p,
shmseg->shm_cpid = p->p_p->ps_pid;
shmseg->shm_lpid = shmseg->shm_nattch = 0;
shmseg->shm_atime = shmseg->shm_dtime = 0;
- shmseg->shm_ctime = time_second;
+ shmseg->shm_ctime = gettime();
shmseg->shm_internal = shm_handle;
*retval = IXSEQ_TO_IPCID(segnum, shmseg->shm_perm);
diff --git a/sys/kern/vfs_sync.c b/sys/kern/vfs_sync.c
index 9a9231a3eee..62693a1d2f0 100644
--- a/sys/kern/vfs_sync.c
+++ b/sys/kern/vfs_sync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_sync.c,v 1.63 2020/01/20 23:21:56 claudio Exp $ */
+/* $OpenBSD: vfs_sync.c,v 1.64 2020/06/24 22:03:41 cheloha Exp $ */
/*
* Portions of this code are:
@@ -142,7 +142,7 @@ syncer_thread(void *arg)
int s;
for (;;) {
- starttime = time_second;
+ starttime = gettime();
/*
* Push files whose dirty time has expired.
@@ -228,7 +228,7 @@ syncer_thread(void *arg)
* matter as we are just trying to generally pace the
* filesystem activity.
*/
- if (time_second == starttime)
+ if (gettime() == starttime)
tsleep_nsec(&lbolt, PPAUSE, "syncer", INFSLP);
}
}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 44dcf3c117e..f195ac991dc 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.344 2020/03/19 13:55:20 anton Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.345 2020/06/24 22:03:42 cheloha Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -251,7 +251,7 @@ update:
*/
error = VFS_MOUNT(mp, fspath, args, &nd, p);
if (!error) {
- mp->mnt_stat.f_ctime = time_second;
+ mp->mnt_stat.f_ctime = gettime();
}
if (mp->mnt_flag & MNT_UPDATE) {
vfs_unbusy(vp->v_mount);
diff --git a/sys/net/bridgectl.c b/sys/net/bridgectl.c
index be0f03a7f70..491770f9543 100644
--- a/sys/net/bridgectl.c
+++ b/sys/net/bridgectl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bridgectl.c,v 1.20 2019/07/09 15:15:49 mpi Exp $ */
+/* $OpenBSD: bridgectl.c,v 1.21 2020/06/24 22:03:42 cheloha Exp $ */
/*
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
@@ -397,9 +397,9 @@ bridge_rtagenode(struct ifnet *ifp, int age)
LIST_FOREACH(n, &sc->sc_rts[i], brt_next) {
/* Cap the expiry time to 'age' */
if (n->brt_ifidx == ifp->if_index &&
- n->brt_age > time_uptime + age &&
+ n->brt_age > getuptime() + age &&
(n->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC)
- n->brt_age = time_uptime + age;
+ n->brt_age = getuptime() + age;
}
}
mtx_leave(&sc->sc_mtx);
diff --git a/sys/net/if_bpe.c b/sys/net/if_bpe.c
index b9a88be8efa..13224499bb1 100644
--- a/sys/net/if_bpe.c
+++ b/sys/net/if_bpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bpe.c,v 1.10 2019/11/07 07:36:31 dlg Exp $ */
+/* $OpenBSD: if_bpe.c,v 1.11 2020/06/24 22:03:43 cheloha Exp $ */
/*
* Copyright (c) 2018 David Gwynne <dlg@openbsd.org>
*
@@ -230,7 +230,7 @@ bpe_entry_valid(struct bpe_softc *sc, const struct bpe_entry *be)
if (be->be_type == BPE_ENTRY_STATIC)
return (1);
- diff = time_uptime - be->be_age;
+ diff = getuptime() - be->be_age;
if (diff < sc->sc_bridge_tmo)
return (1);
@@ -343,7 +343,7 @@ bpe_bridge_age(void *arg)
if (be->be_type != BPE_ENTRY_DYNAMIC)
continue;
- diff = time_uptime - be->be_age;
+ diff = getuptime() - be->be_age;
if (diff < sc->sc_bridge_tmo)
continue;
@@ -402,7 +402,7 @@ bpe_rtfind(struct bpe_softc *sc, struct ifbaconf *baconf)
switch (be->be_type) {
case BPE_ENTRY_DYNAMIC:
- age = time_uptime - be->be_age;
+ age = getuptime() - be->be_age;
bareq.ifba_age = MIN(age, 0xff);
bareq.ifba_flags = IFBAF_DYNAMIC;
break;
@@ -833,7 +833,7 @@ bpe_input_map(struct bpe_softc *sc, const uint8_t *ba, const uint8_t *ca)
if (be == NULL)
new = 1;
else {
- be->be_age = time_uptime; /* only a little bit racy */
+ be->be_age = getuptime(); /* only a little bit racy */
if (be->be_type != BPE_ENTRY_DYNAMIC ||
ETHER_IS_EQ(ba, &be->be_b_da))
@@ -857,7 +857,7 @@ bpe_input_map(struct bpe_softc *sc, const uint8_t *ba, const uint8_t *ca)
memcpy(&be->be_b_da, ba, sizeof(be->be_b_da));
be->be_type = BPE_ENTRY_DYNAMIC;
refcnt_init(&be->be_refs);
- be->be_age = time_uptime;
+ be->be_age = getuptime();
rw_enter_write(&sc->sc_bridge_lock);
num = sc->sc_bridge_num;
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index de8cdfe0d93..5a1ff7884da 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bridge.c,v 1.339 2020/04/12 06:48:46 visa Exp $ */
+/* $OpenBSD: if_bridge.c,v 1.340 2020/06/24 22:03:42 cheloha Exp $ */
/*
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
@@ -1541,7 +1541,7 @@ bridge_ipsec(struct ifnet *ifp, struct ether_header *eh, int hassnap,
if (tdb != NULL && (tdb->tdb_flags & TDBF_INVALID) == 0 &&
tdb->tdb_xform != NULL) {
if (tdb->tdb_first_use == 0) {
- tdb->tdb_first_use = time_second;
+ tdb->tdb_first_use = gettime();
if (tdb->tdb_flags & TDBF_FIRSTUSE)
timeout_add_sec(&tdb->tdb_first_tmo,
tdb->tdb_exp_first_use);
@@ -1586,7 +1586,7 @@ bridge_ipsec(struct ifnet *ifp, struct ether_header *eh, int hassnap,
if ((af == AF_INET) &&
ip_mtudisc && (ip->ip_off & htons(IP_DF)) &&
tdb->tdb_mtu && ntohs(ip->ip_len) > tdb->tdb_mtu &&
- tdb->tdb_mtutimeout > time_second)
+ tdb->tdb_mtutimeout > gettime())
bridge_send_icmp_err(ifp, eh, m,
hassnap, llc, tdb->tdb_mtu,
ICMP_UNREACH, ICMP_UNREACH_NEEDFRAG);
diff --git a/sys/net/if_pflow.c b/sys/net/if_pflow.c
index e78eeb9090d..1d482865013 100644
--- a/sys/net/if_pflow.c
+++ b/sys/net/if_pflow.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pflow.c,v 1.90 2018/07/30 12:22:14 mpi Exp $ */
+/* $OpenBSD: if_pflow.c,v 1.91 2020/06/24 22:03:42 cheloha Exp $ */
/*
* Copyright (c) 2011 Florian Obser <florian@narrans.de>
@@ -734,13 +734,13 @@ copy_flow_ipfix_4_data(struct pflow_ipfix_flow4 *flow1,
* is in the future of the last time a package was seen due to pfsync.
*/
if (st->creation > st->expire)
- flow1->flow_start = flow2->flow_start = htobe64((time_second -
- time_uptime)*1000);
+ flow1->flow_start = flow2->flow_start = htobe64((gettime() -
+ getuptime())*1000);
else
- flow1->flow_start = flow2->flow_start = htobe64((time_second -
- (time_uptime - st->creation))*1000);
- flow1->flow_finish = flow2->flow_finish = htobe64((time_second -
- (time_uptime - st->expire))*1000);
+ flow1->flow_start = flow2->flow_start = htobe64((gettime() -
+ (getuptime() - st->creation))*1000);
+ flow1->flow_finish = flow2->flow_finish = htobe64((gettime() -
+ (getuptime() - st->expire))*1000);
flow1->protocol = flow2->protocol = sk->proto;
flow1->tos = flow2->tos = st->rule.ptr->tos;
@@ -773,13 +773,13 @@ copy_flow_ipfix_6_data(struct pflow_ipfix_flow6 *flow1,
* is in the future of the last time a package was seen due to pfsync.
*/
if (st->creation > st->expire)
- flow1->flow_start = flow2->flow_start = htobe64((time_second -
- time_uptime)*1000);
+ flow1->flow_start = flow2->flow_start = htobe64((gettime() -
+ getuptime())*1000);
else
- flow1->flow_start = flow2->flow_start = htobe64((time_second -
- (time_uptime - st->creation))*1000);
- flow1->flow_finish = flow2->flow_finish = htobe64((time_second -
- (time_uptime - st->expire))*1000);
+ flow1->flow_start = flow2->flow_start = htobe64((gettime() -
+ (getuptime() - st->creation))*1000);
+ flow1->flow_finish = flow2->flow_finish = htobe64((gettime() -
+ (getuptime() - st->expire))*1000);
flow1->protocol = flow2->protocol = sk->proto;
flow1->tos = flow2->tos = st->rule.ptr->tos;
@@ -1082,7 +1082,7 @@ pflow_sendout_v5(struct pflow_softc *sc)
h->count = htons(sc->sc_count);
/* populate pflow_header */
- h->uptime_ms = htonl(time_uptime * 1000);
+ h->uptime_ms = htonl(getuptime() * 1000);
getnanotime(&tv);
h->time_sec = htonl(tv.tv_sec); /* XXX 2038 */
@@ -1145,7 +1145,7 @@ pflow_sendout_ipfix(struct pflow_softc *sc, sa_family_t af)
h10 = mtod(m, struct pflow_v10_header *);
h10->version = htons(PFLOW_PROTO_10);
h10->length = htons(PFLOW_IPFIX_HDRLEN + set_length);
- h10->time_sec = htonl(time_second); /* XXX 2038 */
+ h10->time_sec = htonl(gettime()); /* XXX 2038 */
h10->flow_sequence = htonl(sc->sc_sequence);
sc->sc_sequence += count;
h10->observation_dom = htonl(PFLOW_ENGINE_TYPE);
@@ -1186,7 +1186,7 @@ pflow_sendout_ipfix_tmpl(struct pflow_softc *sc)
h10->version = htons(PFLOW_PROTO_10);
h10->length = htons(PFLOW_IPFIX_HDRLEN + sizeof(struct
pflow_ipfix_tmpl));
- h10->time_sec = htonl(time_second); /* XXX 2038 */
+ h10->time_sec = htonl(gettime()); /* XXX 2038 */
h10->flow_sequence = htonl(sc->sc_sequence);
h10->observation_dom = htonl(PFLOW_ENGINE_TYPE);
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c
index ce9b909d4e7..515504d38e9 100644
--- a/sys/net/if_pfsync.c
+++ b/sys/net/if_pfsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.c,v 1.270 2020/04/12 11:56:52 mpi Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.271 2020/06/24 22:03:43 cheloha Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@@ -590,8 +590,8 @@ pfsync_state_import(struct pfsync_state *sp, int flags)
/* copy to state */
bcopy(&sp->rt_addr, &st->rt_addr, sizeof(st->rt_addr));
- st->creation = time_uptime - ntohl(sp->creation);
- st->expire = time_uptime;
+ st->creation = getuptime() - ntohl(sp->creation);
+ st->expire = getuptime();
if (ntohl(sp->expire)) {
u_int32_t timeout;
@@ -622,7 +622,7 @@ pfsync_state_import(struct pfsync_state *sp, int flags)
st->anchor.ptr = NULL;
st->rt_kif = NULL;
- st->pfsync_time = time_uptime;
+ st->pfsync_time = getuptime();
st->sync_state = PFSYNC_S_NONE;
refcnt_init(&st->refcnt);
@@ -962,10 +962,10 @@ pfsync_in_upd(caddr_t buf, int len, int count, int flags)
if (sync < 2) {
pfsync_alloc_scrub_memory(&sp->dst, &st->dst);
pf_state_peer_ntoh(&sp->dst, &st->dst);
- st->expire = time_uptime;
+ st->expire = getuptime();
st->timeout = sp->timeout;
}
- st->pfsync_time = time_uptime;
+ st->pfsync_time = getuptime();
if (sync) {
pfsyncstat_inc(pfsyncs_stale);
@@ -1036,10 +1036,10 @@ pfsync_in_upd_c(caddr_t buf, int len, int count, int flags)
if (sync < 2) {
pfsync_alloc_scrub_memory(&up->dst, &st->dst);
pf_state_peer_ntoh(&up->dst, &st->dst);
- st->expire = time_uptime;
+ st->expire = getuptime();
st->timeout = up->timeout;
}
- st->pfsync_time = time_uptime;
+ st->pfsync_time = getuptime();
if (sync) {
pfsyncstat_inc(pfsyncs_stale);
@@ -1160,7 +1160,7 @@ pfsync_in_bus(caddr_t buf, int len, int count, int flags)
break;
case PFSYNC_BUS_END:
- if (time_uptime - ntohl(bus->endtime) >=
+ if (getuptime() - ntohl(bus->endtime) >=
sc->sc_ureq_sent) {
/* that's it, we're happy */
sc->sc_ureq_sent = 0;
@@ -1947,7 +1947,7 @@ pfsync_update_state_locked(struct pf_state *st)
st->sync_state);
}
- if (sync || (time_uptime - st->pfsync_time) < 2)
+ if (sync || (getuptime() - st->pfsync_time) < 2)
schednetisr(NETISR_PFSYNC);
}
@@ -1998,7 +1998,7 @@ pfsync_request_full_update(struct pfsync_softc *sc)
{
if (sc->sc_sync_if && ISSET(sc->sc_if.if_flags, IFF_RUNNING)) {
/* Request a full state table update. */
- sc->sc_ureq_sent = time_uptime;
+ sc->sc_ureq_sent = getuptime();
#if NCARP > 0
if (!sc->sc_link_demoted && pfsync_sync_ok)
carp_group_demote_adj(&sc->sc_if, 1,
@@ -2306,7 +2306,7 @@ pfsync_bulk_start(void)
if (TAILQ_EMPTY(&state_list))
pfsync_bulk_status(PFSYNC_BUS_END);
else {
- sc->sc_ureq_received = time_uptime;
+ sc->sc_ureq_received = getuptime();
if (sc->sc_bulk_next == NULL)
sc->sc_bulk_next = TAILQ_FIRST(&state_list);
@@ -2379,7 +2379,7 @@ pfsync_bulk_status(u_int8_t status)
r.subh.count = htons(1);
r.bus.creatorid = pf_status.hostid;
- r.bus.endtime = htonl(time_uptime - sc->sc_ureq_received);
+ r.bus.endtime = htonl(getuptime() - sc->sc_ureq_received);
r.bus.status = status;
pfsync_send_plus(&r, sizeof(r));
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 3f03d18b6ab..19b486a50c3 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ppp.c,v 1.113 2020/05/20 06:44:30 mpi Exp $ */
+/* $OpenBSD: if_ppp.c,v 1.114 2020/06/24 22:03:42 cheloha Exp $ */
/* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */
/*
@@ -294,7 +294,7 @@ pppalloc(pid_t pid)
for (i = 0; i < NUM_NP; ++i)
sc->sc_npmode[i] = NPMODE_ERROR;
ml_init(&sc->sc_npqueue);
- sc->sc_last_sent = sc->sc_last_recv = time_uptime;
+ sc->sc_last_sent = sc->sc_last_recv = getuptime();
return sc;
}
@@ -514,7 +514,7 @@ pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, int flag,
break;
case PPPIOCGIDLE:
- t = time_uptime;
+ t = getuptime();
((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
break;
@@ -744,14 +744,14 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
if (sc->sc_active_filt.bf_insns == 0 ||
bpf_filter(sc->sc_active_filt.bf_insns, (u_char *)m0,
len, 0))
- sc->sc_last_sent = time_uptime;
+ sc->sc_last_sent = getuptime();
*mtod(m0, u_char *) = address;
#else
/*
* Update the time we sent the most recent packet.
*/
- sc->sc_last_sent = time_uptime;
+ sc->sc_last_sent = getuptime();
#endif
}
@@ -1356,14 +1356,14 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
if (sc->sc_active_filt.bf_insns == 0 ||
bpf_filter(sc->sc_active_filt.bf_insns, (u_char *)m,
ilen, 0))
- sc->sc_last_recv = time_uptime;
+ sc->sc_last_recv = getuptime();
*mtod(m, u_char *) = adrs;
#else
/*
* Record the time that we received this packet.
*/
- sc->sc_last_recv = time_uptime;
+ sc->sc_last_recv = getuptime();
#endif
}
diff --git a/sys/net/pf.c b/sys/net/pf.c
index d31ef989743..034c138e234 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.1092 2020/06/17 06:45:22 dlg Exp $ */
+/* $OpenBSD: pf.c,v 1.1093 2020/06/24 22:03:42 cheloha Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -417,13 +417,13 @@ pf_init_threshold(struct pf_threshold *threshold,
threshold->limit = limit * PF_THRESHOLD_MULT;
threshold->seconds = seconds;
threshold->count = 0;
- threshold->last = time_uptime;
+ threshold->last = getuptime();
}
void
pf_add_threshold(struct pf_threshold *threshold)
{
- u_int32_t t = time_uptime, diff = t - threshold->last;
+ u_int32_t t = getuptime(), diff = t - threshold->last;
if (diff >= threshold->seconds)
threshold->count = 0;
@@ -496,7 +496,7 @@ pf_src_connlimit(struct pf_state **state)
}
pfr_insert_kentry((*state)->rule.ptr->overload_tbl,
- &p, time_second);
+ &p, gettime());
/* kill existing states if that's required. */
if ((*state)->rule.ptr->flush) {
@@ -584,7 +584,7 @@ pf_insert_src_node(struct pf_src_node **sn, struct pf_rule *rule,
pool_put(&pf_src_tree_pl, *sn);
return (-1);
}
- (*sn)->creation = time_uptime;
+ (*sn)->creation = getuptime();
(*sn)->rule.ptr->src_nodes++;
if (kif != NULL) {
(*sn)->kif = kif;
@@ -605,7 +605,7 @@ pf_insert_src_node(struct pf_src_node **sn, struct pf_rule *rule,
void
pf_remove_src_node(struct pf_src_node *sn)
{
- if (sn->states > 0 || sn->expire > time_uptime)
+ if (sn->states > 0 || sn->expire > getuptime())
return;
sn->rule.ptr->src_nodes--;
@@ -1187,12 +1187,12 @@ pf_state_export(struct pfsync_state *sp, struct pf_state *st)
/* copy from state */
strlcpy(sp->ifname, st->kif->pfik_name, sizeof(sp->ifname));
memcpy(&sp->rt_addr, &st->rt_addr, sizeof(sp->rt_addr));
- sp->creation = htonl(time_uptime - st->creation);
+ sp->creation = htonl(getuptime() - st->creation);
expire = pf_state_expires(st);
- if (expire <= time_uptime)
+ if (expire <= getuptime())
sp->expire = htonl(0);
else
- sp->expire = htonl(expire - time_uptime);
+ sp->expire = htonl(expire - getuptime());
sp->direction = st->direction;
#if NPFLOG > 0
@@ -1342,7 +1342,7 @@ pf_purge_expired_src_nodes(void)
for (cur = RB_MIN(pf_src_tree, &tree_src_tracking); cur; cur = next) {
next = RB_NEXT(pf_src_tree, &tree_src_tracking, cur);
- if (cur->states == 0 && cur->expire <= time_uptime) {
+ if (cur->states == 0 && cur->expire <= getuptime()) {
next = RB_NEXT(pf_src_tree, &tree_src_tracking, cur);
pf_remove_src_node(cur);
}
@@ -1364,7 +1364,7 @@ pf_src_tree_remove_state(struct pf_state *s)
if (!timeout)
timeout =
pf_default_rule.timeout[PFTM_SRC_NODE];
- sni->sn->expire = time_uptime + timeout;
+ sni->sn->expire = getuptime() + timeout;
}
pool_put(&pf_sn_item_pl, sni);
}
@@ -1477,7 +1477,7 @@ pf_purge_expired_states(u_int32_t maxcheck)
next = TAILQ_NEXT(cur, entry_list);
if ((cur->timeout == PFTM_UNLINKED) ||
- (pf_state_expires(cur) <= time_uptime))
+ (pf_state_expires(cur) <= getuptime()))
SLIST_INSERT_HEAD(&gcl, cur, gc_list);
else
pf_state_unref(cur);
@@ -3976,7 +3976,7 @@ pf_test_rule(struct pf_pdesc *pd, struct pf_rule **rm, struct pf_state **sm,
if (((rule_flag & PFRULE_EXPIRED) == 0) &&
atomic_cas_uint(&r->rule_flag, rule_flag,
rule_flag | PFRULE_EXPIRED) == rule_flag) {
- r->exptime = time_second;
+ r->exptime = gettime();
SLIST_INSERT_HEAD(&pf_rule_gcl, r, gcle);
}
}
@@ -4095,8 +4095,8 @@ pf_create_state(struct pf_pdesc *pd, struct pf_rule *r, struct pf_rule *a,
s->timeout = PFTM_OTHER_FIRST_PACKET;
}
- s->creation = time_uptime;
- s->expire = time_uptime;
+ s->creation = getuptime();
+ s->expire = getuptime();
if (pd->proto == IPPROTO_TCP) {
if (s->state_flags & PFSTATE_SCRUB_TCP &&
@@ -4478,7 +4478,7 @@ pf_tcp_track_full(struct pf_pdesc *pd, struct pf_state **state, u_short *reason,
pf_set_protostate(*state, PF_PEER_BOTH, TCPS_TIME_WAIT);
/* update expire time */
- (*state)->expire = time_uptime;
+ (*state)->expire = getuptime();
if (src->state >= TCPS_FIN_WAIT_2 &&
dst->state >= TCPS_FIN_WAIT_2)
(*state)->timeout = PFTM_TCP_CLOSED;
@@ -4671,7 +4671,7 @@ pf_tcp_track_sloppy(struct pf_pdesc *pd, struct pf_state **state,
pf_set_protostate(*state, PF_PEER_BOTH, TCPS_TIME_WAIT);
/* update expire time */
- (*state)->expire = time_uptime;
+ (*state)->expire = getuptime();
if (src->state >= TCPS_FIN_WAIT_2 &&
dst->state >= TCPS_FIN_WAIT_2)
(*state)->timeout = PFTM_TCP_CLOSED;
@@ -4878,7 +4878,7 @@ pf_test_state(struct pf_pdesc *pd, struct pf_state **state, u_short *reason,
pf_set_protostate(*state, pdst, PFUDPS_MULTIPLE);
/* update expire time */
- (*state)->expire = time_uptime;
+ (*state)->expire = getuptime();
if (src->state == PFUDPS_MULTIPLE &&
dst->state == PFUDPS_MULTIPLE)
(*state)->timeout = PFTM_UDP_MULTIPLE;
@@ -4893,7 +4893,7 @@ pf_test_state(struct pf_pdesc *pd, struct pf_state **state, u_short *reason,
pf_set_protostate(*state, pdst, PFOTHERS_MULTIPLE);
/* update expire time */
- (*state)->expire = time_uptime;
+ (*state)->expire = getuptime();
if (src->state == PFOTHERS_MULTIPLE &&
dst->state == PFOTHERS_MULTIPLE)
(*state)->timeout = PFTM_OTHER_MULTIPLE;
@@ -5045,7 +5045,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **state,
if (ret >= 0)
return (ret);
- (*state)->expire = time_uptime;
+ (*state)->expire = getuptime();
(*state)->timeout = PFTM_ICMP_ERROR_REPLY;
/* translate source/destination address, if necessary */
diff --git a/sys/net/pf_if.c b/sys/net/pf_if.c
index 76bb90b2f91..30552d106f5 100644
--- a/sys/net/pf_if.c
+++ b/sys/net/pf_if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_if.c,v 1.99 2019/11/18 03:23:41 dlg Exp $ */
+/* $OpenBSD: pf_if.c,v 1.100 2020/06/24 22:03:42 cheloha Exp $ */
/*
* Copyright 2005 Henning Brauer <henning@openbsd.org>
@@ -121,7 +121,7 @@ pfi_kif_get(const char *kif_name)
return (NULL);
strlcpy(kif->pfik_name, kif_name, sizeof(kif->pfik_name));
- kif->pfik_tzero = time_second;
+ kif->pfik_tzero = gettime();
TAILQ_INIT(&kif->pfik_dynaddrs);
if (!strcmp(kif->pfik_name, "any")) {
@@ -650,7 +650,7 @@ pfi_update_status(const char *name, struct pf_status *pfs)
RB_FOREACH(p, pfi_ifhead, &pfi_ifs) {
memset(p->pfik_packets, 0, sizeof(p->pfik_packets));
memset(p->pfik_bytes, 0, sizeof(p->pfik_bytes));
- p->pfik_tzero = time_second;
+ p->pfik_tzero = gettime();
}
return;
}
@@ -683,7 +683,7 @@ pfi_update_status(const char *name, struct pf_status *pfs)
if (pfs == NULL) {
memset(p->pfik_packets, 0, sizeof(p->pfik_packets));
memset(p->pfik_bytes, 0, sizeof(p->pfik_bytes));
- p->pfik_tzero = time_second;
+ p->pfik_tzero = gettime();
continue;
}
for (i = 0; i < 2; i++)
@@ -709,7 +709,7 @@ pfi_get_ifaces(const char *name, struct pfi_kif *buf, int *size)
continue;
if (*size > n++) {
if (!p->pfik_tzero)
- p->pfik_tzero = time_second;
+ p->pfik_tzero = gettime();
pfi_kif_ref(p, PFI_KIF_REF_RULE);
if (copyout(p, buf++, sizeof(*buf))) {
pfi_kif_unref(p, PFI_KIF_REF_RULE);
diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c
index 931bdcb98cd..a486745bc1c 100644
--- a/sys/net/pf_ioctl.c
+++ b/sys/net/pf_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_ioctl.c,v 1.352 2020/05/27 11:19:28 mpi Exp $ */
+/* $OpenBSD: pf_ioctl.c,v 1.353 2020/06/24 22:03:42 cheloha Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -1033,9 +1033,9 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
error = EEXIST;
else {
pf_status.running = 1;
- pf_status.since = time_uptime;
+ pf_status.since = getuptime();
if (pf_status.stateid == 0) {
- pf_status.stateid = time_second;
+ pf_status.stateid = gettime();
pf_status.stateid = pf_status.stateid << 32;
}
timeout_add_sec(&pf_purge_to, 1);
@@ -1051,7 +1051,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
error = ENOENT;
else {
pf_status.running = 0;
- pf_status.since = time_uptime;
+ pf_status.since = getuptime();
pf_remove_queues();
DPFPRINTF(LOG_NOTICE, "pf: stopped");
}
@@ -1793,7 +1793,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
memset(pf_status.counters, 0, sizeof(pf_status.counters));
memset(pf_status.fcounters, 0, sizeof(pf_status.fcounters));
memset(pf_status.scounters, 0, sizeof(pf_status.scounters));
- pf_status.since = time_uptime;
+ pf_status.since = getuptime();
PF_UNLOCK();
break;
@@ -2571,7 +2571,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
p = psn->psn_src_nodes;
RB_FOREACH(n, pf_src_tree, &tree_src_tracking) {
- int secs = time_uptime, diff;
+ int secs = getuptime(), diff;
if ((nr + 1) * sizeof(*p) > psn->psn_len)
break;
diff --git a/sys/net/pf_norm.c b/sys/net/pf_norm.c
index 570d0523cfc..0a438543e10 100644
--- a/sys/net/pf_norm.c
+++ b/sys/net/pf_norm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_norm.c,v 1.218 2019/02/28 20:20:47 bluhm Exp $ */
+/* $OpenBSD: pf_norm.c,v 1.219 2020/06/24 22:03:43 cheloha Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@@ -220,7 +220,7 @@ pf_purge_expired_fragments(void)
PF_ASSERT_UNLOCKED();
- expire = time_uptime - pf_default_rule.timeout[PFTM_FRAG];
+ expire = getuptime() - pf_default_rule.timeout[PFTM_FRAG];
PF_FRAG_LOCK();
while ((frag = TAILQ_LAST(&pf_fragqueue, pf_fragqueue)) != NULL) {
@@ -589,7 +589,7 @@ pf_fillup_fragment(struct pf_frnode *key, u_int32_t id,
memset(frag->fr_entries, 0, sizeof(frag->fr_entries));
TAILQ_INIT(&frag->fr_queue);
frag->fr_id = id;
- frag->fr_timeout = time_uptime;
+ frag->fr_timeout = getuptime();
frag->fr_gen = frnode->fn_gen++;
frag->fr_maxlen = frent->fe_len;
frag->fr_holes = 1;
@@ -1352,7 +1352,7 @@ pf_normalize_tcp_stateful(struct pf_pdesc *pd, u_short *reason,
getmicrouptime(&uptime);
if (src->scrub && (src->scrub->pfss_flags & PFSS_PAWS) &&
(uptime.tv_sec - src->scrub->pfss_last.tv_sec > TS_MAX_IDLE ||
- time_uptime - state->creation > TS_MAX_CONN)) {
+ getuptime() - state->creation > TS_MAX_CONN)) {
if (pf_status.debug >= LOG_NOTICE) {
log(LOG_NOTICE, "pf: src idled out of PAWS ");
pf_print_state(state);
diff --git a/sys/net/pf_table.c b/sys/net/pf_table.c
index 487207dcd0e..07ec189a12f 100644
--- a/sys/net/pf_table.c
+++ b/sys/net/pf_table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_table.c,v 1.132 2020/06/04 04:27:51 yasuoka Exp $ */
+/* $OpenBSD: pf_table.c,v 1.133 2020/06/24 22:03:43 cheloha Exp $ */
/*
* Copyright (c) 2002 Cedric Berger
@@ -271,7 +271,7 @@ pfr_add_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
struct pfr_kentry *p, *q;
struct pfr_addr ad;
int i, rv, xadd = 0;
- time_t tzero = time_second;
+ time_t tzero = gettime();
ACCEPT_FLAGS(flags, PFR_FLAG_DUMMY | PFR_FLAG_FEEDBACK);
if (pfr_validate_table(tbl, 0, flags & PFR_FLAG_USERIOCTL))
@@ -438,7 +438,7 @@ pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
struct pfr_kentry *p, *q;
struct pfr_addr ad;
int i, rv, xadd = 0, xdel = 0, xchange = 0;
- time_t tzero = time_second;
+ time_t tzero = gettime();
ACCEPT_FLAGS(flags, PFR_FLAG_DUMMY | PFR_FLAG_FEEDBACK);
if (pfr_validate_table(tbl, ignore_pfrt_flags, flags &
@@ -630,7 +630,7 @@ pfr_get_astats(struct pfr_table *tbl, struct pfr_astats *addr, int *size,
struct pfr_walktree w;
struct pfr_kentryworkq workq;
int rv;
- time_t tzero = time_second;
+ time_t tzero = gettime();
if (pfr_validate_table(tbl, 0, 0))
return (EINVAL);
@@ -703,7 +703,7 @@ pfr_clr_astats(struct pfr_table *tbl, struct pfr_addr *addr, int size,
}
if (!(flags & PFR_FLAG_DUMMY)) {
- pfr_clstats_kentries(&workq, time_second, 0);
+ pfr_clstats_kentries(&workq, gettime(), 0);
}
if (nzero != NULL)
*nzero = xzero;
@@ -1285,7 +1285,7 @@ pfr_add_tables(struct pfr_table *tbl, int size, int *nadd, int flags)
struct pfr_ktableworkq addq, changeq;
struct pfr_ktable *p, *q, *r, key;
int i, rv, xadd = 0;
- time_t tzero = time_second;
+ time_t tzero = gettime();
ACCEPT_FLAGS(flags, PFR_FLAG_DUMMY);
SLIST_INIT(&addq);
@@ -1438,7 +1438,7 @@ pfr_get_tstats(struct pfr_table *filter, struct pfr_tstats *tbl, int *size,
struct pfr_ktable *p;
struct pfr_ktableworkq workq;
int n, nn;
- time_t tzero = time_second;
+ time_t tzero = gettime();
/* XXX PFR_FLAG_CLSTATS disabled */
ACCEPT_FLAGS(flags, PFR_FLAG_ALLRSETS);
@@ -1479,7 +1479,7 @@ pfr_clr_tstats(struct pfr_table *tbl, int size, int *nzero, int flags)
struct pfr_ktableworkq workq;
struct pfr_ktable *p, key;
int i, xzero = 0;
- time_t tzero = time_second;
+ time_t tzero = gettime();
ACCEPT_FLAGS(flags, PFR_FLAG_DUMMY | PFR_FLAG_ADDRSTOO);
SLIST_INIT(&workq);
@@ -1732,7 +1732,7 @@ pfr_ina_commit(struct pfr_table *trs, u_int32_t ticket, int *nadd,
struct pfr_ktableworkq workq;
struct pf_ruleset *rs;
int xadd = 0, xchange = 0;
- time_t tzero = time_second;
+ time_t tzero = gettime();
ACCEPT_FLAGS(flags, PFR_FLAG_DUMMY);
rs = pf_find_ruleset(trs->pfrt_anchor);
@@ -2226,7 +2226,7 @@ pfr_attach_table(struct pf_ruleset *rs, char *name, int intr)
strlcpy(tbl.pfrt_anchor, ac->path, sizeof(tbl.pfrt_anchor));
kt = pfr_lookup_table(&tbl);
if (kt == NULL) {
- kt = pfr_create_ktable(&tbl, time_second, 1, intr);
+ kt = pfr_create_ktable(&tbl, gettime(), 1, intr);
if (kt == NULL)
return (NULL);
if (ac != NULL) {
diff --git a/sys/net/route.c b/sys/net/route.c
index 083f5f3a594..90ccb1ae477 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.393 2020/04/20 17:25:23 krw Exp $ */
+/* $OpenBSD: route.c,v 1.394 2020/06/24 22:03:43 cheloha Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -1469,8 +1469,8 @@ rt_timer_add(struct rtentry *rt, void (*func)(struct rtentry *,
struct rttimer *r;
long current_time;
- current_time = time_uptime;
- rt->rt_expire = time_uptime + queue->rtq_timeout;
+ current_time = getuptime();
+ rt->rt_expire = getuptime() + queue->rtq_timeout;
/*
* If there's already a timer with this action, destroy it before
@@ -1513,7 +1513,7 @@ rt_timer_timer(void *arg)
struct rttimer *r;
long current_time;
- current_time = time_uptime;
+ current_time = getuptime();
NET_LOCK();
LIST_FOREACH(rtq, &rttimer_queue_head, rtq_link) {
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index e00e94997e7..9d4ccadd4e2 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.298 2020/03/24 13:50:18 tobhe Exp $ */
+/* $OpenBSD: rtsock.c,v 1.299 2020/06/24 22:03:42 cheloha Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -1325,8 +1325,8 @@ rtm_setmetrics(u_long which, const struct rt_metrics *in,
if (which & RTV_EXPIRE) {
expire = in->rmx_expire;
if (expire != 0) {
- expire -= time_second;
- expire += time_uptime;
+ expire -= gettime();
+ expire += getuptime();
}
out->rmx_expire = expire;
@@ -1340,8 +1340,8 @@ rtm_getmetrics(const struct rt_kmetrics *in, struct rt_metrics *out)
expire = in->rmx_expire;
if (expire != 0) {
- expire -= time_uptime;
- expire += time_second;
+ expire -= getuptime();
+ expire += gettime();
}
bzero(out, sizeof(*out));
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index f950dbebc33..fceeffc3e10 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.c,v 1.242 2019/11/07 11:23:23 krw Exp $ */
+/* $OpenBSD: if_ether.c,v 1.243 2020/06/24 22:03:43 cheloha Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
@@ -120,7 +120,7 @@ arptimer(void *arg)
LIST_FOREACH_SAFE(la, &arp_list, la_list, nla) {
struct rtentry *rt = la->la_rt;
- if (rt->rt_expire && rt->rt_expire < time_uptime)
+ if (rt->rt_expire && rt->rt_expire < getuptime())
arptfree(rt); /* timer has expired; clear */
}
NET_UNLOCK();
@@ -192,7 +192,7 @@ arp_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt)
la->la_rt = rt;
rt->rt_flags |= RTF_LLINFO;
if ((rt->rt_flags & RTF_LOCAL) == 0)
- rt->rt_expire = time_uptime;
+ rt->rt_expire = getuptime();
LIST_INSERT_HEAD(&arp_list, la, la_list);
break;
@@ -320,7 +320,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
rt = rt_getll(rt0);
if (ISSET(rt->rt_flags, RTF_REJECT) &&
- (rt->rt_expire == 0 || rt->rt_expire > time_uptime )) {
+ (rt->rt_expire == 0 || rt->rt_expire > getuptime() )) {
m_freem(m);
return (rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}
@@ -348,15 +348,15 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
* Check the address family and length is valid, the address
* is resolved; otherwise, try to resolve.
*/
- if ((rt->rt_expire == 0 || rt->rt_expire > time_uptime) &&
+ if ((rt->rt_expire == 0 || rt->rt_expire > getuptime()) &&
sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) {
memcpy(desten, LLADDR(sdl), sdl->sdl_alen);
/* refresh ARP entry when timeout gets close */
if (rt->rt_expire != 0 &&
- rt->rt_expire - arpt_keep / 8 < time_uptime &&
- la->la_refreshed + 30 < time_uptime) {
- la->la_refreshed = time_uptime;
+ rt->rt_expire - arpt_keep / 8 < getuptime() &&
+ la->la_refreshed + 30 < getuptime()) {
+ la->la_refreshed = getuptime();
arprequest(ifp,
&satosin(rt->rt_ifa->ifa_addr)->sin_addr.s_addr,
&satosin(dst)->sin_addr.s_addr,
@@ -396,13 +396,13 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
/* This should never happen. (Should it? -gwr) */
printf("%s: unresolved and rt_expire == 0\n", __func__);
/* Set expiration time to now (expired). */
- rt->rt_expire = time_uptime;
+ rt->rt_expire = getuptime();
}
#endif
if (rt->rt_expire) {
rt->rt_flags &= ~RTF_REJECT;
- if (la->la_asked == 0 || rt->rt_expire != time_uptime) {
- rt->rt_expire = time_uptime;
+ if (la->la_asked == 0 || rt->rt_expire != getuptime()) {
+ rt->rt_expire = getuptime();
if (la->la_asked++ < arp_maxtries)
arprequest(ifp,
&satosin(rt->rt_ifa->ifa_addr)->sin_addr.s_addr,
@@ -661,7 +661,7 @@ arpcache(struct ifnet *ifp, struct ether_arp *ea, struct rtentry *rt)
sdl->sdl_alen = sizeof(ea->arp_sha);
memcpy(LLADDR(sdl), ea->arp_sha, sizeof(ea->arp_sha));
if (rt->rt_expire)
- rt->rt_expire = time_uptime + arpt_keep;
+ rt->rt_expire = getuptime() + arpt_keep;
rt->rt_flags &= ~RTF_REJECT;
/* Notify userland that an ARP resolution has been done. */
diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c
index 8405bb5c18f..1755056a647 100644
--- a/sys/netinet/ip_ipsp.c
+++ b/sys/netinet/ip_ipsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.c,v 1.235 2020/04/23 19:38:08 tobhe Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.236 2020/06/24 22:03:43 cheloha Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -708,7 +708,7 @@ puttdb(struct tdb *tdbp)
ipsecstat_inc(ipsec_tunnels);
#endif /* IPSEC */
- ipsec_last_added = time_uptime;
+ ipsec_last_added = getuptime();
}
void
@@ -804,7 +804,7 @@ tdb_alloc(u_int rdomain)
TAILQ_INIT(&tdbp->tdb_policy_head);
/* Record establishment time. */
- tdbp->tdb_established = time_second;
+ tdbp->tdb_established = gettime();
/* Save routing domain */
tdbp->tdb_rdomain = rdomain;
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 2fca6974b35..788f47da48d 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.356 2020/03/06 10:40:13 tobhe Exp $ */
+/* $OpenBSD: ip_output.c,v 1.357 2020/06/24 22:03:43 cheloha Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -589,7 +589,7 @@ ip_output_ipsec_send(struct tdb *tdb, struct mbuf *m, struct route *ro, int fwd)
ip = mtod(m, struct ip *);
if (ip_mtudisc && (ip->ip_off & htons(IP_DF)) && tdb->tdb_mtu &&
ntohs(ip->ip_len) > tdb->tdb_mtu &&
- tdb->tdb_mtutimeout > time_second) {
+ tdb->tdb_mtutimeout > gettime()) {
struct rtentry *rt = NULL;
int rt_mtucloned = 0;
int transportmode = 0;
diff --git a/sys/netinet/ip_spd.c b/sys/netinet/ip_spd.c
index 727cad81994..9487ee4893d 100644
--- a/sys/netinet/ip_spd.c
+++ b/sys/netinet/ip_spd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_spd.c,v 1.101 2019/12/10 17:58:54 tobhe Exp $ */
+/* $OpenBSD: ip_spd.c,v 1.102 2020/06/24 22:03:43 cheloha Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -438,7 +438,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction,
if (ipo->ipo_last_searched <= ipsec_last_added) {
/* "Touch" the entry. */
if (dignore == 0)
- ipo->ipo_last_searched = time_uptime;
+ ipo->ipo_last_searched = getuptime();
/* Find an appropriate SA from the existing ones. */
ipo->ipo_tdb =
@@ -560,7 +560,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction,
/* Find whether there exists an appropriate SA. */
if (ipo->ipo_last_searched <= ipsec_last_added) {
if (dignore == 0)
- ipo->ipo_last_searched = time_uptime;
+ ipo->ipo_last_searched = getuptime();
ipo->ipo_tdb =
gettdbbysrc(rdomain,
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index 7303c3cb303..050dc7b1128 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.170 2020/04/23 19:38:08 tobhe Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.171 2020/06/24 22:03:43 cheloha Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -316,7 +316,7 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto,
/* Register first use, setup expiration timer. */
if (tdbp->tdb_first_use == 0) {
- tdbp->tdb_first_use = time_second;
+ tdbp->tdb_first_use = gettime();
if (tdbp->tdb_flags & TDBF_FIRSTUSE)
timeout_add_sec(&tdbp->tdb_first_tmo,
tdbp->tdb_exp_first_use);
@@ -453,7 +453,7 @@ ipsec_common_input_cb(struct mbuf *m, struct tdb *tdbp, int skip, int protoff)
af = tdbp->tdb_dst.sa.sa_family;
sproto = tdbp->tdb_sproto;
- tdbp->tdb_last_used = time_second;
+ tdbp->tdb_last_used = gettime();
/* Sanity check */
if (m == NULL) {
@@ -984,7 +984,7 @@ ipsec_common_ctlinput(u_int rdomain, int cmd, struct sockaddr *sa,
/* Store adjusted MTU in tdb */
tdbp->tdb_mtu = mtu;
- tdbp->tdb_mtutimeout = time_second +
+ tdbp->tdb_mtutimeout = gettime() +
ip_mtudisc_timeout;
DPRINTF(("%s: spi %08x mtu %d adjust %ld\n", __func__,
ntohl(tdbp->tdb_spi), tdbp->tdb_mtu,
@@ -1039,7 +1039,7 @@ udpencap_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v)
if ((adjust = ipsec_hdrsz(tdbp)) != -1) {
/* Store adjusted MTU in tdb */
tdbp->tdb_mtu = mtu - adjust;
- tdbp->tdb_mtutimeout = time_second +
+ tdbp->tdb_mtutimeout = gettime() +
ip_mtudisc_timeout;
DPRINTF(("%s: spi %08x mtu %d adjust %ld\n",
__func__,
diff --git a/sys/netinet/ipsec_output.c b/sys/netinet/ipsec_output.c
index c5a13312f67..ed4551d1f47 100644
--- a/sys/netinet/ipsec_output.c
+++ b/sys/netinet/ipsec_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_output.c,v 1.76 2020/04/23 19:38:09 tobhe Exp $ */
+/* $OpenBSD: ipsec_output.c,v 1.77 2020/06/24 22:03:43 cheloha Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -135,7 +135,7 @@ ipsp_process_packet(struct mbuf *m, struct tdb *tdb, int af, int tunalready)
* Register first use if applicable, setup relevant expiration timer.
*/
if (tdb->tdb_first_use == 0) {
- tdb->tdb_first_use = time_second;
+ tdb->tdb_first_use = gettime();
if (tdb->tdb_flags & TDBF_FIRSTUSE)
timeout_add_sec(&tdb->tdb_first_tmo,
tdb->tdb_exp_first_use);
@@ -474,7 +474,7 @@ ipsp_process_done(struct mbuf *m, struct tdb *tdb)
struct m_tag *mtag;
int roff, error;
- tdb->tdb_last_used = time_second;
+ tdb->tdb_last_used = gettime();
if ((tdb->tdb_flags & TDBF_UDPENCAP) != 0) {
struct mbuf *mi;
@@ -698,7 +698,7 @@ ipsec_adjust_mtu(struct mbuf *m, u_int32_t mtu)
mtu -= adjust;
tdbp->tdb_mtu = mtu;
- tdbp->tdb_mtutimeout = time_second + ip_mtudisc_timeout;
+ tdbp->tdb_mtutimeout = gettime() + ip_mtudisc_timeout;
DPRINTF(("ipsec_adjust_mtu: "
"spi %08x mtu %d adjust %ld mbuf %p\n",
ntohl(tdbp->tdb_spi), tdbp->tdb_mtu,
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index ca8c78c7b9f..6189bca7c02 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6.c,v 1.236 2020/05/27 11:19:29 mpi Exp $ */
+/* $OpenBSD: in6.c,v 1.237 2020/06/24 22:03:44 cheloha Exp $ */
/* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */
/*
@@ -469,8 +469,8 @@ in6_ioctl_get(u_long cmd, caddr_t data, struct ifnet *ifp)
expire = ia6->ia6_updatetime +
ia6->ia6_lifetime.ia6t_vltime;
if (expire != 0) {
- expire -= time_uptime;
- expire += time_second;
+ expire -= getuptime();
+ expire += gettime();
}
retlt->ia6t_expire = expire;
} else
@@ -492,8 +492,8 @@ in6_ioctl_get(u_long cmd, caddr_t data, struct ifnet *ifp)
expire = ia6->ia6_updatetime +
ia6->ia6_lifetime.ia6t_pltime;
if (expire != 0) {
- expire -= time_uptime;
- expire += time_second;
+ expire -= getuptime();
+ expire += gettime();
}
retlt->ia6t_preferred = expire;
} else
@@ -646,7 +646,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
ia6->ia_ifa.ifa_addr = sin6tosa(&ia6->ia_addr);
ia6->ia_addr.sin6_family = AF_INET6;
ia6->ia_addr.sin6_len = sizeof(ia6->ia_addr);
- ia6->ia6_updatetime = time_uptime;
+ ia6->ia6_updatetime = getuptime();
if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) != 0) {
/*
* XXX: some functions expect that ifa_dstaddr is not
@@ -706,16 +706,16 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
* to see if the address is deprecated or invalidated, but initialize
* these members for applications.
*/
- ia6->ia6_updatetime = time_uptime;
+ ia6->ia6_updatetime = getuptime();
ia6->ia6_lifetime = ifra->ifra_lifetime;
if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
ia6->ia6_lifetime.ia6t_expire =
- time_uptime + ia6->ia6_lifetime.ia6t_vltime;
+ getuptime() + ia6->ia6_lifetime.ia6t_vltime;
} else
ia6->ia6_lifetime.ia6t_expire = 0;
if (ia6->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
ia6->ia6_lifetime.ia6t_preferred =
- time_uptime + ia6->ia6_lifetime.ia6t_pltime;
+ getuptime() + ia6->ia6_lifetime.ia6t_pltime;
} else
ia6->ia6_lifetime.ia6t_preferred = 0;
diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h
index 6ab33419335..5e51cbb17b8 100644
--- a/sys/netinet6/in6.h
+++ b/sys/netinet6/in6.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6.h,v 1.105 2019/11/11 17:42:29 bluhm Exp $ */
+/* $OpenBSD: in6.h,v 1.106 2020/06/24 22:03:44 cheloha Exp $ */
/* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
/*
@@ -280,11 +280,11 @@ struct route_in6 {
#define IFA6_IS_DEPRECATED(a) \
((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
- (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
+ (u_int32_t)((getuptime() - (a)->ia6_updatetime)) > \
(a)->ia6_lifetime.ia6t_pltime)
#define IFA6_IS_INVALID(a) \
((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
- (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
+ (u_int32_t)((getuptime() - (a)->ia6_updatetime)) > \
(a)->ia6_lifetime.ia6t_vltime)
#endif /* _KERNEL */
diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c
index b254756a33b..e47047e31f1 100644
--- a/sys/netinet6/ip6_forward.c
+++ b/sys/netinet6/ip6_forward.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_forward.c,v 1.97 2017/11/28 15:32:51 mpi Exp $ */
+/* $OpenBSD: ip6_forward.c,v 1.98 2020/06/24 22:03:44 cheloha Exp $ */
/* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */
/*
@@ -104,8 +104,8 @@ ip6_forward(struct mbuf *m, struct rtentry *rt, int srcrt)
IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
ip6stat_inc(ip6s_cantforward);
- if (ip6_log_time + ip6_log_interval < time_uptime) {
- ip6_log_time = time_uptime;
+ if (ip6_log_time + ip6_log_interval < getuptime()) {
+ ip6_log_time = getuptime();
inet_ntop(AF_INET6, &ip6->ip6_src, src6, sizeof(src6));
inet_ntop(AF_INET6, &ip6->ip6_dst, dst6, sizeof(dst6));
log(LOG_DEBUG,
@@ -193,8 +193,8 @@ reroute:
ip6stat_inc(ip6s_cantforward);
ip6stat_inc(ip6s_badscope);
- if (ip6_log_time + ip6_log_interval < time_uptime) {
- ip6_log_time = time_uptime;
+ if (ip6_log_time + ip6_log_interval < getuptime()) {
+ ip6_log_time = getuptime();
inet_ntop(AF_INET6, &ip6->ip6_src, src6, sizeof(src6));
inet_ntop(AF_INET6, &ip6->ip6_dst, dst6, sizeof(dst6));
log(LOG_DEBUG,
diff --git a/sys/netinet6/ip6_id.c b/sys/netinet6/ip6_id.c
index 6225e73c1e6..40584a18cdf 100644
--- a/sys/netinet6/ip6_id.c
+++ b/sys/netinet6/ip6_id.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_id.c,v 1.13 2017/09/08 05:36:53 deraadt Exp $ */
+/* $OpenBSD: ip6_id.c,v 1.14 2020/06/24 22:03:44 cheloha Exp $ */
/* $NetBSD: ip6_id.c,v 1.7 2003/09/13 21:32:59 itojun Exp $ */
/* $KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $ */
@@ -196,7 +196,7 @@ ip6id_initid(struct randomtab *p)
p->ru_g = ip6id_pmod(p->ru_gen, j, p->ru_n);
p->ru_counter = 0;
- p->ru_reseed = time_uptime + p->ru_out;
+ p->ru_reseed = getuptime() + p->ru_out;
p->ru_msb = p->ru_msb ? 0 : (1U << (p->ru_bits - 1));
}
@@ -205,7 +205,7 @@ ip6id_randomid(struct randomtab *p)
{
int i, n;
- if (p->ru_counter >= p->ru_max || time_uptime > p->ru_reseed)
+ if (p->ru_counter >= p->ru_max || getuptime() > p->ru_reseed)
ip6id_initid(p);
/* Skip a random number of ids */
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index ee14687b2ce..4f0e96dab69 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_mroute.c,v 1.124 2020/05/27 11:19:29 mpi Exp $ */
+/* $OpenBSD: ip6_mroute.c,v 1.125 2020/06/24 22:03:44 cheloha Exp $ */
/* $NetBSD: ip6_mroute.c,v 1.59 2003/12/10 09:28:38 itojun Exp $ */
/* $KAME: ip6_mroute.c,v 1.45 2001/03/25 08:38:51 itojun Exp $ */
@@ -903,10 +903,10 @@ ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
*/
if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
ip6stat_inc(ip6s_cantforward);
- if (ip6_log_time + ip6_log_interval < time_uptime) {
+ if (ip6_log_time + ip6_log_interval < getuptime()) {
char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN];
- ip6_log_time = time_uptime;
+ ip6_log_time = getuptime();
inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src));
inet_ntop(AF_INET6, &ip6->ip6_dst, dst, sizeof(dst));
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 118afe3c916..4fb528b2a28 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.232 2020/05/27 11:19:29 mpi Exp $ */
+/* $OpenBSD: nd6.c,v 1.233 2020/06/24 22:03:44 cheloha Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -67,8 +67,8 @@
#define ND6_RECALC_REACHTM_INTERVAL (60 * 120) /* 2 hours */
/* timer values */
-int nd6_timer_next = -1; /* at which time_uptime nd6_timer runs */
-time_t nd6_expire_next = -1; /* at which time_uptime nd6_expire runs */
+int nd6_timer_next = -1; /* at which uptime nd6_timer runs */
+time_t nd6_expire_next = -1; /* at which uptime nd6_expire runs */
int nd6_delay = 5; /* delay first probe time 5 second */
int nd6_umaxtries = 3; /* maximum unicast query */
int nd6_mmaxtries = 3; /* maximum multicast query */
@@ -303,7 +303,7 @@ skip1:
void
nd6_llinfo_settimer(struct llinfo_nd6 *ln, unsigned int secs)
{
- time_t expire = time_uptime + secs;
+ time_t expire = getuptime() + secs;
NET_ASSERT_LOCKED();
KASSERT(!ISSET(ln->ln_rt->rt_flags, RTF_LOCAL));
@@ -319,14 +319,14 @@ void
nd6_timer(void *arg)
{
struct llinfo_nd6 *ln, *nln;
- time_t expire = time_uptime + nd6_gctimer;
+ time_t expire = getuptime() + nd6_gctimer;
int secs;
NET_LOCK();
TAILQ_FOREACH_SAFE(ln, &nd6_list, ln_list, nln) {
struct rtentry *rt = ln->ln_rt;
- if (rt->rt_expire && rt->rt_expire <= time_uptime)
+ if (rt->rt_expire && rt->rt_expire <= getuptime())
if (nd6_llinfo_timer(rt))
continue;
@@ -334,11 +334,11 @@ nd6_timer(void *arg)
expire = rt->rt_expire;
}
- secs = expire - time_uptime;
+ secs = expire - getuptime();
if (secs < 0)
secs = 0;
if (!TAILQ_EMPTY(&nd6_list)) {
- nd6_timer_next = time_uptime + secs;
+ nd6_timer_next = getuptime() + secs;
timeout_add_sec(&nd6_timer_to, secs);
}
@@ -469,7 +469,7 @@ nd6_expire_timer_update(struct in6_ifaddr *ia6)
if (!timeout_pending(&nd6_expire_timeout) ||
nd6_expire_next > expire_time) {
- secs = expire_time - time_uptime;
+ secs = expire_time - getuptime();
if (secs < 0)
secs = 0;
@@ -1054,8 +1054,8 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
}
expire = ln->ln_rt->rt_expire;
if (expire != 0) {
- expire -= time_uptime;
- expire += time_second;
+ expire -= getuptime();
+ expire += gettime();
}
nbi->state = ln->ln_state;
@@ -1336,7 +1336,7 @@ nd6_resolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
rt = rt_getll(rt0);
if (ISSET(rt->rt_flags, RTF_REJECT) &&
- (rt->rt_expire == 0 || time_uptime < rt->rt_expire)) {
+ (rt->rt_expire == 0 || getuptime() < rt->rt_expire)) {
m_freem(m);
return (rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}
diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c
index 1ed9932b703..2c6a0cc1c3f 100644
--- a/sys/nfs/nfs_subs.c
+++ b/sys/nfs/nfs_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_subs.c,v 1.143 2020/01/20 23:21:56 claudio Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.144 2020/06/24 22:03:44 cheloha Exp $ */
/* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */
/*
@@ -1092,7 +1092,7 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp,
} else
np->n_size = vap->va_size;
}
- np->n_attrstamp = time_second;
+ np->n_attrstamp = gettime();
if (vaper != NULL) {
bcopy(vap, vaper, sizeof(*vap));
if (np->n_flag & NCHG) {
@@ -1110,7 +1110,7 @@ nfs_attrtimeo(struct nfsnode *np)
{
struct vnode *vp = np->n_vnode;
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- int tenthage = (time_second - np->n_mtime.tv_sec) / 10;
+ int tenthage = (gettime() - np->n_mtime.tv_sec) / 10;
int minto, maxto;
if (vp->v_type == VDIR) {
@@ -1142,7 +1142,7 @@ nfs_getattrcache(struct vnode *vp, struct vattr *vaper)
struct vattr *vap;
if (np->n_attrstamp == 0 ||
- (time_second - np->n_attrstamp) >= nfs_attrtimeo(np)) {
+ (gettime() - np->n_attrstamp) >= nfs_attrtimeo(np)) {
nfsstats.attrcache_misses++;
return (ENOENT);
}
@@ -1751,7 +1751,7 @@ nfsm_v3attrbuild(struct mbuf **mp, struct vattr *a, int full)
*tl = nfs_false;
}
if (a->va_atime.tv_nsec != VNOVAL) {
- if (a->va_atime.tv_sec != time_second) {
+ if (a->va_atime.tv_sec != gettime()) {
tl = nfsm_build(&mb, 3 * NFSX_UNSIGNED);
*tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
txdr_nfsv3time(&a->va_atime, tl);
@@ -1764,7 +1764,7 @@ nfsm_v3attrbuild(struct mbuf **mp, struct vattr *a, int full)
*tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);
}
if (a->va_mtime.tv_nsec != VNOVAL) {
- if (a->va_mtime.tv_sec != time_second) {
+ if (a->va_mtime.tv_sec != gettime()) {
tl = nfsm_build(&mb, 3 * NFSX_UNSIGNED);
*tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
txdr_nfsv3time(&a->va_mtime, tl);
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index 5d78232ac57..88665f9a3ef 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vnops.c,v 1.182 2020/01/20 23:21:56 claudio Exp $ */
+/* $OpenBSD: nfs_vnops.c,v 1.183 2020/06/24 22:03:44 cheloha Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */
/*
@@ -342,7 +342,7 @@ nfs_access(void *v)
* shortly before, use the cached result.
*/
cachevalid = (np->n_accstamp != -1 &&
- (time_second - np->n_accstamp) < nfs_attrtimeo(np) &&
+ (gettime() - np->n_accstamp) < nfs_attrtimeo(np) &&
np->n_accuid == ap->a_cred->cr_uid);
if (cachevalid) {
@@ -423,7 +423,7 @@ nfs_access(void *v)
np->n_accmode = ap->a_mode;
}
} else {
- np->n_accstamp = time_second;
+ np->n_accstamp = gettime();
np->n_accuid = ap->a_cred->cr_uid;
np->n_accmode = ap->a_mode;
np->n_accerror = error;
diff --git a/sys/ufs/ext2fs/ext2fs_alloc.c b/sys/ufs/ext2fs/ext2fs_alloc.c
index 5de799e2c8c..d46bd2ab899 100644
--- a/sys/ufs/ext2fs/ext2fs_alloc.c
+++ b/sys/ufs/ext2fs/ext2fs_alloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ext2fs_alloc.c,v 1.36 2016/06/03 18:00:10 natano Exp $ */
+/* $OpenBSD: ext2fs_alloc.c,v 1.37 2020/06/24 22:03:44 cheloha Exp $ */
/* $NetBSD: ext2fs_alloc.c,v 1.10 2001/07/05 08:38:27 toshii Exp $ */
/*
@@ -170,8 +170,8 @@ ext2fs_inode_alloc(struct inode *pip, mode_t mode, struct ucred *cred,
/*
* Set up a new generation number for this inode.
*/
- if (++ext2gennumber < (u_long)time_second)
- ext2gennumber = time_second;
+ if (++ext2gennumber < (u_long)gettime())
+ ext2gennumber = gettime();
ip->i_e2fs_gen = ext2gennumber;
return (0);
noinodes:
diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c
index 0951da816fe..4561dda88be 100644
--- a/sys/ufs/ext2fs/ext2fs_vfsops.c
+++ b/sys/ufs/ext2fs/ext2fs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ext2fs_vfsops.c,v 1.114 2019/12/26 13:28:49 bluhm Exp $ */
+/* $OpenBSD: ext2fs_vfsops.c,v 1.115 2020/06/24 22:03:44 cheloha Exp $ */
/* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */
/*
@@ -267,7 +267,7 @@ ext2fs_mount(struct mount *mp, const char *path, void *data,
if (fs->e2fs_fmod != 0) { /* XXX */
fs->e2fs_fmod = 0;
if (fs->e2fs.e2fs_state == 0)
- fs->e2fs.e2fs_wtime = time_second;
+ fs->e2fs.e2fs_wtime = gettime();
else
printf("%s: file system not clean; please fsck(8)\n",
mp->mnt_stat.f_mntfromname);
@@ -811,7 +811,7 @@ ext2fs_sync(struct mount *mp, int waitfor, int stall,
}
if (fs->e2fs_fmod != 0) {
fs->e2fs_fmod = 0;
- fs->e2fs.e2fs_wtime = time_second;
+ fs->e2fs.e2fs_wtime = gettime();
if ((error = ext2fs_cgupdate(ump, waitfor)))
allerror = error;
}
@@ -945,8 +945,8 @@ ext2fs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
* already have one. This should only happen on old filesystems.
*/
if (ip->i_e2fs_gen == 0) {
- if (++ext2gennumber < (u_long)time_second)
- ext2gennumber = time_second;
+ if (++ext2gennumber < (u_long)gettime())
+ ext2gennumber = gettime();
ip->i_e2fs_gen = ext2gennumber;
if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
ip->i_flag |= IN_MODIFIED;
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index b8a7b0a590b..86ff869783d 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_vfsops.c,v 1.184 2020/05/28 15:48:29 otto Exp $ */
+/* $OpenBSD: ffs_vfsops.c,v 1.185 2020/06/24 22:03:45 cheloha Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */
/*
@@ -1525,7 +1525,7 @@ ffs_sbupdate(struct ufsmount *mp, int waitfor)
fs->fs_sblockloc >> (fs->fs_fshift - fs->fs_fsbtodb),
(int)fs->fs_sbsize, 0, INFSLP);
fs->fs_fmod = 0;
- fs->fs_time = time_second;
+ fs->fs_time = gettime();
memcpy(bp->b_data, fs, fs->fs_sbsize);
/* Restore compatibility to old file systems. XXX */
dfs = (struct fs *)bp->b_data; /* XXX */
diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h
index 4530c4e304d..36661588139 100644
--- a/sys/ufs/ufs/inode.h
+++ b/sys/ufs/ufs/inode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: inode.h,v 1.52 2020/05/28 15:48:29 otto Exp $ */
+/* $OpenBSD: inode.h,v 1.53 2020/06/24 22:03:45 cheloha Exp $ */
/* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */
/*
@@ -320,11 +320,11 @@ struct indir {
if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \
(ip)->i_flag |= IN_MODIFIED; \
if ((ip)->i_flag & IN_ACCESS) \
- (ip)->i_e2fs_atime = time_second; \
+ (ip)->i_e2fs_atime = gettime(); \
if ((ip)->i_flag & IN_UPDATE) \
- (ip)->i_e2fs_mtime = time_second; \
+ (ip)->i_e2fs_mtime = gettime(); \
if ((ip)->i_flag & IN_CHANGE) { \
- (ip)->i_e2fs_ctime = time_second; \
+ (ip)->i_e2fs_ctime = gettime(); \
(ip)->i_modrev++; \
} \
(ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \
diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c
index 2db8696154a..118fc068131 100644
--- a/sys/ufs/ufs/ufs_quota.c
+++ b/sys/ufs/ufs/ufs_quota.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_quota.c,v 1.46 2019/11/25 11:33:51 mpi Exp $ */
+/* $OpenBSD: ufs_quota.c,v 1.47 2020/06/24 22:03:45 cheloha Exp $ */
/* $NetBSD: ufs_quota.c,v 1.8 1996/02/09 22:36:09 christos Exp $ */
/*
@@ -283,15 +283,14 @@ chkdqchg(struct inode *ip, long change, struct ucred *cred, int type)
*/
if (ncurblocks >= dq->dq_bsoftlimit && dq->dq_bsoftlimit) {
if (dq->dq_curblocks < dq->dq_bsoftlimit) {
- dq->dq_btime = time_second +
- ip->i_ump->um_btime[type];
+ dq->dq_btime = gettime() + ip->i_ump->um_btime[type];
if (DIP(ip, uid) == cred->cr_uid)
uprintf("\n%s: warning, %s %s\n",
ITOV(ip)->v_mount->mnt_stat.f_mntonname,
quotatypes[type], "disk quota exceeded");
return (0);
}
- if (time_second > dq->dq_btime) {
+ if (gettime() > dq->dq_btime) {
if ((dq->dq_flags & DQ_BLKS) == 0 &&
DIP(ip, uid) == cred->cr_uid) {
uprintf("\n%s: write failed, %s %s\n",
@@ -404,15 +403,14 @@ chkiqchg(struct inode *ip, long change, struct ucred *cred, int type)
*/
if (ncurinodes >= dq->dq_isoftlimit && dq->dq_isoftlimit) {
if (dq->dq_curinodes < dq->dq_isoftlimit) {
- dq->dq_itime = time_second +
- ip->i_ump->um_itime[type];
+ dq->dq_itime = gettime() + ip->i_ump->um_itime[type];
if (DIP(ip, uid) == cred->cr_uid)
uprintf("\n%s: warning, %s %s\n",
ITOV(ip)->v_mount->mnt_stat.f_mntonname,
quotatypes[type], "inode quota exceeded");
return (0);
}
- if (time_second > dq->dq_itime) {
+ if (gettime() > dq->dq_itime) {
if ((dq->dq_flags & DQ_INODS) == 0 &&
DIP(ip, uid) == cred->cr_uid) {
uprintf("\n%s: write failed, %s %s\n",
@@ -683,11 +681,11 @@ setquota(struct mount *mp, u_long id, int type, caddr_t addr)
if (newlim.dqb_bsoftlimit &&
dq->dq_curblocks >= newlim.dqb_bsoftlimit &&
(dq->dq_bsoftlimit == 0 || dq->dq_curblocks < dq->dq_bsoftlimit))
- newlim.dqb_btime = time_second + ump->um_btime[type];
+ newlim.dqb_btime = gettime() + ump->um_btime[type];
if (newlim.dqb_isoftlimit &&
dq->dq_curinodes >= newlim.dqb_isoftlimit &&
(dq->dq_isoftlimit == 0 || dq->dq_curinodes < dq->dq_isoftlimit))
- newlim.dqb_itime = time_second + ump->um_itime[type];
+ newlim.dqb_itime = gettime() + ump->um_itime[type];
dq->dq_dqb = newlim;
if (dq->dq_curblocks < dq->dq_bsoftlimit)
dq->dq_flags &= ~DQ_BLKS;
@@ -739,10 +737,10 @@ setuse(struct mount *mp, u_long id, int type, caddr_t addr)
*/
if (dq->dq_bsoftlimit && dq->dq_curblocks < dq->dq_bsoftlimit &&
usage.dqb_curblocks >= dq->dq_bsoftlimit)
- dq->dq_btime = time_second + ump->um_btime[type];
+ dq->dq_btime = gettime() + ump->um_btime[type];
if (dq->dq_isoftlimit && dq->dq_curinodes < dq->dq_isoftlimit &&
usage.dqb_curinodes >= dq->dq_isoftlimit)
- dq->dq_itime = time_second + ump->um_itime[type];
+ dq->dq_itime = gettime() + ump->um_itime[type];
dq->dq_curblocks = usage.dqb_curblocks;
dq->dq_curinodes = usage.dqb_curinodes;
if (dq->dq_curblocks < dq->dq_bsoftlimit)
@@ -940,9 +938,9 @@ dqget(struct vnode *vp, u_long id, struct ufsmount *ump, int type,
dq->dq_flags |= DQ_FAKE;
if (dq->dq_id != 0) {
if (dq->dq_btime == 0)
- dq->dq_btime = time_second + ump->um_btime[type];
+ dq->dq_btime = gettime() + ump->um_btime[type];
if (dq->dq_itime == 0)
- dq->dq_itime = time_second + ump->um_itime[type];
+ dq->dq_itime = gettime() + ump->um_itime[type];
}
*dqp = dq;
return (0);
diff --git a/sys/uvm/uvm_meter.c b/sys/uvm/uvm_meter.c
index c0a78b3774e..875ddd8fa49 100644
--- a/sys/uvm/uvm_meter.c
+++ b/sys/uvm/uvm_meter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_meter.c,v 1.40 2020/03/24 15:03:59 mpi Exp $ */
+/* $OpenBSD: uvm_meter.c,v 1.41 2020/06/24 22:03:45 cheloha Exp $ */
/* $NetBSD: uvm_meter.c,v 1.21 2001/07/14 06:36:03 matt Exp $ */
/*
@@ -85,7 +85,7 @@ void uvm_total(struct vmtotal *);
void
uvm_meter(void)
{
- if ((time_second % 5) == 0)
+ if ((gettime() % 5) == 0)
uvm_loadav(&averunnable);
if (proc0.p_slptime > (maxslp / 2))
wakeup(&proc0);