summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>2004-06-21 23:50:39 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>2004-06-21 23:50:39 +0000
commitee05a750df8c3f9f5d686affb4df7e316507797a (patch)
tree887af571215b85d480946bb169aafa0605c786db /sys/netinet
parente84c5b85eb5d0fc9af7eb3cdcc77a22eb07dec74 (diff)
First step towards more sane time handling in the kernel -- this changes
things such that code that only need a second-resolution uptime or wall time, and used to get that from time.tv_secs or mono_time.tv_secs now get this from separate time_t globals time_second and time_uptime. ok art@ niklas@ nordin@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/if_ether.c20
-rw-r--r--sys/netinet/ip_id.c6
-rw-r--r--sys/netinet/ip_ipsp.c28
-rw-r--r--sys/netinet/ip_output.c4
-rw-r--r--sys/netinet/ip_spd.c10
-rw-r--r--sys/netinet/ipsec_input.c12
-rw-r--r--sys/netinet/ipsec_output.c12
-rw-r--r--sys/netinet/tcp_subr.c6
8 files changed, 45 insertions, 53 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 7153125e150..2b1aa14b674 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.c,v 1.53 2003/12/18 09:23:14 ho Exp $ */
+/* $OpenBSD: if_ether.c,v 1.54 2004/06/21 23:50:37 tholo Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
@@ -126,7 +126,7 @@ arptimer(arg)
struct rtentry *rt = la->la_rt;
nla = LIST_NEXT(la, la_list);
- if (rt->rt_expire && rt->rt_expire <= time.tv_sec)
+ if (rt->rt_expire && rt->rt_expire <= time_second)
arptfree(la); /* timer has expired; clear */
}
splx(s);
@@ -155,8 +155,8 @@ arp_rtrequest(req, rt, info)
* We generate expiration times from time.tv_sec
* so avoid accidently creating permanent routes.
*/
- if (time.tv_sec == 0) {
- time.tv_sec++;
+ if (time_second == 0) {
+ time_second++;
}
timeout_set(&arptimer_to, arptimer, &arptimer_to);
@@ -207,7 +207,7 @@ arp_rtrequest(req, rt, info)
* it's a "permanent" route, so that routes cloned
* from it do not need their expiration time set.
*/
- rt->rt_expire = time.tv_sec;
+ rt->rt_expire = time_second;
/*
* linklayers with particular link MTU limitation.
*/
@@ -401,7 +401,7 @@ arpresolve(ac, rt, m, dst, desten)
* 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.tv_sec) &&
+ if ((rt->rt_expire == 0 || rt->rt_expire > time_second) &&
sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) {
bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
return 1;
@@ -425,13 +425,13 @@ arpresolve(ac, rt, m, dst, desten)
/* This should never happen. (Should it? -gwr) */
printf("arpresolve: unresolved and rt_expire == 0\n");
/* Set expiration time to now (expired). */
- rt->rt_expire = time.tv_sec;
+ rt->rt_expire = time_second;
}
#endif
if (rt->rt_expire) {
rt->rt_flags &= ~RTF_REJECT;
- if (la->la_asked == 0 || rt->rt_expire != time.tv_sec) {
- rt->rt_expire = time.tv_sec;
+ if (la->la_asked == 0 || rt->rt_expire != time_second) {
+ rt->rt_expire = time_second;
if (la->la_asked++ < arp_maxtries)
arprequest(&ac->ac_if,
&(SIN(rt->rt_ifa->ifa_addr)->sin_addr.s_addr),
@@ -657,7 +657,7 @@ in_arpinput(m)
bcopy(ea->arp_sha, LLADDR(sdl),
sdl->sdl_alen = sizeof(ea->arp_sha));
if (rt->rt_expire)
- rt->rt_expire = time.tv_sec + arpt_keep;
+ rt->rt_expire = time_second + arpt_keep;
rt->rt_flags &= ~RTF_REJECT;
la->la_asked = 0;
if (la->la_hold) {
diff --git a/sys/netinet/ip_id.c b/sys/netinet/ip_id.c
index b2a946bc9ef..d8c5fe6fef5 100644
--- a/sys/netinet/ip_id.c
+++ b/sys/netinet/ip_id.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_id.c,v 1.12 2004/03/22 04:37:20 deraadt Exp $ */
+/* $OpenBSD: ip_id.c,v 1.13 2004/06/21 23:50:37 tholo Exp $ */
/*
* Copyright 1998 Niels Provos <provos@citi.umich.edu>
@@ -154,7 +154,7 @@ ip_initid(void)
ru_g = pmod(RU_GEN,j,RU_N);
ru_counter = 0;
- ru_reseed = time.tv_sec + RU_OUT;
+ ru_reseed = time_second + RU_OUT;
ru_msb = ru_msb == 0x8000 ? 0 : 0x8000;
}
@@ -163,7 +163,7 @@ ip_randomid(void)
{
int i, n;
- if (ru_counter >= RU_MAX || time.tv_sec > ru_reseed)
+ if (ru_counter >= RU_MAX || time_second > ru_reseed)
ip_initid();
#if 0
diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c
index 47b280610af..4b27ebb18c5 100644
--- a/sys/netinet/ip_ipsp.c
+++ b/sys/netinet/ip_ipsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.c,v 1.158 2004/04/14 20:10:04 markus Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.159 2004/06/21 23:50:37 tholo Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -690,7 +690,7 @@ puttdb(struct tdb *tdbp)
tdb_count++;
- ipsec_last_added = time.tv_sec;
+ ipsec_last_added = time_second;
splx(s);
}
@@ -858,7 +858,7 @@ tdb_alloc(void)
TAILQ_INIT(&tdbp->tdb_policy_head);
/* Record establishment time. */
- tdbp->tdb_established = time.tv_sec;
+ tdbp->tdb_established = time_second;
tdbp->tdb_epoch = kernfs_epoch - 1;
/* Initialize timeouts. */
@@ -919,7 +919,7 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer, size_t buflen)
"\tEstablished %d seconds ago\n"
"\tSource = %s",
ntohl(tdb->tdb_spi), ipsp_address(tdb->tdb_dst), tdb->tdb_sproto,
- time.tv_sec - tdb->tdb_established,
+ time_second - tdb->tdb_established,
ipsp_address(tdb->tdb_src));
l = strlen(buffer);
@@ -931,10 +931,10 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer, size_t buflen)
snprintf(buffer + l, buflen - l, "\n");
l += strlen(buffer + l);
- if (tdb->tdb_mtu && tdb->tdb_mtutimeout > time.tv_sec) {
+ if (tdb->tdb_mtu && tdb->tdb_mtutimeout > time_second) {
snprintf(buffer + l, buflen - l,
"\tMTU: %d, expires in %llu seconds\n",
- tdb->tdb_mtu, tdb->tdb_mtutimeout - time.tv_sec);
+ tdb->tdb_mtu, tdb->tdb_mtutimeout - time_second);
l += strlen(buffer + l);
}
@@ -1053,14 +1053,14 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer, size_t buflen)
if (tdb->tdb_last_used) {
snprintf(buffer + l, buflen - l,
"\tLast used %llu seconds ago\n",
- time.tv_sec - tdb->tdb_last_used);
+ time_second - tdb->tdb_last_used);
l += strlen(buffer + l);
}
if (tdb->tdb_last_marked) {
snprintf(buffer + l, buflen - l,
"\tLast marked/unmarked %llu seconds ago\n",
- time.tv_sec - tdb->tdb_last_marked);
+ time_second - tdb->tdb_last_marked);
l += strlen(buffer + l);
}
@@ -1071,14 +1071,14 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer, size_t buflen)
if (tdb->tdb_flags & TDBF_TIMER) {
snprintf(buffer + l, buflen -l,
"\t\tHard expiration(1) in %llu seconds\n",
- tdb->tdb_established + tdb->tdb_exp_timeout - time.tv_sec);
+ tdb->tdb_established + tdb->tdb_exp_timeout - time_second);
l += strlen(buffer + l);
}
if (tdb->tdb_flags & TDBF_SOFT_TIMER) {
snprintf(buffer + l, buflen -l,
"\t\tSoft expiration(1) in %llu seconds\n",
tdb->tdb_established + tdb->tdb_soft_timeout -
- time.tv_sec);
+ time_second);
l += strlen(buffer + l);
}
if (tdb->tdb_flags & TDBF_BYTES) {
@@ -1110,7 +1110,7 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer, size_t buflen)
snprintf(buffer + l, buflen -l,
"\t\tHard expiration(2) in %llu seconds\n",
(tdb->tdb_first_use + tdb->tdb_exp_first_use) -
- time.tv_sec);
+ time_second);
l += strlen(buffer + l);
} else {
snprintf(buffer + l, buflen -l,
@@ -1126,7 +1126,7 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer, size_t buflen)
snprintf(buffer + l, buflen -l,
"\t\tSoft expiration(2) in %llu seconds\n",
(tdb->tdb_first_use + tdb->tdb_soft_first_use) -
- time.tv_sec);
+ time_second);
l += strlen(buffer + l);
} else {
snprintf(buffer + l, buflen -l,
@@ -1336,7 +1336,7 @@ ipsp_skipcrypto_mark(struct tdb_ident *tdbi)
tdb = gettdb(tdbi->spi, &tdbi->dst, tdbi->proto);
if (tdb != NULL) {
tdb->tdb_flags |= TDBF_SKIPCRYPTO;
- tdb->tdb_last_marked = time.tv_sec;
+ tdb->tdb_last_marked = time_second;
}
splx(s);
}
@@ -1351,7 +1351,7 @@ ipsp_skipcrypto_unmark(struct tdb_ident *tdbi)
tdb = gettdb(tdbi->spi, &tdbi->dst, tdbi->proto);
if (tdb != NULL) {
tdb->tdb_flags &= ~TDBF_SKIPCRYPTO;
- tdb->tdb_last_marked = time.tv_sec;
+ tdb->tdb_last_marked = time_second;
}
splx(s);
}
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 701134d30cf..69badd9337a 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.165 2004/06/21 19:26:01 mcbride Exp $ */
+/* $OpenBSD: ip_output.c,v 1.166 2004/06/21 23:50:37 tholo Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -618,7 +618,7 @@ sendit:
/* Check if we are allowed to fragment */
if (ip_mtudisc && (ip->ip_off & htons(IP_DF)) && tdb->tdb_mtu &&
ntohs(ip->ip_len) > tdb->tdb_mtu &&
- tdb->tdb_mtutimeout > time.tv_sec) {
+ tdb->tdb_mtutimeout > time_second) {
struct rtentry *rt = NULL;
int rt_mtucloned = 0;
diff --git a/sys/netinet/ip_spd.c b/sys/netinet/ip_spd.c
index a8099ead19a..357a567cdf4 100644
--- a/sys/netinet/ip_spd.c
+++ b/sys/netinet/ip_spd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_spd.c,v 1.49 2004/06/21 20:44:54 itojun Exp $ */
+/* $OpenBSD: ip_spd.c,v 1.50 2004/06/21 23:50:37 tholo Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -386,7 +386,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction,
if (ipo->ipo_last_searched <= ipsec_last_added) {
/* "Touch" the entry. */
if (dignore == 0)
- ipo->ipo_last_searched = time.tv_sec;
+ ipo->ipo_last_searched = time_second;
/* Find an appropriate SA from the existing ones. */
ipo->ipo_tdb =
@@ -500,7 +500,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int *error, int direction,
/* Find whether there exists an appropriate SA. */
if (ipo->ipo_last_searched <= ipsec_last_added) {
if (dignore == 0)
- ipo->ipo_last_searched = time.tv_sec;
+ ipo->ipo_last_searched = time_second;
ipo->ipo_tdb =
gettdbbysrc(dignore ? &ssrc : &ipo->ipo_dst,
@@ -1005,7 +1005,7 @@ ipsp_spd_inp(struct mbuf *m, int af, int hlen, int *error, int direction,
*/
if (inp->inp_ipo->ipo_last_searched <=
ipsec_last_added) {
- inp->inp_ipo->ipo_last_searched = time.tv_sec;
+ inp->inp_ipo->ipo_last_searched = time_second;
/* Do we have an SA already established ? */
if (gettdbbysrc(&inp->inp_ipo->ipo_dst,
@@ -1058,7 +1058,7 @@ ipsp_spd_inp(struct mbuf *m, int af, int hlen, int *error, int direction,
if (inp->inp_ipo != NULL) {
if (inp->inp_ipo->ipo_last_searched <=
ipsec_last_added) {
- inp->inp_ipo->ipo_last_searched = time.tv_sec;
+ inp->inp_ipo->ipo_last_searched = time_second;
/* Update, just in case. */
ipsec_update_policy(inp, inp->inp_ipo, af,
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index 0765dac25cd..43bd253b723 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.73 2004/06/21 20:44:54 itojun Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.74 2004/06/21 23:50:37 tholo Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -242,11 +242,7 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto,
/* Register first use, setup expiration timer. */
if (tdbp->tdb_first_use == 0) {
- int pri;
-
- pri = splhigh();
- tdbp->tdb_first_use = time.tv_sec;
- splx(pri);
+ tdbp->tdb_first_use = time_second;
tv.tv_usec = 0;
@@ -295,7 +291,7 @@ ipsec_common_input_cb(struct mbuf *m, struct tdb *tdbp, int skip, int protoff,
af = tdbp->tdb_dst.sa.sa_family;
sproto = tdbp->tdb_sproto;
- tdbp->tdb_last_used = time.tv_sec;
+ tdbp->tdb_last_used = time_second;
/* Sanity check */
if (m == NULL) {
@@ -868,7 +864,7 @@ ipsec_common_ctlinput(int cmd, struct sockaddr *sa, void *v, int proto)
/* Store adjusted MTU in tdb */
tdbp->tdb_mtu = mtu;
- tdbp->tdb_mtutimeout = time.tv_sec +
+ tdbp->tdb_mtutimeout = time_second +
ip_mtudisc_timeout;
}
splx(s);
diff --git a/sys/netinet/ipsec_output.c b/sys/netinet/ipsec_output.c
index d14e0abe205..3aa5abbfe1c 100644
--- a/sys/netinet/ipsec_output.c
+++ b/sys/netinet/ipsec_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_output.c,v 1.29 2004/06/21 23:11:39 markus Exp $ */
+/* $OpenBSD: ipsec_output.c,v 1.30 2004/06/21 23:50:37 tholo Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -131,11 +131,7 @@ ipsp_process_packet(struct mbuf *m, struct tdb *tdb, int af, int tunalready)
* Register first use if applicable, setup relevant expiration timer.
*/
if (tdb->tdb_first_use == 0) {
- int pri;
-
- pri = splhigh();
- tdb->tdb_first_use = time.tv_sec;
- splx(pri);
+ tdb->tdb_first_use = time_second;
tv.tv_usec = 0;
@@ -338,7 +334,7 @@ ipsp_process_done(struct mbuf *m, struct tdb *tdb)
struct tdb_ident *tdbi;
struct m_tag *mtag;
- tdb->tdb_last_used = time.tv_sec;
+ tdb->tdb_last_used = time_second;
if ((tdb->tdb_flags & TDBF_UDPENCAP) != 0) {
struct mbuf *mi;
@@ -535,7 +531,7 @@ ipsec_adjust_mtu(struct mbuf *m, u_int32_t mtu)
mtu -= adjust;
tdbp->tdb_mtu = mtu;
- tdbp->tdb_mtutimeout = time.tv_sec + ip_mtudisc_timeout;
+ tdbp->tdb_mtutimeout = time_second + ip_mtudisc_timeout;
}
splx(s);
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 13116592f04..f666cd62448 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_subr.c,v 1.81 2004/06/08 19:47:24 markus Exp $ */
+/* $OpenBSD: tcp_subr.c,v 1.82 2004/06/21 23:50:37 tholo Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
@@ -1128,7 +1128,7 @@ tcp_rndiss_init()
{
get_random_bytes(tcp_rndiss_sbox, sizeof(tcp_rndiss_sbox));
- tcp_rndiss_reseed = time.tv_sec + TCP_RNDISS_OUT;
+ tcp_rndiss_reseed = time_second + TCP_RNDISS_OUT;
tcp_rndiss_msb = tcp_rndiss_msb == 0x8000 ? 0 : 0x8000;
tcp_rndiss_cnt = 0;
}
@@ -1137,7 +1137,7 @@ tcp_seq
tcp_rndiss_next()
{
if (tcp_rndiss_cnt >= TCP_RNDISS_MAX ||
- time.tv_sec > tcp_rndiss_reseed)
+ time_second > tcp_rndiss_reseed)
tcp_rndiss_init();
/* (arc4random() & 0x7fff) ensures a 32768 byte gap between ISS */