summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1998-03-30 09:56:58 +0000
committerphk <phk@FreeBSD.org>1998-03-30 09:56:58 +0000
commit9b703b14551addf9806978973e2ddc427d4908b4 (patch)
tree91f2de8432f719153d0de9465a9ebeee33c29077 /sys/net
parentadd2782c4ec0d7c4447da2b33d1413a2754f8a3e (diff)
downloadFreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.zip
FreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.tar.gz
Eradicate the variable "time" from the kernel, using various measures.
"time" wasn't a atomic variable, so splfoo() protection were needed around any access to it, unless you just wanted the seconds part. Most uses of time.tv_sec now uses the new variable time_second instead. gettime() changed to getmicrotime(0. Remove a couple of unneeded splfoo() protections, the new getmicrotime() is atomic, (until Bruce sets a breakpoint in it). A couple of places needed random data, so use read_random() instead of mucking about with time which isn't random. Add a new nfs_curusec() function. Mark a couple of bogosities involving the now disappeard time variable. Update ffs_update() to avoid the weird "== &time" checks, by fixing the one remaining call that passwd &time as args. Change profiling in ncr.c to use ticks instead of time. Resolution is the same. Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call hzto() which subtracts time" sequences. Reviewed by: bde
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_atmsubr.c4
-rw-r--r--sys/net/if_ethersubr.c4
-rw-r--r--sys/net/if_fddisubr.c8
-rw-r--r--sys/net/if_ppp.c22
-rw-r--r--sys/net/if_sl.c10
-rw-r--r--sys/net/if_spppsubr.c11
-rw-r--r--sys/net/ppp_tty.c4
7 files changed, 32 insertions, 31 deletions
diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c
index b005f80..7df2626 100644
--- a/sys/net/if_atmsubr.c
+++ b/sys/net/if_atmsubr.c
@@ -108,7 +108,7 @@ atm_output(ifp, m0, dst, rt0)
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
- gettime(&ifp->if_lastchange);
+ getmicrotime(&ifp->if_lastchange);
/*
* check route
@@ -263,7 +263,7 @@ atm_input(ifp, ah, m, rxhand)
m_freem(m);
return;
}
- gettime(&ifp->if_lastchange);
+ getmicrotime(&ifp->if_lastchange);
ifp->if_ibytes += m->m_pkthdr.len;
#if NBPFILTER > 0
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 9b64a59..3266f18 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
- * $Id: if_ethersubr.c,v 1.45 1998/02/20 13:11:49 bde Exp $
+ * $Id: if_ethersubr.c,v 1.46 1998/03/18 01:40:11 wollman Exp $
*/
#include "opt_atalk.h"
@@ -162,7 +162,7 @@ ether_output(ifp, m0, dst, rt0)
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 ||
- time.tv_sec < rt->rt_rmx.rmx_expire)
+ time_second < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}
switch (dst->sa_family) {
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index 8690356..5f54878 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*
* from: if_ethersubr.c,v 1.5 1994/12/13 22:31:45 wollman Exp
- * $Id: if_fddisubr.c,v 1.25 1998/01/09 00:51:55 eivind Exp $
+ * $Id: if_fddisubr.c,v 1.26 1998/02/20 13:11:49 bde Exp $
*/
#include "opt_atalk.h"
@@ -149,7 +149,7 @@ fddi_output(ifp, m0, dst, rt0)
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
- gettime(&ifp->if_lastchange);
+ getmicrotime(&ifp->if_lastchange);
#if !defined(__bsdi__) || _BSDI_VERSION >= 199401
if (rt = rt0) {
if ((rt->rt_flags & RTF_UP) == 0) {
@@ -170,7 +170,7 @@ fddi_output(ifp, m0, dst, rt0)
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 ||
- time.tv_sec < rt->rt_rmx.rmx_expire)
+ time_second < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}
#endif
@@ -474,7 +474,7 @@ fddi_input(ifp, fh, m)
m_freem(m);
return;
}
- gettime(&ifp->if_lastchange);
+ getmicrotime(&ifp->if_lastchange);
ifp->if_ibytes += m->m_pkthdr.len + sizeof (*fh);
if (fh->fddi_dhost[0] & 1) {
if (bcmp((caddr_t)fddibroadcastaddr, (caddr_t)fh->fddi_dhost,
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 5d24e4b..fd194e1 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -69,7 +69,7 @@
* Paul Mackerras (paulus@cs.anu.edu.au).
*/
-/* $Id: if_ppp.c,v 1.53 1998/01/08 23:41:28 eivind Exp $ */
+/* $Id: if_ppp.c,v 1.54 1998/03/22 06:51:54 peter Exp $ */
/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
@@ -275,7 +275,7 @@ pppalloc(pid)
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.tv_sec;
+ sc->sc_last_sent = sc->sc_last_recv = time_second;
return sc;
}
@@ -511,7 +511,7 @@ pppioctl(sc, cmd, data, flag, p)
case PPPIOCGIDLE:
s = splsoftnet();
- t = time.tv_sec;
+ t = time_second;
((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
((struct ppp_idle *)data)->recv_idle = t - sc->sc_last_recv;
splx(s);
@@ -820,14 +820,14 @@ pppoutput(ifp, m0, dst, rtp)
*/
if (sc->sc_active_filt.bf_insns == 0
|| bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m0, len, 0))
- sc->sc_last_sent = time.tv_sec;
+ sc->sc_last_sent = time_second;
*mtod(m0, u_char *) = address;
#else
/*
* Update the time we sent the most recent data packet.
*/
- sc->sc_last_sent = time.tv_sec;
+ sc->sc_last_sent = time_second;
#endif /* PPP_FILTER */
}
@@ -862,7 +862,7 @@ pppoutput(ifp, m0, dst, rtp)
IF_ENQUEUE(ifq, m0);
(*sc->sc_start)(sc);
}
- gettime(&ifp->if_lastchange);
+ getmicrotime(&ifp->if_lastchange);
ifp->if_opackets++;
ifp->if_obytes += len;
@@ -1455,14 +1455,14 @@ ppp_inproc(sc, m)
}
if (sc->sc_active_filt.bf_insns == 0
|| bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m, ilen, 0))
- sc->sc_last_recv = time.tv_sec;
+ sc->sc_last_recv = time_second;
*mtod(m, u_char *) = adrs;
#else
/*
* Record the time that we received this packet.
*/
- sc->sc_last_recv = time.tv_sec;
+ sc->sc_last_recv = time_second;
#endif /* PPP_FILTER */
}
@@ -1490,7 +1490,7 @@ ppp_inproc(sc, m)
m->m_len -= PPP_HDRLEN;
schednetisr(NETISR_IP);
inq = &ipintrq;
- sc->sc_last_recv = time.tv_sec; /* update time of last pkt rcvd */
+ sc->sc_last_recv = time_second; /* update time of last pkt rcvd */
break;
#endif
#ifdef IPX
@@ -1509,7 +1509,7 @@ ppp_inproc(sc, m)
m->m_len -= PPP_HDRLEN;
schednetisr(NETISR_IPX);
inq = &ipxintrq;
- sc->sc_last_recv = time.tv_sec; /* update time of last pkt rcvd */
+ sc->sc_last_recv = time_second; /* update time of last pkt rcvd */
break;
#endif
@@ -1538,7 +1538,7 @@ ppp_inproc(sc, m)
splx(s);
ifp->if_ipackets++;
ifp->if_ibytes += ilen;
- gettime(&ifp->if_lastchange);
+ getmicrotime(&ifp->if_lastchange);
if (rv)
(*sc->sc_ctlp)(sc);
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 5ff58ec..1b0cc01 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_sl.c 8.6 (Berkeley) 2/1/94
- * $Id: if_sl.c,v 1.66 1998/02/09 06:09:54 eivind Exp $
+ * $Id: if_sl.c,v 1.67 1998/02/13 12:46:14 phk Exp $
*/
/*
@@ -792,15 +792,15 @@ slinput(c, tp)
* this one is within the time limit.
*/
if (sc->sc_abortcount &&
- time.tv_sec >= sc->sc_starttime + ABT_WINDOW)
+ time_second >= 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.tv_sec >= sc->sc_lasttime + ABT_IDLE) {
+ if (time_second >= sc->sc_lasttime + ABT_IDLE) {
if (++sc->sc_abortcount == 1)
- sc->sc_starttime = time.tv_sec;
+ sc->sc_starttime = time_second;
if (sc->sc_abortcount >= ABT_COUNT) {
slclose(tp,0);
return 0;
@@ -808,7 +808,7 @@ slinput(c, tp)
}
} else
sc->sc_abortcount = 0;
- sc->sc_lasttime = time.tv_sec;
+ sc->sc_lasttime = time_second;
}
switch (c) {
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index 441eb7c..0f890cb 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -17,7 +17,7 @@
*
* From: Version 2.4, Thu Apr 30 17:17:21 MSD 1997
*
- * $Id: if_spppsubr.c,v 1.33 1998/02/28 21:01:09 phk Exp $
+ * $Id: if_spppsubr.c,v 1.34 1998/03/01 06:01:33 bde Exp $
*/
#include "opt_inet.h"
@@ -29,6 +29,7 @@
#include <sys/sockio.h>
#include <sys/socket.h>
#include <sys/syslog.h>
+#include <machine/random.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/md5.h>
@@ -989,7 +990,7 @@ sppp_cisco_input(struct sppp *sp, struct mbuf *m)
++sp->pp_loopcnt;
/* Generate new local sequence number */
- sp->pp_seq ^= time.tv_sec ^ time.tv_usec;
+ read_random((char*)&sp->pp_seq, sizeof sp->pp_seq);
break;
}
sp->pp_loopcnt = 0;
@@ -1017,7 +1018,7 @@ sppp_cisco_send(struct sppp *sp, int type, long par1, long par2)
struct ppp_header *h;
struct cisco_packet *ch;
struct mbuf *m;
- u_long t = (time.tv_sec - boottime.tv_sec) * 1000;
+ u_long t = (time_second - boottime.tv_sec) * 1000;
MGETHDR (m, M_DONTWAIT, MT_DATA);
if (! m)
@@ -2114,7 +2115,7 @@ sppp_lcp_RCN_nak(struct sppp *sp, struct lcp_header *h, int len)
if (magic == ~sp->lcp.magic) {
if (debug)
addlog("magic glitch ");
- sp->lcp.magic += time.tv_sec + time.tv_usec;
+ read_random((char*)&sp->lcp.magic, sizeof sp->lcp.magic);
} else {
sp->lcp.magic = magic;
if (debug)
@@ -2274,7 +2275,7 @@ sppp_lcp_scr(struct sppp *sp)
if (sp->lcp.opts & (1 << LCP_OPT_MAGIC)) {
if (! sp->lcp.magic)
- sp->lcp.magic = time.tv_sec + time.tv_usec;
+ read_random((char*)&sp->lcp.magic, sizeof sp->lcp.magic);
opt[i++] = LCP_OPT_MAGIC;
opt[i++] = 6;
opt[i++] = sp->lcp.magic >> 24;
diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c
index 9d774e4..3a3a5da 100644
--- a/sys/net/ppp_tty.c
+++ b/sys/net/ppp_tty.c
@@ -70,7 +70,7 @@
* Paul Mackerras (paulus@cs.anu.edu.au).
*/
-/* $Id: ppp_tty.c,v 1.30 1998/02/13 12:46:15 phk Exp $ */
+/* $Id: ppp_tty.c,v 1.31 1998/03/28 10:33:12 bde Exp $ */
#include "ppp.h"
#if NPPP > 0
@@ -618,7 +618,7 @@ pppasyncstart(sc)
/* Calculate the FCS for the first mbuf's worth. */
sc->sc_outfcs = pppfcs(PPP_INITFCS, mtod(m, u_char *), m->m_len);
- gettime(&sc->sc_if.if_lastchange);
+ getmicrotime(&sc->sc_if.if_lastchange);
}
for (;;) {
OpenPOWER on IntegriCloud