kernel - Change time_second to time_uptime for all expiration calculations
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 5 Sep 2013 19:06:13 +0000 (12:06 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 5 Sep 2013 19:06:13 +0000 (12:06 -0700)
* Vet the entire kernel and change use cases for expiration calculations
  using time_second to use time_uptime instead.

* Protects these expiration calculations from step changes in the wall time,
  particularly needed for route table entries.

* Probably requires further variable type adjustments but the use of
  time_uptime instead if time_second is highly unlikely to ever overrun
  any demotions to int still present.

75 files changed:
libexec/bootpd/rtmsg.c
sbin/route/route.c
sys/bus/cam/scsi/scsi_da.c
sys/bus/usb/usbdi.c
sys/dev/atm/hfa/fore_stats.c
sys/dev/disk/ncr/ncr.c
sys/dev/drm/i915kms/i915_drv.c
sys/dev/misc/musycc/musycc.c
sys/dev/netif/mn/if_mn.c
sys/dev/netif/nfe/if_nfe.c
sys/dev/raid/aac/aac.c
sys/dev/raid/aac/aac_cam.c
sys/dev/raid/ips/ips.c
sys/dev/raid/mfi/mfi.c
sys/dev/raid/mfi/mfi_tbolt.c
sys/dev/raid/mlx/mlx.c
sys/dev/raid/mlx/mlxvar.h
sys/dev/raid/mly/mly.c
sys/dev/raid/mps/mps.c
sys/dev/raid/twa/tw_cl_share.h
sys/dev/raid/twa/tw_osl_inline.h
sys/dev/raid/twe/twe.c
sys/dev/raid/tws/tws_hdm.c
sys/dev/raid/tws/tws_services.h
sys/kern/kern_clock.c
sys/kern/kern_device.c
sys/kern/kern_ntptime.c
sys/kern/kern_sensors.c
sys/kern/subr_prf.c
sys/kern/vfs_cache.c
sys/kern/vfs_sync.c
sys/kern/vfs_vnops.c
sys/net/bridge/if_bridge.c
sys/net/bridge/if_bridgevar.h
sys/net/dummynet/ip_dummynet.c
sys/net/ip_mroute/ip_mroute.c
sys/net/ipfw/ip_fw2.c
sys/net/ppp/if_ppp.c
sys/net/route.c
sys/net/sl/if_sl.c
sys/net/sppp/if_spppsubr.c
sys/netinet/if_ether.c
sys/netinet/in_rmx.c
sys/netinet/ip_input.c
sys/netinet/tcp_output.c
sys/netinet6/icmp6.c
sys/netinet6/in6.c
sys/netinet6/in6.h
sys/netinet6/in6_prefix.c
sys/netinet6/in6_rmx.c
sys/netinet6/ip6_forward.c
sys/netinet6/ip6_mroute.c
sys/netinet6/nd6.c
sys/netinet6/nd6_nbr.c
sys/netinet6/nd6_rtr.c
sys/netproto/802_11/ieee80211_node.h
sys/netproto/802_11/wlan/ieee80211_ddb.c
sys/netproto/802_11/wlan/ieee80211_node.c
sys/netproto/802_11/wlan/ieee80211_sta.c
sys/platform/pc32/i386/trap.c
sys/platform/pc32/isa/clock.c
sys/platform/pc64/isa/clock.c
sys/sys/conf.h
sys/sys/time.h
sys/vfs/devfs/devfs_core.c
sys/vfs/devfs/devfs_vnops.c
sys/vfs/nfs/bootp_subr.c
sys/vfs/nfs/nfs.h
sys/vfs/nfs/nfs_socket.c
sys/vfs/nfs/nfs_subs.c
sys/vfs/nfs/nfs_syscalls.c
sys/vfs/nwfs/nwfs_node.c
sys/vfs/smbfs/smbfs_node.c
sys/vfs/ufs/ffs_softdep.c
sys/vm/vm_pageout.c

index 7647bb3..e2e14ab 100644 (file)
@@ -121,7 +121,7 @@ bsd_arp_set(struct in_addr *ia, char *eaddr, int len)
        struct sockaddr_dl *sdl;
        struct rt_msghdr *rtm = &(m_rtmsg.m_rtm);
        u_char *ea;
-       struct timeval time;
+       struct timespec tp;
        int op = RTM_ADD;
 
        getsocket();
@@ -135,8 +135,8 @@ bsd_arp_set(struct in_addr *ia, char *eaddr, int len)
        doing_proxy = flags = export_only = expire_time = 0;
 
        /* make arp entry temporary */
-       gettimeofday(&time, 0);
-       expire_time = time.tv_sec + 20 * 60;
+       clock_gettime(CLOCK_MONOTONIC, &tp);
+       expire_time = tp.tv_sec + 20 * 60;
 
 tryagain:
        if (rtmsg(RTM_GET) < 0) {
index fa757fb..32db9aa 100644 (file)
@@ -1537,8 +1537,11 @@ print_getmsg(struct rt_msghdr *rtm, int msglen)
        printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rttvar), lock(RTTVAR));
        printf("%8ld%c ", rtm->rtm_rmx.rmx_hopcount, lock(HOPCOUNT));
        printf("%8ld%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU));
-       if (rtm->rtm_rmx.rmx_expire != 0)
-               rtm->rtm_rmx.rmx_expire -= time(0);
+       if (rtm->rtm_rmx.rmx_expire != 0) {
+               struct timespec sp;
+               clock_gettime(CLOCK_MONOTONIC, &tp);
+               rtm->rtm_rmx.rmx_expire -= tp.tv_sec;
+       }
        printf("%8ld%c ", rtm->rtm_rmx.rmx_expire, lock(EXPIRE));
        printf("%8ld ", rtm->rtm_rmx.rmx_msl);
        printf("%5ld ", rtm->rtm_rmx.rmx_iwmaxsegs);
index 3a77a18..aa0ce8d 100644 (file)
@@ -1429,13 +1429,13 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
                /* DEBUGGING */
                static int savets;
                static long savets2;
-               if (1 || time_second != savets2 || (ticks != savets && (softc->outstanding_cmds_rd || softc->outstanding_cmds_wr))) {
+               if (1 || time_uptime != savets2 || (ticks != savets && (softc->outstanding_cmds_rd || softc->outstanding_cmds_wr))) {
                        kprintf("%d %d (%d)\n",
                                softc->outstanding_cmds_rd,
                                softc->outstanding_cmds_wr,
                                limit);
                        savets = ticks;
-                       savets2 = time_second;
+                       savets2 = time_uptime;
                }
 #endif
                if (bio_rd && softc->outstanding_cmds_rd < limit) {
index 3b31f33..e636370 100644 (file)
@@ -1131,9 +1131,9 @@ usbd_get_endpoint_descriptor(usbd_interface_handle iface, u_int8_t address)
 int
 usbd_ratecheck(struct timeval *last)
 {
-       if (last->tv_sec == time_second)
+       if (last->tv_sec == time_uptime)
                return (0);
-       last->tv_sec = time_second;
+       last->tv_sec = time_uptime;
        return (1);
 }
 
index ee2836b..5e6dbae 100644 (file)
@@ -86,11 +86,11 @@ fore_get_stats(Fore_unit *fup)
        /*
         * Limit stats gathering to once a second or so
         */
-       if (time_second == fup->fu_stats_time) {
+       if (time_uptime == fup->fu_stats_time) {
                crit_exit();
                return (0);
        } else
-               fup->fu_stats_time = time_second;
+               fup->fu_stats_time = time_uptime;
 
        /*
         * Queue command at end of command queue
index 2a5b888..c76cfb4 100644 (file)
@@ -1391,7 +1391,7 @@ static char *ncr_name (ncb_p np)
  * THESE MUST ALL BE ALIGNED TO A 4-BYTE BOUNDARY.
  */
 static void *script_kvars[] =
-       { &time_second, &ticks, &ncr_cache };
+       { &time_uptime, &ticks, &ncr_cache };
 
 static struct script script0 = {
 /*--------------------------< START >-----------------------*/ {
@@ -4141,7 +4141,7 @@ ncr_action (struct cam_sim *sim, union ccb *ccb)
                */
 
                cp->jump_nccb.l_cmd     = (SCR_JUMP ^ IFFALSE (DATA (cp->tag)));
-               cp->tlimit              = time_second
+               cp->tlimit              = time_uptime
                                        + ccb->ccb_h.timeout / 1000 + 2;
                cp->magic               = CCB_MAGIC;
 
@@ -5104,7 +5104,7 @@ static void
 ncr_timeout (void *arg)
 {
        ncb_p   np = arg;
-       time_t  thistime = time_second;
+       time_t  thistime = time_uptime;
        ticks_t step  = np->ticks;
        u_long  count = 0;
        long signed   t;
@@ -5412,9 +5412,9 @@ void ncr_exception (ncb_p np)
        **========================================
        */
 
-       if (time_second - np->regtime > 10) {
+       if (time_uptime - np->regtime > 10) {
                int i;
-               np->regtime = time_second;
+               np->regtime = time_uptime;
                for (i=0; i<sizeof(np->regdump); i++)
                        ((volatile char*)&np->regdump)[i] = INB_OFF(i);
                np->regdump.nc_dstat = dstat;
index 725043a..160b7a1 100644 (file)
@@ -714,7 +714,7 @@ i915_reset(struct drm_device *dev, u8 flags)
        i915_gem_reset(dev);
 
        ret = -ENODEV;
-       if (time_second - dev_priv->last_gpu_reset < 5) {
+       if (time_uptime - dev_priv->last_gpu_reset < 5) {
                DRM_ERROR("GPU hanging too fast, declaring wedged!\n");
        } else {
                switch (INTEL_INFO(dev)->gen) {
@@ -733,7 +733,7 @@ i915_reset(struct drm_device *dev, u8 flags)
                        break;
                }
        }
-       dev_priv->last_gpu_reset = time_second;
+       dev_priv->last_gpu_reset = time_uptime;
        if (ret) {
                DRM_ERROR("Failed to reset chip.\n");
                DRM_UNLOCK(dev);
index a49e593..2a1210e 100644 (file)
@@ -447,11 +447,11 @@ status_chans(struct softc *sc, char *s)
                ksprintf(s + strlen(s), "c%2d:", i);
                ksprintf(s + strlen(s), " ts %08x", scp->ts);
                ksprintf(s + strlen(s), " RX %lus/%lus",
-                   time_second - scp->last_recv, time_second - scp->last_rxerr);
+                   time_uptime - scp->last_recv, time_uptime - scp->last_rxerr);
                ksprintf(s + strlen(s), " TX %lus/%lus/%lus",
-                   time_second - scp->last_xmit, 
-                   time_second - scp->last_txerr,
-                   time_second - scp->last_txdrop);
+                   time_uptime - scp->last_xmit,
+                   time_uptime - scp->last_txerr,
+                   time_uptime - scp->last_txdrop);
                ksprintf(s + strlen(s), " TXdrop %lu Pend %lu", 
                    scp->tx_drop,
                    scp->tx_pending);
@@ -703,7 +703,7 @@ musycc_intr0_rx_eom(struct softc *sc, int ch)
                                        md->m = m2;
                                        md->data = vtophys(m2->m_data);
                                        /* Pass the received mbuf upwards. */
-                                       sch->last_recv = time_second;
+                                       sch->last_recv = time_uptime;
                                        ng_queue_data(sch->hook, m, NULL);
                                } else {
                                        /*
@@ -713,7 +713,7 @@ musycc_intr0_rx_eom(struct softc *sc, int ch)
                                         * the mbuf+cluster we already had.
                                         */
                                        m_freem(m2);
-                                       sch->last_rdrop = time_second;
+                                       sch->last_rdrop = time_uptime;
                                        sch->rx_drop++;
                                }
                        } else {
@@ -721,23 +721,23 @@ musycc_intr0_rx_eom(struct softc *sc, int ch)
                                 * We didn't get a mbuf, drop received packet
                                 * and recycle the "old" mbuf+cluster.
                                 */
-                               sch->last_rdrop = time_second;
+                               sch->last_rdrop = time_uptime;
                                sch->rx_drop++;
                        }
                } else if (error == 9) {
-                       sch->last_rxerr = time_second;
+                       sch->last_rxerr = time_uptime;
                        sch->crc_error++;
                } else if (error == 10) {
-                       sch->last_rxerr = time_second;
+                       sch->last_rxerr = time_uptime;
                        sch->dribble_error++;
                } else if (error == 11) {
-                       sch->last_rxerr = time_second;
+                       sch->last_rxerr = time_uptime;
                        sch->abort_error++;
                } else if (error == 12) {
-                       sch->last_rxerr = time_second;
+                       sch->last_rxerr = time_uptime;
                        sch->long_error++;
                } else {
-                       sch->last_rxerr = time_second;
+                       sch->last_rxerr = time_uptime;
                        /* Receive error, print some useful info */
                        kprintf("%s %s: RX 0x%08x ", sch->sc->nodename, 
                            sch->hookname, status);
@@ -810,7 +810,7 @@ musycc_intr0(void *arg)
                                break;
                        case 0:
                                if (er == 13) { /* SHT */
-                                       sc->chan[ch]->last_rxerr = time_second;
+                                       sc->chan[ch]->last_rxerr = time_uptime;
                                        sc->chan[ch]->short_error++;
                                        break;
                                }
@@ -1113,7 +1113,7 @@ musycc_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
        } 
        if (sch->tx_pending + m->m_pkthdr.len > sch->tx_limit * maxlatency) {
                sch->tx_drop++;
-               sch->last_txdrop = time_second;
+               sch->last_txdrop = time_uptime;
                NG_FREE_DATA(m, meta);
                return (0);
        }
@@ -1126,7 +1126,7 @@ musycc_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
                        continue;
                if (md->status != 0) {
                        sch->tx_drop++;
-                       sch->last_txdrop = time_second;
+                       sch->last_txdrop = time_uptime;
                        NG_FREE_DATA(m, meta);
                        return (0);
                }
@@ -1142,9 +1142,9 @@ musycc_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
                        continue;
                if (md->status != 0) {
                        kprintf("Out of tx md(2)\n");
-                       sch->last_txerr = time_second;
+                       sch->last_txerr = time_uptime;
                        sch->tx_drop++;
-                       sch->last_txdrop = time_second;
+                       sch->last_txdrop = time_uptime;
                        NG_FREE_DATA(m, meta);
                        break;
                }
@@ -1175,7 +1175,7 @@ musycc_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
                        md->status = u;
                        md0->status = u0 | 0x80000000; /* OWNER = MUSYCC */
                }
-               sch->last_xmit = time_second;
+               sch->last_xmit = time_uptime;
                sch->tx_next_md = md->snext;
        }
        sch->txn++;
index 8fa1def..aab52b6 100644 (file)
@@ -407,19 +407,19 @@ ngmn_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr, struct ng_mes
 
                pos += ksprintf(r + pos, "  Last Rx: ");
                if (sch->last_recv)
-                       pos += ksprintf(r + pos, "%lu s", time_second - sch->last_recv);
+                       pos += ksprintf(r + pos, "%lu s", time_uptime - sch->last_recv);
                else
                        pos += ksprintf(r + pos, "never");
 
                pos += ksprintf(r + pos, ", last RxErr: ");
                if (sch->last_rxerr)
-                       pos += ksprintf(r + pos, "%lu s", time_second - sch->last_rxerr);
+                       pos += ksprintf(r + pos, "%lu s", time_uptime - sch->last_rxerr);
                else
                        pos += ksprintf(r + pos, "never");
 
                pos += ksprintf(r + pos, ", last Tx: ");
                if (sch->last_xmit)
-                       pos += ksprintf(r + pos, "%lu s\n", time_second - sch->last_xmit);
+                       pos += ksprintf(r + pos, "%lu s\n", time_uptime - sch->last_xmit);
                else
                        pos += ksprintf(r + pos, "never\n");
 
@@ -1105,7 +1105,7 @@ mn_tx_intr(struct softc *sc, u_int32_t vector)
                        sc->ch[chan]->tx_pending -= m->m_pkthdr.len;
                        m_freem(m);
                }
-               sc->ch[chan]->last_xmit = time_second;
+               sc->ch[chan]->last_xmit = time_uptime;
                sc->ch[chan]->x1 = dp->vnext;
                mn_free_desc(dp);
        }
@@ -1143,7 +1143,7 @@ mn_rx_intr(struct softc *sc, u_int32_t vector)
                err = (dp->status >> 8) & 0xff;
                if (!err) {
                        ng_queue_data(sch->hook, m, NULL);
-                       sch->last_recv = time_second;
+                       sch->last_recv = time_uptime;
                        m = NULL;
                        /* we could be down by now... */
                        if (sch->state != UP) 
@@ -1162,7 +1162,7 @@ mn_rx_intr(struct softc *sc, u_int32_t vector)
                        sch->overflow_error++;
                }
                if (err) {
-                       sch->last_rxerr = time_second;
+                       sch->last_rxerr = time_uptime;
                        sch->prev_error = sch->last_error;
                        sch->last_error = err;
                }
index 9c3d4be..dafb7cd 100644 (file)
@@ -921,11 +921,11 @@ nfe_intr(void *arg)
                return; /* not for us */
        NFE_WRITE(sc, NFE_IRQ_STATUS, r);
 
-       if (sc->sc_rate_second != time_second) {
+       if (sc->sc_rate_second != time_uptime) {
                /*
                 * Calculate sc_rate_avg - interrupts per second.
                 */
-               sc->sc_rate_second = time_second;
+               sc->sc_rate_second = time_uptime;
                if (sc->sc_rate_avg < sc->sc_rate_acc)
                        sc->sc_rate_avg = sc->sc_rate_acc;
                else
index 6b32368..29aa37f 100644 (file)
@@ -1139,7 +1139,7 @@ aac_complete(void *context, int pending)
                if ((cm->cm_flags & AAC_CMD_TIMEDOUT) != 0)
                        device_printf(sc->aac_dev,
                            "COMMAND %p COMPLETED AFTER %d SECONDS\n",
-                           cm, (int)(time_second-cm->cm_timestamp));
+                           cm, (int)(time_uptime - cm->cm_timestamp));
 
                aac_remove_busy(cm);
 
@@ -1207,7 +1207,7 @@ aac_bio_command(struct aac_softc *sc, struct aac_command **cmp)
        cm->cm_datalen = bp->b_bcount;
        cm->cm_complete = aac_bio_complete;
        cm->cm_private = bio;
-       cm->cm_timestamp = time_second;
+       cm->cm_timestamp = time_uptime;
 
        /* build the FIB */
        fib = cm->cm_fib;
@@ -1697,7 +1697,7 @@ aac_check_firmware(struct aac_softc *sc)
        /*
         * Wait for the adapter to come ready.
         */
-       then = time_second;
+       then = time_uptime;
        do {
                code = AAC_GET_FWSTATUS(sc);
                if (code & AAC_SELF_TEST_FAILED) {
@@ -1709,7 +1709,7 @@ aac_check_firmware(struct aac_softc *sc)
                                      "FATAL: controller kernel panic");
                        return(ENXIO);
                }
-               if (time_second > (then + AAC_BOOT_TIMEOUT)) {
+               if (time_uptime > (then + AAC_BOOT_TIMEOUT)) {
                        device_printf(sc->aac_dev,
                                      "FATAL: controller not coming ready, "
                                           "status %x\n", code);
@@ -1888,7 +1888,7 @@ aac_init(struct aac_softc *sc)
                ip->HostPhysMemPages =
                    (ip->HostPhysMemPages + AAC_PAGE_SIZE) / AAC_PAGE_SIZE;
        }
-       ip->HostElapsedSeconds = time_second;   /* reset later if invalid */
+       ip->HostElapsedSeconds = time_uptime;   /* reset later if invalid */
 
        ip->InitFlags = 0;
        if (sc->flags & AAC_FLAGS_NEW_COMM) {
@@ -2057,9 +2057,9 @@ aac_sync_command(struct aac_softc *sc, u_int32_t command,
        AAC_QNOTIFY(sc, AAC_DB_SYNC_COMMAND);
 
        /* spin waiting for the command to complete */
-       then = time_second;
+       then = time_uptime;
        do {
-               if (time_second > (then + AAC_IMMEDIATE_TIMEOUT)) {
+               if (time_uptime > (then + AAC_IMMEDIATE_TIMEOUT)) {
                        fwprintf(sc, HBA_FLAGS_DBG_ERROR_B, "timed out");
                        return(EIO);
                }
@@ -2359,7 +2359,7 @@ aac_timeout(struct aac_softc *sc)
         * only.
         */
        timedout = 0;
-       deadline = time_second - AAC_CMD_TIMEOUT;
+       deadline = time_uptime - AAC_CMD_TIMEOUT;
        TAILQ_FOREACH(cm, &sc->aac_busy, cm_link) {
                if ((cm->cm_timestamp  < deadline)
                    && !(cm->cm_flags & AAC_CMD_TIMEDOUT)) {
@@ -2367,7 +2367,7 @@ aac_timeout(struct aac_softc *sc)
                        device_printf(sc->aac_dev,
                            "COMMAND %p (TYPE %d) TIMEOUT AFTER %d SECONDS\n",
                            cm, cm->cm_fib->Header.Command,
-                           (int)(time_second-cm->cm_timestamp));
+                           (int)(time_uptime-cm->cm_timestamp));
                        AAC_PRINT_FIB(sc, cm->cm_fib);
                        timedout++;
                }
@@ -3047,7 +3047,7 @@ aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib)
        if ((error = copyin(ufib, cm->cm_fib, size)) != 0)
                goto out;
        cm->cm_fib->Header.Size = size;
-       cm->cm_timestamp = time_second;
+       cm->cm_timestamp = time_uptime;
 
        /*
         * Pass the FIB to the controller, wait for it to complete.
index 481cd4b..15815fe 100644 (file)
@@ -506,7 +506,7 @@ aac_cam_action(struct cam_sim *sim, union ccb *ccb)
 
        cm->cm_complete = aac_cam_complete;
        cm->cm_private = ccb;
-       cm->cm_timestamp = time_second;
+       cm->cm_timestamp = time_uptime;
 
        fib->Header.XferState =
            AAC_FIBSTATE_HOSTOWNED      |
index 3142cad..c58e6fe 100644 (file)
@@ -612,10 +612,10 @@ ips_morpheus_poll(ips_command_t *command)
 {
        uint32_t ts;
 
-       ts = time_second + command->timeout;
+       ts = time_uptime + command->timeout;
        while (command->timeout != 0 &&
            ips_morpheus_check_intr(command->sc) == 0 &&
-           (ts > time_second))
+           (ts > time_uptime))
                DELAY(1000);
  }
 
index 5b76159..e2b0cd0 100644 (file)
@@ -2293,7 +2293,7 @@ mfi_send_frame(struct mfi_softc *sc, struct mfi_command *cm)
        hdr = &cm->cm_frame->header;
 
        if ((cm->cm_flags & MFI_CMD_POLLED) == 0) {
-               cm->cm_timestamp = time_second;
+               cm->cm_timestamp = time_uptime;
                mfi_enqueue_busy(cm);
        } else {
                hdr->cmd_status = MFI_STAT_INVALID_STATUS;
@@ -3484,13 +3484,13 @@ mfi_dump_all(void)
                        break;
                device_printf(sc->mfi_dev, "Dumping\n\n");
                timedout = 0;
-               deadline = time_second - mfi_cmd_timeout;
+               deadline = time_uptime - mfi_cmd_timeout;
                lockmgr(&sc->mfi_io_lock, LK_EXCLUSIVE);
                TAILQ_FOREACH(cm, &sc->mfi_busy, cm_link) {
                        if (cm->cm_timestamp < deadline) {
                                device_printf(sc->mfi_dev,
                                    "COMMAND %p TIMEOUT AFTER %d SECONDS\n",
-                                   cm, (int)(time_second - cm->cm_timestamp));
+                                   cm, (int)(time_uptime - cm->cm_timestamp));
                                MFI_PRINT_CMD(cm);
                                timedout++;
                        }
@@ -3515,7 +3515,7 @@ mfi_timeout(void *data)
        time_t deadline;
        int timedout = 0;
 
-       deadline = time_second - mfi_cmd_timeout;
+       deadline = time_uptime - mfi_cmd_timeout;
        if (sc->adpreset == 0) {
                if (!mfi_tbolt_reset(sc)) {
                        callout_reset(&sc->mfi_watchdog_callout,
@@ -3529,11 +3529,11 @@ mfi_timeout(void *data)
                        continue;
                if ((sc->mfi_aen_cm != cm) && (cm->cm_timestamp < deadline)) {
                        if (sc->adpreset != 0 && sc->issuepend_done == 0) {
-                               cm->cm_timestamp = time_second;
+                               cm->cm_timestamp = time_uptime;
                        } else {
                                device_printf(sc->mfi_dev,
                                    "COMMAND %p TIMEOUT AFTER %d SECONDS\n",
-                                    cm, (int)(time_second - cm->cm_timestamp));
+                                    cm, (int)(time_uptime - cm->cm_timestamp));
                                MFI_PRINT_CMD(cm);
                                MFI_VALIDATE_CMD(sc, cm);
                                timedout++;
index f396623..2844fe8 100644 (file)
@@ -396,7 +396,7 @@ mfi_tbolt_init_MFI_queue(struct mfi_softc *sc)
        mfiAddressTemp->u.addressLow = (uint32_t)phyAddress;
        mfiAddressTemp->u.addressHigh = (uint32_t)((uint64_t)phyAddress >> 32);
        mpi2IocInit->ReplyFreeQueueAddress =  0; /* Not supported by MR. */
-       mpi2IocInit->TimeStamp = time_second;
+       mpi2IocInit->TimeStamp = time_uptime;
 
        if (sc->verbuf) {
                ksnprintf((char *)sc->verbuf, strlen(MEGASAS_VERSION) + 2, "%s\n",
@@ -417,7 +417,7 @@ mfi_tbolt_init_MFI_queue(struct mfi_softc *sc)
 
        cm->cm_data = NULL;
        cm->cm_flags |= MFI_CMD_POLLED;
-       cm->cm_timestamp = time_second;
+       cm->cm_timestamp = time_uptime;
        if ((error = mfi_mapcmd(sc, cm)) != 0) {
                device_printf(sc->mfi_dev, "failed to send IOC init2 "
                    "command %d at %lx\n", error, (long)cm->cm_frame_busaddr);
@@ -1146,7 +1146,7 @@ mfi_tbolt_send_frame(struct mfi_softc *sc, struct mfi_command *cm)
        if (sc->adpreset)
                return 1;
        if ((cm->cm_flags & MFI_CMD_POLLED) == 0) {
-               cm->cm_timestamp = time_second;
+               cm->cm_timestamp = time_uptime;
                mfi_enqueue_busy(cm);
        }
        else {
index 2ca2bb5..8d1f69a 100644 (file)
@@ -836,7 +836,7 @@ mlx_ioctl(struct dev_ioctl_args *ap)
 
            /* looks ok, go with it */
            sc->mlx_pause.mp_which = mp->mp_which;
-           sc->mlx_pause.mp_when = time_second + mp->mp_when;
+           sc->mlx_pause.mp_when = time_uptime + mp->mp_when;
            sc->mlx_pause.mp_howlong = sc->mlx_pause.mp_when + mp->mp_howlong;
        }
        return(0);
@@ -987,7 +987,7 @@ mlx_periodic(void *data)
      */
     if ((sc->mlx_pause.mp_which != 0) &&
        (sc->mlx_pause.mp_when > 0) &&
-       (time_second >= sc->mlx_pause.mp_when)){
+       (time_uptime >= sc->mlx_pause.mp_when)){
 
        mlx_pause_action(sc);           /* pause is running */
        sc->mlx_pause.mp_when = 0;
@@ -1000,19 +1000,19 @@ mlx_periodic(void *data)
               (sc->mlx_pause.mp_when == 0)) {
 
        /* time to stop bus pause? */
-       if (time_second >= sc->mlx_pause.mp_howlong) {
+       if (time_uptime >= sc->mlx_pause.mp_howlong) {
            mlx_pause_action(sc);
            sc->mlx_pause.mp_which = 0; /* pause is complete */
            sysbeep(500, hz);
        } else {
-           sysbeep((time_second % 5) * 100 + 500, hz/8);
+           sysbeep((time_uptime % 5) * 100 + 500, hz/8);
        }
 
        /* 
         * Run normal periodic activities? 
         */
-    } else if (time_second > (sc->mlx_lastpoll + 10)) {
-       sc->mlx_lastpoll = time_second;
+    } else if (time_uptime > (sc->mlx_lastpoll + 10)) {
+       sc->mlx_lastpoll = time_uptime;
 
        /* 
         * Check controller status.
@@ -1379,10 +1379,10 @@ mlx_pause_action(struct mlx_softc *sc)
         * which is specified in multiples of 30 seconds.
         * This constrains us to a maximum pause of 450 seconds.
         */
-       failsafe = ((sc->mlx_pause.mp_howlong - time_second) + 5) / 30;
+       failsafe = ((sc->mlx_pause.mp_howlong - time_uptime) + 5) / 30;
        if (failsafe > 0xf) {
            failsafe = 0xf;
-           sc->mlx_pause.mp_howlong = time_second + (0xf * 30) - 5;
+           sc->mlx_pause.mp_howlong = time_uptime + (0xf * 30) - 5;
        }
     }
 
@@ -1428,7 +1428,7 @@ mlx_pause_done(struct mlx_command *mc)
                      command == MLX_CMD_STOPCHANNEL ? "pause" : "resume", mlx_diagnose_command(mc));
     } else if (command == MLX_CMD_STOPCHANNEL) {
        device_printf(sc->mlx_dev, "channel %d pausing for %ld seconds\n", 
-                     channel, (long)(sc->mlx_pause.mp_howlong - time_second));
+                     channel, (long)(sc->mlx_pause.mp_howlong - time_uptime));
     } else {
        device_printf(sc->mlx_dev, "channel %d resuming\n", channel);
     }
@@ -2085,7 +2085,7 @@ mlx_start(struct mlx_command *mc)
     mc->mc_status = MLX_STATUS_BUSY;
 
     /* set a default 60-second timeout  XXX tunable?  XXX not currently used */
-    mc->mc_timeout = time_second + 60;
+    mc->mc_timeout = time_uptime + 60;
     
     /* spin waiting for the mailbox */
     for (i = 100000, done = 0; (i > 0) && !done; i--) {
index 84f81e4..3a1dd4c 100644 (file)
@@ -148,7 +148,7 @@ struct mlx_softc
 #define MLX_STATE_OPEN         (1<<2)  /* control device is open */
 #define MLX_STATE_SUSPEND      (1<<3)  /* controller is suspended */
     struct callout     mlx_timeout;    /* periodic status monitor */
-    time_t             mlx_lastpoll;   /* last time_second we polled for status */
+    time_t             mlx_lastpoll;   /* last time_uptime we polled for status */
     u_int16_t          mlx_lastevent;  /* sequence number of the last event we recorded */
     int                        mlx_currevent;  /* sequence number last time we looked */
     int                        mlx_background; /* if != 0 rebuild or check is in progress */
index 5d4ed32..3663d0d 100644 (file)
@@ -1464,7 +1464,7 @@ mly_start(struct mly_command *mc)
     mc->mc_packet->generic.command_id = mc->mc_slot;
 
 #ifdef MLY_DEBUG
-    mc->mc_timestamp = time_second;
+    mc->mc_timestamp = time_uptime;
 #endif
 
     crit_enter();
@@ -2976,12 +2976,12 @@ mly_timeout(struct mly_softc *sc)
        struct mly_command *mc;
        int deadline;
 
-       deadline = time_second - MLY_CMD_TIMEOUT;
+       deadline = time_uptime - MLY_CMD_TIMEOUT;
        TAILQ_FOREACH(mc, &sc->mly_busy, mc_link) {
                if ((mc->mc_timestamp < deadline)) {
                        device_printf(sc->mly_dev,
                            "COMMAND %p TIMEOUT AFTER %d SECONDS\n", mc,
-                           (int)(time_second - mc->mc_timestamp));
+                           (int)(time_uptime - mc->mc_timestamp));
                }
        }
 
index 440ce00..61c982a 100644 (file)
@@ -632,7 +632,7 @@ mps_send_iocinit(struct mps_softc *sc)
        init.ReplyFreeQueueAddress.High = 0;
        init.ReplyFreeQueueAddress.Low = (uint32_t)sc->free_busaddr;
        init.TimeStamp.High = 0;
-       init.TimeStamp.Low = (uint32_t)time_second;
+       init.TimeStamp.Low = (uint32_t)time_uptime;
 
        error = mps_request_sync(sc, &init, &reply, req_sz, reply_sz, 5);
        if ((reply.IOCStatus & MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_SUCCESS)
index 43c4839..978979c 100644 (file)
@@ -396,7 +396,7 @@ extern TW_VOID      tw_osl_free_lock(struct tw_cl_ctlr_handle *ctlr_handle,
 
 
 #ifndef tw_osl_get_local_time
-/* Get local time. */
+/* Get local time. XXX now gets monotonic uptime, used only for timeouts */
 extern TW_TIME tw_osl_get_local_time(TW_VOID);
 #endif
 
index 5330d89..d2b4b5c 100644 (file)
@@ -261,9 +261,7 @@ tw_osl_write_reg_inline(struct tw_cl_ctlr_handle *ctlr_handle,
  * Output:             None
  * Return value:       local time
  */
-#define tw_osl_get_local_time()                                                \
-       (time_second - (tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0)))
-
+#define tw_osl_get_local_time()                time_uptime
 
 /*
  * Function name:      tw_osl_delay
index 5153910..5b4b824 100644 (file)
@@ -1272,14 +1272,14 @@ twe_wait_status(struct twe_softc *sc, u_int32_t status, int timeout)
 
     debug_called(4);
 
-    expiry = time_second + timeout;
+    expiry = time_uptime + timeout;
 
     do {
        status_reg = TWE_STATUS(sc);
        if (status_reg & status)        /* got the required bit(s)? */
            return(0);
        DELAY(100000);
-    } while (time_second <= expiry);
+    } while (time_uptime <= expiry);
 
     return(1);
 }
@@ -1565,7 +1565,7 @@ twe_wait_aen(struct twe_softc *sc, int aen, int timeout)
 
     debug_called(4);
 
-    expiry = time_second + timeout;
+    expiry = time_uptime + timeout;
     found = 0;
 
     sc->twe_wait_aen = aen;
@@ -1574,7 +1574,7 @@ twe_wait_aen(struct twe_softc *sc, int aen, int timeout)
        lksleep(&sc->twe_wait_aen, &sc->twe_io_lock, 0, "twewaen", hz);
        if (sc->twe_wait_aen == -1)
            found = 1;
-    } while ((time_second <= expiry) && !found);
+    } while ((time_uptime <= expiry) && !found);
     return(!found);
 }
 #endif
@@ -1742,19 +1742,19 @@ twe_check_bits(struct twe_softc *sc, u_int32_t status_reg)
 
     result = 0;
     if ((status_reg & TWE_STATUS_EXPECTED_BITS) != TWE_STATUS_EXPECTED_BITS) {
-       if (time_second > (lastwarn[0] + 5)) {
+       if (time_uptime > (lastwarn[0] + 5)) {
            twe_printf(sc, "missing expected status bit(s) %b\n", ~status_reg & TWE_STATUS_EXPECTED_BITS, 
                       TWE_STATUS_BITS_DESCRIPTION);
-           lastwarn[0] = time_second;
+           lastwarn[0] = time_uptime;
        }
        result = 1;
     }
 
     if ((status_reg & TWE_STATUS_UNEXPECTED_BITS) != 0) {
-       if (time_second > (lastwarn[1] + 5)) {
+       if (time_uptime > (lastwarn[1] + 5)) {
            twe_printf(sc, "unexpected status bit(s) %b\n", status_reg & TWE_STATUS_UNEXPECTED_BITS, 
                       TWE_STATUS_BITS_DESCRIPTION);
-           lastwarn[1] = time_second;
+           lastwarn[1] = time_uptime;
        }
        result = 1;
        if (status_reg & TWE_STATUS_PCI_PARITY_ERROR) {
index 0b27cc3..e04bc44 100644 (file)
@@ -517,7 +517,7 @@ tws_aen_synctime_with_host(struct tws_softc *sc)
     TWS_TRACE_DEBUG(sc, "entry", sc, 0);
 
     sync_time = (TWS_LOCAL_TIME - (3 * 86400)) % 604800;
-    TWS_TRACE_DEBUG(sc, "sync_time,ts", sync_time, time_second);
+    TWS_TRACE_DEBUG(sc, "sync_time,ts", sync_time, time_uptime);
     TWS_TRACE_DEBUG(sc, "utc_offset", utc_offset(), 0);
     error = tws_set_param(sc, TWS_PARAM_TIME_TABLE, TWS_PARAM_TIME_SCHED_TIME,
                            4, &sync_time);
index 502e178..89f209e 100644 (file)
@@ -130,5 +130,4 @@ extern struct error_desc array[];
 
 
 /* ------------------------ */
-#define TWS_LOCAL_TIME (time_second - (tz.tz_minuteswest * 60) -   \
-                  (wall_cmos_clock ? adjkerntz : 0))
+#define TWS_LOCAL_TIME         time_uptime
index eeaf08d..202f69c 100644 (file)
@@ -178,6 +178,7 @@ SYSCTL_PROC(_kern, OID_AUTO, cp_time, (CTLTYPE_LONG|CTLFLAG_RD), 0, 0,
  */
 struct timespec boottime;      /* boot time (realtime) for reference only */
 time_t time_second;            /* read-only 'passive' uptime in seconds */
+time_t time_uptime;            /* read-only 'passive' uptime in seconds */
 
 /*
  * basetime is used to calculate the compensated real time of day.  The
@@ -379,6 +380,8 @@ hardclock(systimer_t info, int in_ipi __unused, struct intrframe *frame)
        if (cputicks >= sys_cputimer->freq) {
                ++gd->gd_time_seconds;
                gd->gd_cpuclock_base += sys_cputimer->freq;
+               if (gd->gd_cpuid == 0)
+                       ++time_uptime;  /* uncorrected monotonic 1-sec gran */
        }
 
        /*
index 54a7e83..16049cc 100644 (file)
@@ -195,7 +195,7 @@ dev_dread(cdev_t dev, struct uio *uio, int ioflag)
        if (needmplock)
                rel_mplock();
        if (error == 0)
-               dev->si_lastread = time_second;
+               dev->si_lastread = time_uptime;
        return (error);
 }
 
@@ -206,7 +206,7 @@ dev_dwrite(cdev_t dev, struct uio *uio, int ioflag)
        int needmplock = dev_needmplock(dev);
        int error;
 
-       dev->si_lastwrite = time_second;
+       dev->si_lastwrite = time_uptime;
        ap.a_head.a_desc = &dev_write_desc;
        ap.a_head.a_dev = dev;
        ap.a_uio = uio;
index 0f16073..dbde886 100644 (file)
@@ -147,7 +147,7 @@ static long time_constant;          /* poll interval (shift) (s) */
 static long time_precision = 1;                /* clock precision (ns) */
 static long time_maxerror = MAXPHASE / 1000; /* maximum error (us) */
 static long time_esterror = MAXPHASE / 1000; /* estimated error (us) */
-static long time_reftime;              /* time at last adjustment (s) */
+static time_t time_reftime;            /* time at last adjustment (s) */
 static long time_tick;                 /* nanoseconds per tick (ns) */
 static l_fp time_offset;               /* time offset (ns) */
 static l_fp time_freq;                 /* frequency offset (ns/s) */
@@ -632,13 +632,13 @@ hardupdate(long offset)
         * to discipline the frequency, the PPS frequency is used;
         * otherwise, the argument offset is used to compute it.
         */
-       if (time_status & STA_PPSFREQ && time_status & STA_PPSSIGNAL) {
-               time_reftime = time_second;
+       if ((time_status & STA_PPSFREQ) && time_status & STA_PPSSIGNAL) {
+               time_reftime = time_uptime;
                return;
        }
-       if (time_status & STA_FREQHOLD || time_reftime == 0)
-               time_reftime = time_second;
-       mtemp = time_second - time_reftime;
+       if ((time_status & STA_FREQHOLD) || time_reftime == 0)
+               time_reftime = time_uptime;
+       mtemp = time_uptime - time_reftime;
        L_LINT(ftemp, time_monitor);
        L_RSHIFT(ftemp, (SHIFT_PLL + 2 + time_constant) << 1);
        L_MPY(ftemp, mtemp);
@@ -650,7 +650,7 @@ hardupdate(long offset)
                L_ADD(time_freq, ftemp);
                time_status |= STA_MODE;
        }
-       time_reftime = time_second;
+       time_reftime = time_uptime;
        if (L_GINT(time_freq) > MAXFREQ)
                L_LINT(time_freq, MAXFREQ);
        else if (L_GINT(time_freq) < -MAXFREQ)
index 63faaf4..7d29e81 100644 (file)
@@ -51,7 +51,7 @@ struct sensor_task {
        void                            (*func)(void *);
 
        int                             period;
-       time_t                          nextrun;
+       time_t                          nextrun;        /* time_uptime */
        volatile int                    running;
        TAILQ_ENTRY(sensor_task)        entry;
 };
@@ -258,7 +258,7 @@ sensor_task_thread(void *arg)
 
        while (!TAILQ_EMPTY(&tasklist)) {
                while ((nst = TAILQ_FIRST(&tasklist))->nextrun >
-                   (now = time_second))
+                   (now = time_uptime))
                        lksleep(&tasklist, &sensor_task_lock, 0, "timeout",
                               (nst->nextrun - now) * hz);
 
@@ -292,7 +292,7 @@ sensor_task_schedule(struct sensor_task *st)
        struct sensor_task      *cst;
 
        lockmgr(&sensor_task_lock, LK_EXCLUSIVE);
-       st->nextrun = time_second + st->period;
+       st->nextrun = time_uptime + st->period;
 
        TAILQ_FOREACH(cst, &tasklist, entry) {
                if (cst->nextrun > st->nextrun) {
index 3776477..9ea0402 100644 (file)
@@ -340,8 +340,8 @@ krateprintf(struct krate *rate, const char *fmt, ...)
 {
        __va_list ap;
 
-       if (rate->ticks != (int)time_second) {
-               rate->ticks = (int)time_second;
+       if (rate->ticks != (int)time_uptime) {
+               rate->ticks = (int)time_uptime;
                if (rate->count > 0)
                        rate->count = 0;
        }
index 173d234..c836c4f 100644 (file)
@@ -2188,8 +2188,8 @@ cache_fromdvp_try(struct vnode *dvp, struct ucred *cred,
                dvp = pvp;
        }
        if (error == 0) {
-               if (last_fromdvp_report != time_second) {
-                       last_fromdvp_report = time_second;
+               if (last_fromdvp_report != time_uptime) {
+                       last_fromdvp_report = time_uptime;
                        kprintf("Warning: extremely inefficient path "
                                "resolution on %s\n",
                                nch.ncp->nc_name);
index 2602f4d..271926a 100644 (file)
@@ -319,7 +319,7 @@ syncer_thread(void *_ctx)
        for (;;) {
                kproc_suspend_loop();
 
-               starttime = time_second;
+               starttime = time_uptime;
                lwkt_gettoken(&ctx->sc_token);
 
                /*
@@ -399,7 +399,7 @@ syncer_thread(void *_ctx)
                 * matter as we are just trying to generally pace the
                 * filesystem activity.
                 */
-               if (time_second == starttime)
+               if (time_uptime == starttime)
                        tsleep(ctx, 0, "syncer", hz);
        }
 
index 5093b81..99dcf30 100644 (file)
@@ -828,11 +828,15 @@ vn_stat(struct vnode *vp, struct stat *sb, struct ucred *cred)
                dev = vp->v_rdev;
                if (dev != NULL) {
                        if (dev->si_lastread) {
-                               sb->st_atimespec.tv_sec = dev->si_lastread;
+                               sb->st_atimespec.tv_sec = time_second +
+                                                         (time_uptime -
+                                                          dev->si_lastread);
                                sb->st_atimespec.tv_nsec = 0;
                        }
                        if (dev->si_lastwrite) {
-                               sb->st_atimespec.tv_sec = dev->si_lastwrite;
+                               sb->st_atimespec.tv_sec = time_second +
+                                                         (time_uptime -
+                                                          dev->si_lastwrite);
                                sb->st_atimespec.tv_nsec = 0;
                        }
                }
index f711114..7b71f82 100644 (file)
@@ -1472,7 +1472,7 @@ bridge_ioctl_rts(struct bridge_softc *sc, void *arg)
        count = 0;
        LIST_FOREACH(brt, &sc->sc_rtlists[mycpuid], brt_list) {
                struct bridge_rtinfo *bri = brt->brt_info;
-               unsigned long expire;
+               time_t expire;
 
                if (len < sizeof(*bareq))
                        break;
@@ -1482,8 +1482,8 @@ bridge_ioctl_rts(struct bridge_softc *sc, void *arg)
                memcpy(bareq->ifba_dst, brt->brt_addr, sizeof(brt->brt_addr));
                expire = bri->bri_expire;
                if ((bri->bri_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC &&
-                   time_second < expire)
-                       bareq->ifba_expire = expire - time_second;
+                   time_uptime < expire)
+                       bareq->ifba_expire = expire - time_uptime;
                else
                        bareq->ifba_expire = 0;
                bareq->ifba_flags = bri->bri_flags;
@@ -3166,8 +3166,8 @@ bridge_rtinfo_update(struct bridge_rtinfo *bri, struct ifnet *dst_if,
            bri->bri_ifp != dst_if)
                bri->bri_ifp = dst_if;
        if ((flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC &&
-           bri->bri_expire != time_second + timeo)
-               bri->bri_expire = time_second + timeo;
+           bri->bri_expire != time_uptime + timeo)
+               bri->bri_expire = time_uptime + timeo;
        if (setflags)
                bri->bri_flags = flags;
 }
@@ -3488,7 +3488,7 @@ bridge_rtage_finddead(struct bridge_softc *sc)
                struct bridge_rtinfo *bri = brt->brt_info;
 
                if ((bri->bri_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC &&
-                   time_second >= bri->bri_expire) {
+                   time_uptime >= bri->bri_expire) {
                        bri->bri_dead = 1;
                        ++dead;
                        KKASSERT(dead <= sc->sc_brtcnt);
index f46ae28..107c9ab 100644 (file)
@@ -183,7 +183,7 @@ struct ifbifconf {
  */
 struct ifbareq {
        char            ifba_ifsname[IFNAMSIZ]; /* member if name */
-       unsigned long   ifba_expire;            /* address expire time */
+       time_t          ifba_expire;            /* address expire time */
        uint8_t         ifba_flags;             /* address flags */
        uint8_t         ifba_dst[ETHER_ADDR_LEN];/* destination address */
 };
@@ -316,7 +316,7 @@ TAILQ_HEAD(bridge_iflist_head, bridge_iflist);
  */
 struct bridge_rtinfo {
        struct ifnet            *bri_ifp;       /* destination if */
-       unsigned long           bri_expire;     /* expiration time */
+       time_t                  bri_expire;     /* expiration time */
        uint8_t                 bri_flags;      /* address flags */
        uint8_t                 bri_dead;
        uint8_t                 bri_pad[2];
index 6d6868e..c812091 100644 (file)
@@ -694,10 +694,10 @@ expire_queues(struct dn_flow_set *fs)
 {
     int i, initial_elements = fs->rq_elements;
 
-    if (fs->last_expired == time_second)
+    if (fs->last_expired == time_uptime)
        return 0;
 
-    fs->last_expired = time_second;
+    fs->last_expired = time_uptime;
 
     for (i = 0; i <= fs->rq_size; i++) { /* Last one is overflow */
        struct dn_flow_queue *q, *qn;
index 92dbc12..492cbd0 100644 (file)
@@ -1173,9 +1173,9 @@ X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m,
         * Packet arrived through a source-route tunnel.
         * Source-route tunnels are no longer supported.
         */
-       static int last_log;
-       if (last_log != time_second) {
-           last_log = time_second;
+       static time_t last_log;
+       if (last_log != time_uptime) {
+           last_log = time_uptime;
            log(LOG_ERR,
                "ip_mforward: received source-routed packet from %lx\n",
                (u_long)ntohl(ip->ip_src.s_addr));
index 63ca9e5..4c5a564 100644 (file)
@@ -912,7 +912,7 @@ do {                                                                        \
 static void
 remove_dyn_rule_locked(struct ip_fw *rule, ipfw_dyn_rule *keep_me)
 {
-       static uint32_t last_remove = 0; /* XXX */
+       static time_t last_remove = 0; /* XXX */
 
 #define FORCE  (keep_me == NULL)
 
@@ -922,9 +922,9 @@ remove_dyn_rule_locked(struct ip_fw *rule, ipfw_dyn_rule *keep_me)
        if (ipfw_dyn_v == NULL || dyn_count == 0)
                return;
        /* do not expire more than once per second, it is useless */
-       if (!FORCE && last_remove == time_second)
+       if (!FORCE && last_remove == time_uptime)
                return;
-       last_remove = time_second;
+       last_remove = time_uptime;
 
        /*
         * because O_LIMIT refer to parent rules, during the first pass only
index 0f80b14..4b4634d 100644 (file)
@@ -307,7 +307,7 @@ pppalloc(struct thread *td)
        sc->sc_npmode[i] = NPMODE_ERROR;
     sc->sc_npqueue = NULL;
     sc->sc_npqtail = &sc->sc_npqueue;
-    sc->sc_last_sent = sc->sc_last_recv = time_second;
+    sc->sc_last_sent = sc->sc_last_recv = time_uptime;
 
     return sc;
 }
@@ -536,7 +536,7 @@ pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data,
 
     case PPPIOCGIDLE:
        crit_enter();
-       t = time_second;
+       t = time_uptime;
        ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
        ((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
        crit_exit();
@@ -842,14 +842,14 @@ pppoutput_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq,
         */
        if (sc->sc_active_filt.bf_insns == NULL
            || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m0, len, 0))
-           sc->sc_last_sent = time_second;
+           sc->sc_last_sent = time_uptime;
 
        *mtod(m0, u_char *) = address;
 #else
        /*
         * Update the time we sent the most recent data packet.
         */
-       sc->sc_last_sent = time_second;
+       sc->sc_last_sent = time_uptime;
 #endif /* PPP_FILTER */
     }
 
@@ -1470,14 +1470,14 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
        }
        if (sc->sc_active_filt.bf_insns == NULL
            || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m, ilen, 0))
-           sc->sc_last_recv = time_second;
+           sc->sc_last_recv = time_uptime;
 
        *mtod(m, u_char *) = adrs;
 #else
        /*
         * Record the time that we received this packet.
         */
-       sc->sc_last_recv = time_second;
+       sc->sc_last_recv = time_uptime;
 #endif /* PPP_FILTER */
     }
 
@@ -1521,7 +1521,7 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
        m->m_data += PPP_HDRLEN;
        m->m_len -= PPP_HDRLEN;
        isr = NETISR_IPX;
-       sc->sc_last_recv = time_second; /* update time of last pkt rcvd */
+       sc->sc_last_recv = time_uptime; /* update time of last pkt rcvd */
        break;
 #endif
 
index 4ce41b0..cf35135 100644 (file)
@@ -1314,7 +1314,7 @@ rt_llroute(struct sockaddr *dst, struct rtentry *rt0, struct rtentry **drt)
                rt = up_rt;
        if (rt->rt_flags & RTF_REJECT &&
            (rt->rt_rmx.rmx_expire == 0 ||              /* rt doesn't expire */
-            time_second < rt->rt_rmx.rmx_expire))      /* rt not expired */
+            time_uptime < rt->rt_rmx.rmx_expire))      /* rt not expired */
                return (rt->rt_flags & RTF_HOST ?  EHOSTDOWN : EHOSTUNREACH);
        *drt = rt;
        return 0;
index 57a1719..e672993 100644 (file)
@@ -809,15 +809,15 @@ slinput(int c, struct tty *tp)
                         * this one is within the time limit.
                         */
                        if (sc->sc_abortcount &&
-                           time_second >= sc->sc_starttime + ABT_WINDOW)
+                           time_uptime >= sc->sc_starttime + ABT_WINDOW)
                                sc->sc_abortcount = 0;
                        /*
                         * If we see an abort after "idle" time, count it;
                         * record when the first abort escape arrived.
                         */
-                       if (time_second >= sc->sc_lasttime + ABT_IDLE) {
+                       if (time_uptime >= sc->sc_lasttime + ABT_IDLE) {
                                if (++sc->sc_abortcount == 1)
-                                       sc->sc_starttime = time_second;
+                                       sc->sc_starttime = time_uptime;
                                if (sc->sc_abortcount >= ABT_COUNT) {
                                        slclose(tp,0);
                                        lwkt_reltoken(&tty_token);
@@ -826,7 +826,7 @@ slinput(int c, struct tty *tp)
                        }
                } else
                        sc->sc_abortcount = 0;
-               sc->sc_lasttime = time_second;
+               sc->sc_lasttime = time_uptime;
        }
 
        switch (c) {
index f073127..e7c5274 100644 (file)
@@ -681,7 +681,7 @@ drop2:
         * idle lines.
         */
        if (do_account)
-               sp->pp_last_recv = time_second;
+               sp->pp_last_recv = time_uptime;
 }
 
 /*
@@ -931,7 +931,7 @@ sppp_output_serialized(struct ifnet *ifp, struct ifaltq_subque *ifsq,
         * network-layer traffic; control-layer traffic is handled
         * by sppp_cp_send().
         */
-       sp->pp_last_sent = time_second;
+       sp->pp_last_sent = time_uptime;
 
        crit_exit();
        return (0);
@@ -982,7 +982,7 @@ sppp_attach(struct ifnet *ifp)
        sp->pp_phase = PHASE_DEAD;
        sp->pp_up = lcp.Up;
        sp->pp_down = lcp.Down;
-       sp->pp_last_recv = sp->pp_last_sent = time_second;
+       sp->pp_last_recv = sp->pp_last_sent = time_uptime;
        sp->confflags = 0;
 #ifdef INET
        sp->confflags |= CONF_ENABLE_VJ;
index e9f4076..cc56c69 100644 (file)
@@ -190,7 +190,7 @@ arptimer_dispatch(netmsg_t nmsg)
        crit_exit();
 
        LIST_FOREACH_MUTABLE(la, &llinfo_arp_list[cpuid], la_le, nla) {
-               if (la->la_rt->rt_expire && la->la_rt->rt_expire <= time_second)
+               if (la->la_rt->rt_expire && la->la_rt->rt_expire <= time_uptime)
                        arptfree(la);
        }
        callout_reset(&arptimer_context[cpuid].timer_ch, arpt_prune * hz,
@@ -255,7 +255,7 @@ arp_rtrequest(int req, struct rtentry *rt)
                        gate = rt->rt_gateway;
                        SDL(gate)->sdl_type = rt->rt_ifp->if_type;
                        SDL(gate)->sdl_index = rt->rt_ifp->if_index;
-                       rt->rt_expire = time_second;
+                       rt->rt_expire = time_uptime;
                        break;
                }
                /* Announce a new entry if requested. */
@@ -538,7 +538,7 @@ 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_second) &&
+       if ((rt->rt_expire == 0 || rt->rt_expire > time_uptime) &&
            sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) {
                /*
                 * If entry has an expiry time and it is approaching,
@@ -546,7 +546,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
                 * arpt_down interval.
                 */
                if ((rt->rt_expire != 0) &&
-                   (time_second + la->la_preempt > rt->rt_expire)) {
+                   (time_uptime + la->la_preempt > rt->rt_expire)) {
                        arprequest(ifp,
                                   &SIN(rt->rt_ifa->ifa_addr)->sin_addr,
                                   &SIN(dst)->sin_addr,
@@ -577,8 +577,8 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
        la->la_hold = m;
        if (rt->rt_expire || ((rt->rt_flags & RTF_STATIC) && !sdl->sdl_alen)) {
                rt->rt_flags &= ~RTF_REJECT;
-               if (la->la_asked == 0 || rt->rt_expire != time_second) {
-                       rt->rt_expire = time_second;
+               if (la->la_asked == 0 || rt->rt_expire != time_uptime) {
+                       rt->rt_expire = time_uptime;
                        if (la->la_asked++ < arp_maxtries) {
                                arprequest(ifp,
                                           &SIN(rt->rt_ifa->ifa_addr)->sin_addr,
@@ -792,7 +792,7 @@ arp_update_oncpu(struct mbuf *m, in_addr_t saddr, boolean_t create,
                }
                memcpy(LLADDR(sdl), ar_sha(ah), sdl->sdl_alen = ah->ar_hln);
                if (rt->rt_expire != 0) {
-                       rt->rt_expire = time_second + arpt_keep;
+                       rt->rt_expire = time_uptime + arpt_keep;
                }
                rt->rt_flags &= ~RTF_REJECT;
                la->la_asked = 0;
index 29f9e87..3f6f156 100644 (file)
@@ -244,7 +244,7 @@ in_closeroute(struct radix_node *rn, struct radix_node_head *head)
         */
        if (rtq_reallyold != 0) {
                rt->rt_flags |= RTPRF_EXPIRING;
-               rt->rt_rmx.rmx_expire = time_second + rtq_reallyold;
+               rt->rt_rmx.rmx_expire = time_uptime + rtq_reallyold;
        } else {
                /*
                 * Remove route from the radix tree, but defer deallocation
@@ -278,7 +278,7 @@ in_rtqkill(struct radix_node *rn, void *rock)
 
        if (rt->rt_flags & RTPRF_EXPIRING) {
                ap->found++;
-               if (ap->draining || rt->rt_rmx.rmx_expire <= time_second) {
+               if (ap->draining || rt->rt_rmx.rmx_expire <= time_uptime) {
                        if (rt->rt_refcnt > 0)
                                panic("rtqkill route really not free");
 
@@ -290,9 +290,9 @@ in_rtqkill(struct radix_node *rn, void *rock)
                                ap->killed++;
                } else {
                        if (ap->updating &&
-                           (rt->rt_rmx.rmx_expire - time_second >
-                            rtq_reallyold)) {
-                               rt->rt_rmx.rmx_expire = time_second +
+                           (int)(rt->rt_rmx.rmx_expire - time_uptime) >
+                            rtq_reallyold) {
+                               rt->rt_rmx.rmx_expire = time_uptime +
                                    rtq_reallyold;
                        }
                        ap->nextstop = lmin(ap->nextstop,
@@ -329,7 +329,7 @@ in_rtqtimo_dispatch(netmsg_t nmsg)
 
        arg.found = arg.killed = 0;
        arg.rnh = rnh;
-       arg.nextstop = time_second + rtq_timeout;
+       arg.nextstop = time_uptime + rtq_timeout;
        arg.draining = arg.updating = 0;
        rnh->rnh_walktree(rnh, in_rtqkill, &arg);
 
@@ -342,14 +342,14 @@ in_rtqtimo_dispatch(netmsg_t nmsg)
         * hard.
         */
        if ((arg.found - arg.killed > rtq_toomany) &&
-           (time_second - last_adjusted_timeout >= rtq_timeout) &&
+           (int)(time_uptime - last_adjusted_timeout) >= rtq_timeout &&
            rtq_reallyold > rtq_minreallyold) {
                rtq_reallyold = 2*rtq_reallyold / 3;
                if (rtq_reallyold < rtq_minreallyold) {
                        rtq_reallyold = rtq_minreallyold;
                }
 
-               last_adjusted_timeout = time_second;
+               last_adjusted_timeout = time_uptime;
 #ifdef DIAGNOSTIC
                log(LOG_DEBUG, "in_rtqtimo: adjusted rtq_reallyold to %d\n",
                    rtq_reallyold);
@@ -360,14 +360,14 @@ in_rtqtimo_dispatch(netmsg_t nmsg)
        }
 
        atv.tv_usec = 0;
-       atv.tv_sec = arg.nextstop - time_second;
+       atv.tv_sec = arg.nextstop - time_uptime;
        if ((int)atv.tv_sec < 1) {              /* time shift safety */
                atv.tv_sec = 1;
-               arg.nextstop = time_second + atv.tv_sec;
+               arg.nextstop = time_uptime + atv.tv_sec;
        }
        if ((int)atv.tv_sec > rtq_timeout) {    /* time shift safety */
                atv.tv_sec = rtq_timeout;
-               arg.nextstop = time_second + atv.tv_sec;
+               arg.nextstop = time_uptime + atv.tv_sec;
        }
        callout_reset(&ctx->timo_ch, tvtohz_high(&atv), in_rtqtimo, NULL);
 }
index 1f6e184..b3bf6ee 100644 (file)
@@ -359,7 +359,7 @@ ip_init(void)
        maxnipq = nmbclusters / 32;
        maxfragsperpacket = 16;
 
-       ip_id = time_second & 0xffff;
+       ip_id = time_second & 0xffff;   /* time_second survives reboots */
 
        for (cpu = 0; cpu < ncpus; ++cpu) {
                /*
index 4bf3688..3771207 100644 (file)
@@ -822,8 +822,8 @@ send:
                        if (tp->t_maxopd <= optlen + ipoptlen) {
                                static time_t last_optlen_report;
 
-                               if (last_optlen_report != time_second) {
-                                       last_optlen_report = time_second;
+                               if (last_optlen_report != time_uptime) {
+                                       last_optlen_report = time_uptime;
                                        kprintf("tcpcb %p: MSS (%d) too "
                                            "small to hold options!\n",
                                            tp, tp->t_maxopd);
index 603f3fc..78336a5 100644 (file)
@@ -1765,8 +1765,8 @@ again:
                                ltime = ND6_INFINITE_LIFETIME;
                        else {
                                if (ifa6->ia6_lifetime.ia6t_expire >
-                                   time_second)
-                                       ltime = htonl(ifa6->ia6_lifetime.ia6t_expire - time_second);
+                                   time_uptime)
+                                       ltime = htonl(ifa6->ia6_lifetime.ia6t_expire - time_uptime);
                                else
                                        ltime = 0;
                        }
index 0a64551..b38f3ce 100644 (file)
@@ -558,11 +558,11 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
                /* sanity for overflow - beware unsigned */
                lt = &ifr->ifr_ifru.ifru_lifetime;
                if (lt->ia6t_vltime != ND6_INFINITE_LIFETIME
-                && lt->ia6t_vltime + time_second < time_second) {
+                   && lt->ia6t_vltime + time_uptime < time_uptime) {
                        return EINVAL;
                }
                if (lt->ia6t_pltime != ND6_INFINITE_LIFETIME
-                && lt->ia6t_pltime + time_second < time_second) {
+                   && lt->ia6t_pltime + time_uptime < time_uptime) {
                        return EINVAL;
                }
                break;
@@ -618,12 +618,12 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
                /* for sanity */
                if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
                        ia->ia6_lifetime.ia6t_expire =
-                               time_second + ia->ia6_lifetime.ia6t_vltime;
+                               time_uptime + ia->ia6_lifetime.ia6t_vltime;
                } else
                        ia->ia6_lifetime.ia6t_expire = 0;
                if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
                        ia->ia6_lifetime.ia6t_preferred =
-                               time_second + ia->ia6_lifetime.ia6t_pltime;
+                               time_uptime + ia->ia6_lifetime.ia6t_pltime;
                } else
                        ia->ia6_lifetime.ia6t_preferred = 0;
                break;
@@ -905,7 +905,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
        /* lifetime consistency check */
        lt = &ifra->ifra_lifetime;
        if (lt->ia6t_vltime != ND6_INFINITE_LIFETIME
-           && lt->ia6t_vltime + time_second < time_second) {
+           && lt->ia6t_vltime + time_uptime < time_uptime) {
                return EINVAL;
        }
        if (lt->ia6t_vltime == 0) {
@@ -918,7 +918,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
                    ip6_sprintf(&ifra->ifra_addr.sin6_addr));
        }
        if (lt->ia6t_pltime != ND6_INFINITE_LIFETIME
-           && lt->ia6t_pltime + time_second < time_second) {
+           && lt->ia6t_pltime + time_uptime < time_uptime) {
                return EINVAL;
        }
 
@@ -1150,12 +1150,12 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
        /* for sanity */
        if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
                ia->ia6_lifetime.ia6t_expire =
-                       time_second + ia->ia6_lifetime.ia6t_vltime;
+                       time_uptime + ia->ia6_lifetime.ia6t_vltime;
        } else
                ia->ia6_lifetime.ia6t_expire = 0;
        if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
                ia->ia6_lifetime.ia6t_preferred =
-                       time_second + ia->ia6_lifetime.ia6t_pltime;
+                       time_uptime + ia->ia6_lifetime.ia6t_pltime;
        } else
                ia->ia6_lifetime.ia6t_preferred = 0;
 
index da2a76d..59f15ec 100644 (file)
@@ -369,11 +369,11 @@ extern const struct in6_addr in6addr_linklocal_allnodes;
 
 #define IFA6_IS_DEPRECATED(a)                                          \
        ((a)->ia6_lifetime.ia6t_preferred != 0 &&                       \
-        (a)->ia6_lifetime.ia6t_preferred < time_second)
+        (a)->ia6_lifetime.ia6t_preferred < time_uptime)
 
 #define IFA6_IS_INVALID(a)                                             \
        ((a)->ia6_lifetime.ia6t_expire != 0 &&                          \
-        (a)->ia6_lifetime.ia6t_expire < time_second)
+        (a)->ia6_lifetime.ia6t_expire < time_uptime)
 #endif
 
 /*
index 1e4e959..23570eb 100644 (file)
@@ -331,12 +331,12 @@ init_prefix_ltimes(struct rr_prefix *rpp)
            rpp->rp_rrf_decrprefd == 0)
                rpp->rp_preferred = 0;
        else
-               rpp->rp_preferred = time_second + rpp->rp_pltime;
+               rpp->rp_preferred = time_uptime + rpp->rp_pltime;
        if (rpp->rp_vltime == RR_INFINITE_LIFETIME ||
            rpp->rp_rrf_decrvalid == 0)
                rpp->rp_expire = 0;
        else
-               rpp->rp_expire = time_second + rpp->rp_vltime;
+               rpp->rp_expire = time_uptime + rpp->rp_vltime;
 }
 
 static int
@@ -955,7 +955,7 @@ unprefer_prefix(struct rr_prefix *rpp)
             rap = rap->ra_entry.le_next) {
                if (rap->ra_addr == NULL)
                        continue;
-               rap->ra_addr->ia6_lifetime.ia6t_preferred = time_second;
+               rap->ra_addr->ia6_lifetime.ia6t_preferred = time_uptime;
                rap->ra_addr->ia6_lifetime.ia6t_pltime = 0;
        }
 }
@@ -1190,7 +1190,7 @@ in6_rr_timer(void *ignored_arg)
        /* expire */
        rpp = LIST_FIRST(&rr_prefix);
        while (rpp) {
-               if (rpp->rp_expire && rpp->rp_expire < time_second) {
+               if (rpp->rp_expire && rpp->rp_expire < time_uptime) {
                        struct rr_prefix *next_rpp;
 
                        next_rpp = LIST_NEXT(rpp, rp_entry);
@@ -1198,7 +1198,7 @@ in6_rr_timer(void *ignored_arg)
                        rpp = next_rpp;
                        continue;
                }
-               if (rpp->rp_preferred && rpp->rp_preferred < time_second)
+               if (rpp->rp_preferred && rpp->rp_preferred < time_uptime)
                        unprefer_prefix(rpp);
                rpp = LIST_NEXT(rpp, rp_entry);
        }
index 466df0e..294c815 100644 (file)
@@ -271,7 +271,7 @@ in6_clsroute(struct radix_node *rn, struct radix_node_head *head)
         */
        if (rtq_reallyold != 0) {
                rt->rt_flags |= RTPRF_OURS;
-               rt->rt_rmx.rmx_expire = time_second + rtq_reallyold;
+               rt->rt_rmx.rmx_expire = time_uptime + rtq_reallyold;
        } else {
                /*
                 * Remove route from the radix tree, but defer deallocation
@@ -307,7 +307,7 @@ in6_rtqkill(struct radix_node *rn, void *rock)
        if (rt->rt_flags & RTPRF_OURS) {
                ap->found++;
 
-               if (ap->draining || rt->rt_rmx.rmx_expire <= time_second) {
+               if (ap->draining || rt->rt_rmx.rmx_expire <= time_uptime) {
                        if (rt->rt_refcnt > 0)
                                panic("rtqkill route really not free");
 
@@ -319,10 +319,10 @@ in6_rtqkill(struct radix_node *rn, void *rock)
                                ap->killed++;
                } else {
                        if (ap->updating &&
-                           (rt->rt_rmx.rmx_expire - time_second >
+                           (rt->rt_rmx.rmx_expire - time_uptime >
                             rtq_reallyold)) {
                                rt->rt_rmx.rmx_expire =
-                                   time_second + rtq_reallyold;
+                                   time_uptime + rtq_reallyold;
                        }
                        ap->nextstop = lmin(ap->nextstop,
                                            rt->rt_rmx.rmx_expire);
@@ -345,7 +345,7 @@ in6_rtqtimo(void *rock)
 
        arg.found = arg.killed = 0;
        arg.rnh = rnh;
-       arg.nextstop = time_second + rtq_timeout;
+       arg.nextstop = time_uptime + rtq_timeout;
        arg.draining = arg.updating = 0;
        crit_enter();
        rnh->rnh_walktree(rnh, in6_rtqkill, &arg);
@@ -360,14 +360,14 @@ in6_rtqtimo(void *rock)
         * hard.
         */
        if ((arg.found - arg.killed > rtq_toomany)
-          && (time_second - last_adjusted_timeout >= rtq_timeout)
+          && (int)(time_uptime - last_adjusted_timeout) >= rtq_timeout
           && rtq_reallyold > rtq_minreallyold) {
                rtq_reallyold = 2*rtq_reallyold / 3;
                if (rtq_reallyold < rtq_minreallyold) {
                        rtq_reallyold = rtq_minreallyold;
                }
 
-               last_adjusted_timeout = time_second;
+               last_adjusted_timeout = time_uptime;
 #ifdef DIAGNOSTIC
                log(LOG_DEBUG, "in6_rtqtimo: adjusted rtq_reallyold to %d",
                    rtq_reallyold);
@@ -380,14 +380,14 @@ in6_rtqtimo(void *rock)
        }
 
        atv.tv_usec = 0;
-       atv.tv_sec = arg.nextstop - time_second;
+       atv.tv_sec = arg.nextstop - time_uptime;
        if ((int)atv.tv_sec < 1) {              /* time shift safety */
                atv.tv_sec = 1;
-               arg.nextstop = time_second + atv.tv_sec;
+               arg.nextstop = time_uptime + atv.tv_sec;
        }
        if ((int)atv.tv_sec > rtq_timeout) {    /* time shift safety */
                atv.tv_sec = rtq_timeout;
-               arg.nextstop = time_second + atv.tv_sec;
+               arg.nextstop = time_uptime + atv.tv_sec;
        }
        callout_reset(&in6_rtqtimo_ch[mycpuid], tvtohz_high(&atv),
                      in6_rtqtimo, rock);
@@ -412,7 +412,7 @@ in6_mtuexpire(struct radix_node *rn, void *rock)
                panic("rt == NULL in in6_mtuexpire");
 
        if (rt->rt_rmx.rmx_expire && !(rt->rt_flags & RTF_PROBEMTU)) {
-               if (rt->rt_rmx.rmx_expire <= time_second) {
+               if (rt->rt_rmx.rmx_expire <= time_uptime) {
                        rt->rt_flags |= RTF_PROBEMTU;
                } else {
                        ap->nextstop = lmin(ap->nextstop,
@@ -433,20 +433,20 @@ in6_mtutimo(void *rock)
        struct timeval atv;
 
        arg.rnh = rnh;
-       arg.nextstop = time_second + MTUTIMO_DEFAULT;
+       arg.nextstop = time_uptime + MTUTIMO_DEFAULT;
        crit_enter();
        rnh->rnh_walktree(rnh, in6_mtuexpire, &arg);
        crit_exit();
 
        atv.tv_usec = 0;
-       atv.tv_sec = arg.nextstop - time_second;
+       atv.tv_sec = arg.nextstop - time_uptime;
        if ((int)atv.tv_sec < 1) {              /* time shift safety */
                atv.tv_sec = 1;
-               arg.nextstop = time_second + atv.tv_sec;
+               arg.nextstop = time_uptime + atv.tv_sec;
        }
        if ((int)atv.tv_sec > rtq_timeout) {    /* time shift safety */
                atv.tv_sec = rtq_timeout;
-               arg.nextstop = time_second + atv.tv_sec;
+               arg.nextstop = time_uptime + atv.tv_sec;
        }
        callout_reset(&in6_mtutimo_ch[mycpuid], tvtohz_high(&atv),
                      in6_mtutimo, rock);
index 241c121..8425c8a 100644 (file)
@@ -140,8 +140,8 @@ ip6_forward(struct mbuf *m, int srcrt)
            IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
                ip6stat.ip6s_cantforward++;
                /* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard) */
-               if (ip6_log_time + ip6_log_interval < time_second) {
-                       ip6_log_time = time_second;
+               if (ip6_log_time + ip6_log_interval < time_uptime) {
+                       ip6_log_time = time_uptime;
                        log(LOG_DEBUG,
                            "cannot forward "
                            "from %s to %s nxt %d received on %s\n",
@@ -361,8 +361,8 @@ skip_ipsec:
                ip6stat.ip6s_badscope++;
                in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard);
 
-               if (ip6_log_time + ip6_log_interval < time_second) {
-                       ip6_log_time = time_second;
+               if (ip6_log_time + ip6_log_interval < time_uptime) {
+                       ip6_log_time = time_uptime;
                        log(LOG_DEBUG,
                            "cannot forward "
                            "src %s, dst %s, nxt %d, rcvif %s, outif %s\n",
index b643519..e5c00f1 100644 (file)
@@ -919,8 +919,8 @@ ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
         */
        if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
                ip6stat.ip6s_cantforward++;
-               if (ip6_log_time + ip6_log_interval < time_second) {
-                       ip6_log_time = time_second;
+               if (ip6_log_time + ip6_log_interval < time_uptime) {
+                       ip6_log_time = time_uptime;
                        log(LOG_DEBUG,
                            "cannot forward "
                            "from %s to %s nxt %d received on %s\n",
index c9b71a8..095d75d 100644 (file)
@@ -428,7 +428,7 @@ nd6_timer(void *ignored_arg)
                ndi = ND_IFINFO(ifp);
                dst = (struct sockaddr_in6 *)rt_key(rt);
 
-               if (ln->ln_expire > time_second) {
+               if (ln->ln_expire > time_uptime) {
                        ln = next;
                        continue;
                }
@@ -446,7 +446,7 @@ nd6_timer(void *ignored_arg)
                case ND6_LLINFO_INCOMPLETE:
                        if (ln->ln_asked < nd6_mmaxtries) {
                                ln->ln_asked++;
-                               ln->ln_expire = time_second +
+                               ln->ln_expire = time_uptime +
                                        ND_IFINFO(ifp)->retrans / 1000;
                                nd6_ns_output(ifp, NULL, &dst->sin6_addr,
                                        ln, 0);
@@ -473,7 +473,7 @@ nd6_timer(void *ignored_arg)
                case ND6_LLINFO_REACHABLE:
                        if (ln->ln_expire) {
                                ln->ln_state = ND6_LLINFO_STALE;
-                               ln->ln_expire = time_second + nd6_gctimer;
+                               ln->ln_expire = time_uptime + nd6_gctimer;
                        }
                        break;
 
@@ -488,20 +488,20 @@ nd6_timer(void *ignored_arg)
                                /* We need NUD */
                                ln->ln_asked = 1;
                                ln->ln_state = ND6_LLINFO_PROBE;
-                               ln->ln_expire = time_second +
+                               ln->ln_expire = time_uptime +
                                        ndi->retrans / 1000;
                                nd6_ns_output(ifp, &dst->sin6_addr,
                                              &dst->sin6_addr,
                                              ln, 0);
                        } else {
                                ln->ln_state = ND6_LLINFO_STALE; /* XXX */
-                               ln->ln_expire = time_second + nd6_gctimer;
+                               ln->ln_expire = time_uptime + nd6_gctimer;
                        }
                        break;
                case ND6_LLINFO_PROBE:
                        if (ln->ln_asked < nd6_umaxtries) {
                                ln->ln_asked++;
-                               ln->ln_expire = time_second +
+                               ln->ln_expire = time_uptime +
                                        ND_IFINFO(ifp)->retrans / 1000;
                                nd6_ns_output(ifp, &dst->sin6_addr,
                                               &dst->sin6_addr, ln, 0);
@@ -516,7 +516,7 @@ nd6_timer(void *ignored_arg)
        /* expire default router list */
        dr = TAILQ_FIRST(&nd_defrouter);
        while (dr) {
-               if (dr->expire && dr->expire < time_second) {
+               if (dr->expire && dr->expire < time_uptime) {
                        struct nd_defrouter *t;
                        t = TAILQ_NEXT(dr, dr_entry);
                        defrtrlist_del(dr);
@@ -606,7 +606,7 @@ addrloop:
                 * since pltime is just for autoconf, pltime processing for
                 * prefix is not necessary.
                 */
-               if (pr->ndpr_expire && pr->ndpr_expire < time_second) {
+               if (pr->ndpr_expire && pr->ndpr_expire < time_uptime) {
                        struct nd_prefix *t;
                        t = pr->ndpr_next;
 
@@ -1045,7 +1045,7 @@ nd6_nud_hint(struct rtentry *rt, struct in6_addr *dst6, int force)
 
        ln->ln_state = ND6_LLINFO_REACHABLE;
        if (ln->ln_expire)
-               ln->ln_expire = time_second +
+               ln->ln_expire = time_uptime +
                        ND_IFINFO(rt->rt_ifp)->reachable;
 }
 
@@ -1116,7 +1116,7 @@ nd6_rtrequest(int req, struct rtentry *rt)
                        SDL(gate)->sdl_type = ifp->if_type;
                        SDL(gate)->sdl_index = ifp->if_index;
                        if (ln)
-                               ln->ln_expire = time_second;
+                               ln->ln_expire = time_uptime;
 #if 1
                        if (ln && ln->ln_expire == 0) {
                                /* kludge for desktops */
@@ -1205,7 +1205,7 @@ nd6_rtrequest(int req, struct rtentry *rt)
                         * initialized in rtrequest(), so rt_expire is 0.
                         */
                        ln->ln_state = ND6_LLINFO_NOSTATE;
-                       ln->ln_expire = time_second;
+                       ln->ln_expire = time_uptime;
                }
                rt->rt_flags |= RTF_LLINFO;
                ln->ln_next = llinfo_nd6.ln_next;
@@ -1667,7 +1667,7 @@ fail:
                         * we must set the timer now, although it is actually
                         * meaningless.
                         */
-                       ln->ln_expire = time_second + nd6_gctimer;
+                       ln->ln_expire = time_uptime + nd6_gctimer;
 
                        if (ln->ln_hold) {
                                /*
@@ -1681,7 +1681,7 @@ fail:
                        }
                } else if (ln->ln_state == ND6_LLINFO_INCOMPLETE) {
                        /* probe right away */
-                       ln->ln_expire = time_second;
+                       ln->ln_expire = time_uptime;
                }
        }
 
@@ -1901,7 +1901,7 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m,
        if ((ifp->if_flags & IFF_POINTOPOINT) &&
            ln->ln_state < ND6_LLINFO_REACHABLE) {
                ln->ln_state = ND6_LLINFO_STALE;
-               ln->ln_expire = time_second + nd6_gctimer;
+               ln->ln_expire = time_uptime + nd6_gctimer;
        }
 
        /*
@@ -1914,7 +1914,7 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m,
        if (ln->ln_state == ND6_LLINFO_STALE) {
                ln->ln_asked = 0;
                ln->ln_state = ND6_LLINFO_DELAY;
-               ln->ln_expire = time_second + nd6_delay;
+               ln->ln_expire = time_uptime + nd6_delay;
        }
 
        /*
@@ -1941,9 +1941,9 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m,
        ln->ln_hold = m;
        if (ln->ln_expire) {
                if (ln->ln_asked < nd6_mmaxtries &&
-                   ln->ln_expire < time_second) {
+                   ln->ln_expire < time_uptime) {
                        ln->ln_asked++;
-                       ln->ln_expire = time_second +
+                       ln->ln_expire = time_uptime +
                                ND_IFINFO(ifp)->retrans / 1000;
                        nd6_ns_output(ifp, NULL, &dst->sin6_addr, ln, 0);
                }
index 49d80c2..f5cd676 100644 (file)
@@ -735,11 +735,11 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
                        ln->ln_state = ND6_LLINFO_REACHABLE;
                        ln->ln_byhint = 0;
                        if (ln->ln_expire)
-                               ln->ln_expire = time_second +
+                               ln->ln_expire = time_uptime +
                                    ND_IFINFO(rt->rt_ifp)->reachable;
                } else {
                        ln->ln_state = ND6_LLINFO_STALE;
-                       ln->ln_expire = time_second + nd6_gctimer;
+                       ln->ln_expire = time_uptime + nd6_gctimer;
                }
                if ((ln->ln_router = is_router) != 0) {
                        /*
@@ -793,7 +793,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
                         */
                        if (ln->ln_state == ND6_LLINFO_REACHABLE) {
                                ln->ln_state = ND6_LLINFO_STALE;
-                               ln->ln_expire = time_second + nd6_gctimer;
+                               ln->ln_expire = time_uptime + nd6_gctimer;
                        }
                        goto freeit;
                } else if (is_override                             /* (2a) */
@@ -816,13 +816,13 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
                                ln->ln_state = ND6_LLINFO_REACHABLE;
                                ln->ln_byhint = 0;
                                if (ln->ln_expire) {
-                                       ln->ln_expire = time_second +
+                                       ln->ln_expire = time_uptime +
                                            ND_IFINFO(ifp)->reachable;
                                }
                        } else {
                                if (lladdr && llchange) {
                                        ln->ln_state = ND6_LLINFO_STALE;
-                                       ln->ln_expire = time_second + nd6_gctimer;
+                                       ln->ln_expire = time_uptime + nd6_gctimer;
                                }
                        }
                }
index f701042..8cf6f98 100644 (file)
@@ -269,7 +269,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
        dr0.rtaddr = saddr6;
        dr0.flags  = nd_ra->nd_ra_flags_reserved;
        dr0.rtlifetime = ntohs(nd_ra->nd_ra_router_lifetime);
-       dr0.expire = time_second + dr0.rtlifetime;
+       dr0.expire = time_uptime + dr0.rtlifetime;
        dr0.ifp = ifp;
        dr0.advint = 0;         /* Mobile IPv6 */
        dr0.advint_expire = 0;  /* Mobile IPv6 */
@@ -1065,7 +1065,7 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *m)
                else if (IFA6_IS_INVALID(ifa6))
                        storedlifetime = 0;
                else
-                       storedlifetime = lt6_tmp.ia6t_expire - time_second;
+                       storedlifetime = lt6_tmp.ia6t_expire - time_uptime;
 
                /* when not updating, keep the current stored lifetime. */
                lt6_tmp.ia6t_vltime = storedlifetime;
@@ -1753,14 +1753,14 @@ again:
         */
        if (ia0->ia6_lifetime.ia6t_expire != 0) {
                vltime0 = IFA6_IS_INVALID(ia0) ? 0 :
-                       (ia0->ia6_lifetime.ia6t_expire - time_second);
+                       (ia0->ia6_lifetime.ia6t_expire - time_uptime);
                if (vltime0 > ip6_temp_valid_lifetime)
                        vltime0 = ip6_temp_valid_lifetime;
        } else
                vltime0 = ip6_temp_valid_lifetime;
        if (ia0->ia6_lifetime.ia6t_preferred != 0) {
                pltime0 = IFA6_IS_DEPRECATED(ia0) ? 0 :
-                       (ia0->ia6_lifetime.ia6t_preferred - time_second);
+                       (ia0->ia6_lifetime.ia6t_preferred - time_uptime);
                if (pltime0 > ip6_temp_preferred_lifetime - ip6_desync_factor) {
                        pltime0 = ip6_temp_preferred_lifetime -
                                ip6_desync_factor;
@@ -1811,11 +1811,11 @@ in6_init_prefix_ltimes(struct nd_prefix *ndpr)
        if (ndpr->ndpr_pltime == ND6_INFINITE_LIFETIME)
                ndpr->ndpr_preferred = 0;
        else
-               ndpr->ndpr_preferred = time_second + ndpr->ndpr_pltime;
+               ndpr->ndpr_preferred = time_uptime + ndpr->ndpr_pltime;
        if (ndpr->ndpr_vltime == ND6_INFINITE_LIFETIME)
                ndpr->ndpr_expire = 0;
        else
-               ndpr->ndpr_expire = time_second + ndpr->ndpr_vltime;
+               ndpr->ndpr_expire = time_uptime + ndpr->ndpr_vltime;
 
        return 0;
 }
@@ -1827,7 +1827,7 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6)
        if (lt6->ia6t_vltime == ND6_INFINITE_LIFETIME)
                lt6->ia6t_expire = 0;
        else {
-               lt6->ia6t_expire = time_second;
+               lt6->ia6t_expire = time_uptime;
                lt6->ia6t_expire += lt6->ia6t_vltime;
        }
 
@@ -1835,7 +1835,7 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6)
        if (lt6->ia6t_pltime == ND6_INFINITE_LIFETIME)
                lt6->ia6t_preferred = 0;
        else {
-               lt6->ia6t_preferred = time_second;
+               lt6->ia6t_preferred = time_uptime;
                lt6->ia6t_preferred += lt6->ia6t_pltime;
        }
 }
index 4665bbc..4479f32 100644 (file)
@@ -151,7 +151,7 @@ struct ieee80211_node {
 #define IEEE80211_NODE_BOOST   0x0080          /* Dynamic Turbo boosted */
        uint16_t                ni_ath_defkeyix;/* Atheros def key index */
        const struct ieee80211_txparam *ni_txparms;
-       uint32_t                ni_jointime;    /* time of join (secs) */
+       time_t                  ni_jointime;    /* time of join (time_uptime) */
        uint32_t                *ni_challenge;  /* shared-key challenge */
        struct ieee80211_ies    ni_ies;         /* captured ie's */
                                                /* tx seq per-tid */
index 17fc28f..104e5bc 100644 (file)
@@ -250,8 +250,8 @@ _db_show_sta(const struct ieee80211_node *ni)
                ni->ni_ath_flags, ni->ni_ath_defkeyix);
        db_printf("\tassocid 0x%x txpower %u vlan %u\n",
                ni->ni_associd, ni->ni_txpower, ni->ni_vlan);
-       db_printf("\tjointime %d (%lu secs) challenge %p\n",
-               ni->ni_jointime, (unsigned long)(time_second - ni->ni_jointime),
+       db_printf("\tjointime %lu (%lu secs) challenge %p\n",
+               (unsigned long)ni->ni_jointime, (unsigned long)(time_uptime - ni->ni_jointime),
                ni->ni_challenge);
        db_printf("\ties: data %p len %d\n", ni->ni_ies.data, ni->ni_ies.len);
        db_printf("\t[wpa_ie %p rsn_ie %p wme_ie %p ath_ie %p\n",
index 4302d25..814035b 100644 (file)
@@ -2273,7 +2273,7 @@ ieee80211_node_join(struct ieee80211_node *ni, int resp)
                        return;
                }
                ni->ni_associd = aid | 0xc000;
-               ni->ni_jointime = time_second;
+               ni->ni_jointime = time_uptime;
                IEEE80211_AID_SET(vap, ni->ni_associd);
                vap->iv_sta_assoc++;
                ic->ic_sta_assoc++;
index da4d826..c58942b 100644 (file)
@@ -1564,7 +1564,7 @@ sta_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
                ni->ni_capinfo = capinfo;
                ni->ni_associd = associd;
                if (ni->ni_jointime == 0)
-                       ni->ni_jointime = time_second;
+                       ni->ni_jointime = time_uptime;
                if (wme != NULL &&
                    ieee80211_parse_wmeparams(vap, wme, wh) >= 0) {
                        ni->ni_flags |= IEEE80211_NODE_QOS;
index 9cb8cd4..d3c4857 100644 (file)
@@ -835,12 +835,11 @@ kernel_trap:
                {
                  static unsigned lastalert = 0;
 
-                 if(time_second - lastalert > 10)
-                   {
+                 if (time_uptime - lastalert > 10) {
                      log(LOG_WARNING, "NMI: power fail\n");
                      sysbeep(TIMER_FREQ/880, hz);
-                     lastalert = time_second;
-                   }
+                     lastalert = time_uptime;
+                 }
                    /* YYY mp count */
                  goto out2;
                }
index c425387..42a1574 100644 (file)
@@ -919,7 +919,7 @@ inittodr(time_t base)
 
        sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
 
-       y = time_second - sec;
+       y = (int)(time_second - sec);
        if (y <= -2 || y >= 2) {
                /* badly off, adjust it */
                ts.tv_sec = sec;
index 6385741..fff4d57 100644 (file)
@@ -926,7 +926,7 @@ inittodr(time_t base)
 
        sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
 
-       y = time_second - sec;
+       y = (int)(time_second - sec);
        if (y <= -2 || y >= 2) {
                /* badly off, adjust it */
                ts.tv_sec = sec;
index 27bb909..74cef1f 100644 (file)
@@ -102,8 +102,8 @@ struct cdev {
        } __si_u;
        struct bio_track si_track_read;
        struct bio_track si_track_write;
-       time_t          si_lastread;    /* time_second */
-       time_t          si_lastwrite;   /* time_second */
+       time_t          si_lastread;    /* time_uptime */
+       time_t          si_lastwrite;   /* time_uptime */
        struct vm_object *si_object;    /* vm_pager support */
        prop_dictionary_t si_dict;
        struct kqinfo   si_kqinfo;      /* degenerate delegated knotes */
index 5e5a6c6..ce1337b 100644 (file)
@@ -191,7 +191,8 @@ struct clockinfo {
 
 #ifdef _KERNEL
 
-extern time_t  time_second;
+extern time_t  time_second;            /* simple time_t (can step) */
+extern time_t  time_uptime;            /* monotonic simple uptime / seconds */
 extern int64_t ntp_tick_permanent;
 extern int64_t ntp_tick_acc;
 extern int64_t ntp_delta;
index c09061a..8fa1d3b 100644 (file)
@@ -2250,8 +2250,8 @@ devfs_new_cdev(struct dev_ops *ops, int minor, struct dev_ops *bops)
        dev->si_perms = 0;
        dev->si_drv1 = NULL;
        dev->si_drv2 = NULL;
-       dev->si_lastread = 0;           /* time_second */
-       dev->si_lastwrite = 0;          /* time_second */
+       dev->si_lastread = 0;           /* time_uptime */
+       dev->si_lastwrite = 0;          /* time_uptime */
 
        dev->si_dict = NULL;
        dev->si_parent = NULL;
index 31f6aec..21f9907 100644 (file)
@@ -1335,11 +1335,15 @@ devfs_fo_stat(struct file *fp, struct stat *sb, struct ucred *cred)
                dev = vp->v_rdev;
                if (dev != NULL) {
                        if (dev->si_lastread) {
-                               sb->st_atimespec.tv_sec = dev->si_lastread;
+                               sb->st_atimespec.tv_sec = time_second +
+                                                         (time_uptime -
+                                                          dev->si_lastread);
                                sb->st_atimespec.tv_nsec = 0;
                        }
                        if (dev->si_lastwrite) {
-                               sb->st_atimespec.tv_sec = dev->si_lastwrite;
+                               sb->st_atimespec.tv_sec = time_second +
+                                                         (time_uptime -
+                                                          dev->si_lastwrite);
                                sb->st_atimespec.tv_nsec = 0;
                        }
                }
index 47ee5fb..a4ed4ef 100644 (file)
@@ -769,7 +769,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td)
                }
                
                if (outstanding == 0 &&
-                   (rtimo == 0 || time_second >= rtimo)) {
+                   (rtimo == 0 || time_uptime >= rtimo)) {
                        error = 0;
                        goto gotreply;
                }
@@ -787,8 +787,8 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td)
                 * Wait for up to timo seconds for a reply.
                 * The socket receive timeout was set to 1 second.
                 */
-               atimo = timo + time_second;
-               while (time_second < atimo) {
+               atimo = timo + time_uptime;
+               while (time_uptime < atimo) {
                        aio.iov_base = (caddr_t) &gctx->reply;
                        aio.iov_len = sizeof(gctx->reply);
                        
@@ -803,7 +803,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td)
                        rcvflg = 0;
                        error = soreceive(so, NULL, &auio,
                                          NULL, NULL, &rcvflg);
-                       gctx->secs = time_second - gctx->starttime;
+                       gctx->secs = time_uptime - gctx->starttime;
                        for (ifctx = gctx->interfaces;
                             ifctx != NULL;
                             ifctx = ifctx->next) {
@@ -886,13 +886,13 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td)
                                        }
                                        /* Network settle delay */
                                        if (outstanding == 0)
-                                               atimo = time_second +
+                                               atimo = time_uptime +
                                                        BOOTP_SETTLE_DELAY;
                                } else
                                        kprintf(" (ignored)");
                                if (ifctx->gotrootpath) {
                                        gotrootpath = 1;
-                                       rtimo = time_second +
+                                       rtimo = time_uptime +
                                                BOOTP_SETTLE_DELAY;
                                        kprintf(" (got root path)");
                                } else
@@ -921,7 +921,7 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td)
                
                if (gotrootpath != 0) {
                        gctx->gotrootpath = gotrootpath;
-                       if (rtimo != 0 && time_second >= rtimo)
+                       if (rtimo != 0 && time_uptime >= rtimo)
                                break;
                }
        } /* forever send/receive */
@@ -1530,16 +1530,10 @@ bootpc_init(void)
        if (nfs_diskless_valid != 0)
                return;
 
-       /*
-        * Wait until arp entries can be handled.
-        */
-       while (time_second == 0)
-               tsleep(&time_second, 0, "arpkludge", 10);
-       
        gctx = kmalloc(sizeof(*gctx), M_TEMP, M_WAITOK | M_ZERO);
        
        gctx->xid = ~0xFFFF;
-       gctx->starttime = time_second;
+       gctx->starttime = time_uptime;
        
        ifctx = allocifctx(gctx);
 
index fa9471a..fcb8bdf 100644 (file)
@@ -445,7 +445,7 @@ struct nfsuid {
        int             nu_flag;        /* Flags */
        union nethostaddr nu_haddr;     /* Host addr. for dgram sockets */
        struct ucred    nu_cr;          /* Cred uid mapped to */
-       int             nu_expire;      /* Expiry time (sec) */
+       time_t          nu_expire;      /* Expiry time (time_uptime) */
        struct timeval  nu_timestamp;   /* Kerb. timestamp */
        u_int32_t       nu_nickname;    /* Nickname on server */
        NFSKERBKEY_T    nu_key;         /* and session key */
index 81a7d70..79f4239 100644 (file)
@@ -1811,14 +1811,14 @@ nfs_timer_req(struct nfsreq *req)
 #define NFSFS  (NFS_RTT_SCALE * NFS_HZ)
                if (req->r_flags & R_TIMING) {
                        static long last_time;
-                       if (nfs_showrtt && last_time != time_second) {
+                       if (nfs_showrtt && last_time != time_uptime) {
                                kprintf("rpccmd %d NFS SRTT %d SDRTT %d "
                                        "timeo %d.%03d\n",
                                        proct[req->r_procnum],
                                        NFS_SRTT(req), NFS_SDRTT(req),
                                        timeo / NFSFS,
                                        timeo % NFSFS * 1000 /  NFSFS);
-                               last_time = time_second;
+                               last_time = time_uptime;
                        }
                }
 #undef NFSFS
@@ -2453,7 +2453,7 @@ nfs_getreq(struct nfsrv_descript *nd, struct nfsd *nfsd, int has_header)
 
                        tvout.tv_sec = fxdr_unsigned(long, tvout.tv_sec);
                        tvout.tv_usec = fxdr_unsigned(long, tvout.tv_usec);
-                       if (nuidp->nu_expire < time_second ||
+                       if (nuidp->nu_expire != time_uptime ||
                            nuidp->nu_timestamp.tv_sec > tvout.tv_sec ||
                            (nuidp->nu_timestamp.tv_sec == tvout.tv_sec &&
                             nuidp->nu_timestamp.tv_usec > tvout.tv_usec)) {
index d78684a..7fa4415 100644 (file)
@@ -785,7 +785,7 @@ nfs_loadattrcache(struct vnode *vp, struct mbuf **mdp, caddr_t *dposp,
                vap->va_gen = fxdr_unsigned(u_int32_t,fp->fa2_ctime.nfsv2_usec);
                vap->va_filerev = 0;
        }
-       np->n_attrstamp = time_second;
+       np->n_attrstamp = time_uptime;
        if (vap->va_size != np->n_size) {
                if (vap->va_type == VREG) {
                        /*
@@ -923,10 +923,10 @@ nfs_getattrcache(struct vnode *vp, struct vattr *vaper)
 
        if (nfs_acdebug)
                kprintf("nfs_getattrcache: age = %d; final timeo = %d\n",
-                       (int)(time_second - np->n_attrstamp), timeo);
+                       (int)(time_uptime - np->n_attrstamp), timeo);
 #endif
 
-       if (np->n_attrstamp == 0 || (time_second - np->n_attrstamp) >= timeo) {
+       if (np->n_attrstamp == 0 || (time_uptime - np->n_attrstamp) >= timeo) {
                nfsstats.attrcache_misses++;
                return (ENOENT);
        }
index 6ea8759..d4b2ce5 100644 (file)
@@ -261,7 +261,7 @@ sys_nfssvc(struct nfssvc_args *uap)
                                    nuidp->nu_cr.cr_ngroups = NGROUPS;
                                nuidp->nu_cr.cr_ref = 1;
                                nuidp->nu_timestamp = nsd->nsd_timestamp;
-                               nuidp->nu_expire = time_second + nsd->nsd_ttl;
+                               nuidp->nu_expire = time_uptime + nsd->nsd_ttl;
                                /*
                                 * and save the session key in nu_key.
                                 */
@@ -1064,7 +1064,7 @@ nfs_getnickauth(struct nfsmount *nmp, struct ucred *cred, char **auth_str,
                if (nuidp->nu_cr.cr_uid == cred->cr_uid)
                        break;
        }
-       if (!nuidp || nuidp->nu_expire < time_second)
+       if (!nuidp || nuidp->nu_expire < time_uptime)
                return (EACCES);
 
        /*
@@ -1084,9 +1084,9 @@ nfs_getnickauth(struct nfsmount *nmp, struct ucred *cred, char **auth_str,
         */
        verfp = (u_int32_t *)verf_str;
        *verfp++ = txdr_unsigned(RPCAKN_NICKNAME);
-       if (time_second > nuidp->nu_timestamp.tv_sec ||
+       if (time_second != nuidp->nu_timestamp.tv_sec ||
            (time_second == nuidp->nu_timestamp.tv_sec &&
-            time_second > nuidp->nu_timestamp.tv_usec))
+            time_second > nuidp->nu_timestamp.tv_usec))        /* XXX */
                getmicrotime(&nuidp->nu_timestamp);
        else
                nuidp->nu_timestamp.tv_usec++;
@@ -1164,7 +1164,7 @@ nfs_savenickauth(struct nfsmount *nmp, struct ucred *cred, int len,
                        }
                        nuidp->nu_flag = 0;
                        nuidp->nu_cr.cr_uid = cred->cr_uid;
-                       nuidp->nu_expire = time_second + NFS_KERBTTL;
+                       nuidp->nu_expire = time_uptime + NFS_KERBTTL;
                        nuidp->nu_timestamp = ktvout;
                        nuidp->nu_nickname = nick;
                        bcopy(key, nuidp->nu_key, sizeof (NFSKERBKEY_T));
index eb6e2f7..3ae7ef4 100644 (file)
@@ -333,7 +333,7 @@ nwfs_attr_cachelookup(struct vnode *vp, struct vattr *va)
        struct nwnode *np = VTONW(vp);
        int diff;
 
-       diff = time_second - np->n_atime;
+       diff = (int)(time_second - np->n_atime);
        if (diff > 2) { /* XXX should be configurable */
                return ENOENT;
        }
index 4164545..ce3964c 100644 (file)
@@ -372,7 +372,7 @@ smbfs_attr_cacheenter(struct vnode *vp, struct smbfattr *fap)
                return;
        np->n_mtime = fap->fa_mtime;
        np->n_dosattr = fap->fa_attr;
-       np->n_attrage = time_second;
+       np->n_attrage = time_uptime;
        return;
 }
 
@@ -383,7 +383,7 @@ smbfs_attr_cachelookup(struct vnode *vp, struct vattr *va)
        struct smbmount *smp = VTOSMBFS(vp);
        int diff;
 
-       diff = time_second - np->n_attrage;
+       diff = (int)(time_uptime - np->n_attrage);
        if (diff > 2)   /* XXX should be configurable */
                return ENOENT;
        va->va_type = vp->v_type;               /* vnode type (for create) */
index fef770a..7b678a7 100644 (file)
@@ -491,7 +491,7 @@ softdep_process_worklist(struct mount *matchmnt)
 {
        thread_t td = curthread;
        int matchcnt, loopcount;
-       long starttime;
+       int starttime;
 
        ACQUIRE_LOCK(&lk);
 
@@ -530,7 +530,7 @@ softdep_process_worklist(struct mount *matchmnt)
                wakeup_one(&proc_waiting);
        }
        loopcount = 1;
-       starttime = time_second;
+       starttime = ticks;
        while (num_on_worklist > 0) {
                matchcnt += process_worklist_item(matchmnt, 0);
 
@@ -570,8 +570,11 @@ softdep_process_worklist(struct mount *matchmnt)
                 * Never allow processing to run for more than one
                 * second. Otherwise the other syncer tasks may get
                 * excessively backlogged.
+                *
+                * Use ticks to avoid boundary condition w/time_second or
+                * time_uptime.
                 */
-               if (starttime != time_second && matchmnt == NULL) {
+               if ((ticks - starttime) > hz && matchmnt == NULL) {
                        matchcnt = -1;
                        break;
                }
index c076a6d..18ae5ad 100644 (file)
@@ -1446,11 +1446,11 @@ vm_pageout_scan_cache(int avail_shortage, int vnodes_skipped, int recycle_count)
         * Idle process swapout -- run once per second.
         */
        if (vm_swap_idle_enabled) {
-               static long lsec;
-               if (time_second != lsec) {
+               static time_t lsec;
+               if (time_uptime != lsec) {
                        vm_pageout_req_swapout |= VM_SWAP_IDLE;
                        vm_req_vmdaemon();
-                       lsec = time_second;
+                       lsec = time_uptime;
                }
        }
 #endif