summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2015-06-11 15:59:18 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2015-06-11 15:59:18 +0000
commit771837ae081d675267bc2b832d98eb0d20854f5f (patch)
treec67e1b25338fa45dc46f2565995ff8982e8ffeac
parentaecfb8a3ee0564f82deb1b8a8f0e87771e0ee47a (diff)
Move away from using hzto(9); OK dlg
-rw-r--r--sys/net/if_bridge.c32
-rw-r--r--sys/net/pfkeyv2_convert.c20
-rw-r--r--sys/netinet/ipsec_input.c15
-rw-r--r--sys/netinet/ipsec_output.c17
4 files changed, 20 insertions, 64 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 887ae427ad5..68fa9ba3470 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bridge.c,v 1.241 2015/06/08 13:44:08 mpi Exp $ */
+/* $OpenBSD: if_bridge.c,v 1.242 2015/06/11 15:59:17 mikeb Exp $ */
/*
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
@@ -2162,7 +2162,6 @@ bridge_ipsec(struct bridge_softc *sc, struct ifnet *ifp,
int dir, int af, int hlen, struct mbuf *m)
{
union sockaddr_union dst;
- struct timeval tv;
struct tdb *tdb;
u_int32_t spi;
u_int16_t cpi;
@@ -2258,33 +2257,12 @@ bridge_ipsec(struct bridge_softc *sc, struct ifnet *ifp,
tdb->tdb_xform != NULL) {
if (tdb->tdb_first_use == 0) {
tdb->tdb_first_use = time_second;
-
- tv.tv_usec = 0;
-
- /* Check for wrap-around. */
- if (tdb->tdb_exp_first_use + tdb->tdb_first_use
- < tdb->tdb_first_use)
- tv.tv_sec = ((unsigned long)-1) / 2;
- else
- tv.tv_sec = tdb->tdb_exp_first_use +
- tdb->tdb_first_use;
-
if (tdb->tdb_flags & TDBF_FIRSTUSE)
- timeout_add(&tdb->tdb_first_tmo,
- hzto(&tv));
-
- /* Check for wrap-around. */
- if (tdb->tdb_first_use +
- tdb->tdb_soft_first_use
- < tdb->tdb_first_use)
- tv.tv_sec = ((unsigned long)-1) / 2;
- else
- tv.tv_sec = tdb->tdb_first_use +
- tdb->tdb_soft_first_use;
-
+ timeout_add_sec(&tdb->tdb_first_tmo,
+ tdb->tdb_exp_first_use);
if (tdb->tdb_flags & TDBF_SOFT_FIRSTUSE)
- timeout_add(&tdb->tdb_sfirst_tmo,
- hzto(&tv));
+ timeout_add_sec(&tdb->tdb_sfirst_tmo,
+ tdb->tdb_soft_first_use);
}
(*(tdb->tdb_xform->xf_input))(m, tdb, hlen, off);
diff --git a/sys/net/pfkeyv2_convert.c b/sys/net/pfkeyv2_convert.c
index ab322693e78..cbad909ec6b 100644
--- a/sys/net/pfkeyv2_convert.c
+++ b/sys/net/pfkeyv2_convert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkeyv2_convert.c,v 1.53 2015/05/25 22:18:38 benno Exp $ */
+/* $OpenBSD: pfkeyv2_convert.c,v 1.54 2015/06/11 15:59:17 mikeb Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@keromytis.org)
*
@@ -279,13 +279,9 @@ export_sa(void **p, struct tdb *tdb)
void
import_lifetime(struct tdb *tdb, struct sadb_lifetime *sadb_lifetime, int type)
{
- struct timeval tv;
-
if (!sadb_lifetime)
return;
- getmicrotime(&tv);
-
switch (type) {
case PFKEYV2_LIFETIME_HARD:
if ((tdb->tdb_exp_allocations =
@@ -303,11 +299,8 @@ import_lifetime(struct tdb *tdb, struct sadb_lifetime *sadb_lifetime, int type)
if ((tdb->tdb_exp_timeout =
sadb_lifetime->sadb_lifetime_addtime) != 0) {
tdb->tdb_flags |= TDBF_TIMER;
- if (tv.tv_sec + tdb->tdb_exp_timeout < tv.tv_sec)
- tv.tv_sec = ((unsigned long) -1) / 2; /* XXX */
- else
- tv.tv_sec += tdb->tdb_exp_timeout;
- timeout_add(&tdb->tdb_timer_tmo, hzto(&tv));
+ timeout_add_sec(&tdb->tdb_timer_tmo,
+ tdb->tdb_exp_timeout);
} else
tdb->tdb_flags &= ~TDBF_TIMER;
@@ -334,11 +327,8 @@ import_lifetime(struct tdb *tdb, struct sadb_lifetime *sadb_lifetime, int type)
if ((tdb->tdb_soft_timeout =
sadb_lifetime->sadb_lifetime_addtime) != 0) {
tdb->tdb_flags |= TDBF_SOFT_TIMER;
- if (tv.tv_sec + tdb->tdb_soft_timeout < tv.tv_sec)
- tv.tv_sec = ((unsigned long) -1) / 2; /* XXX */
- else
- tv.tv_sec += tdb->tdb_soft_timeout;
- timeout_add(&tdb->tdb_stimer_tmo, hzto(&tv));
+ timeout_add_sec(&tdb->tdb_stimer_tmo,
+ tdb->tdb_soft_timeout);
} else
tdb->tdb_flags &= ~TDBF_SOFT_TIMER;
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index 7ecab1e41d4..a95dbda1a6d 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.131 2015/05/13 10:42:46 jsg Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.132 2015/06/11 15:59:17 mikeb Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -119,7 +119,6 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto,
sproto == IPPROTO_AH ? (y)++ : (z)++)
union sockaddr_union dst_address;
- struct timeval tv;
struct tdb *tdbp;
struct ifnet *encif;
u_int32_t spi;
@@ -297,16 +296,12 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto,
/* Register first use, setup expiration timer. */
if (tdbp->tdb_first_use == 0) {
tdbp->tdb_first_use = time_second;
-
- tv.tv_usec = 0;
-
- tv.tv_sec = tdbp->tdb_exp_first_use + tdbp->tdb_first_use;
if (tdbp->tdb_flags & TDBF_FIRSTUSE)
- timeout_add(&tdbp->tdb_first_tmo, hzto(&tv));
-
- tv.tv_sec = tdbp->tdb_first_use + tdbp->tdb_soft_first_use;
+ timeout_add_sec(&tdbp->tdb_first_tmo,
+ tdbp->tdb_exp_first_use);
if (tdbp->tdb_flags & TDBF_SOFT_FIRSTUSE)
- timeout_add(&tdbp->tdb_sfirst_tmo, hzto(&tv));
+ timeout_add_sec(&tdbp->tdb_sfirst_tmo,
+ tdbp->tdb_soft_first_use);
}
/*
diff --git a/sys/netinet/ipsec_output.c b/sys/netinet/ipsec_output.c
index b6bb4510f3d..2ddd05d6269 100644
--- a/sys/netinet/ipsec_output.c
+++ b/sys/netinet/ipsec_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_output.c,v 1.58 2015/04/17 11:04:02 mikeb Exp $ */
+/* $OpenBSD: ipsec_output.c,v 1.59 2015/06/11 15:59:17 mikeb Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -65,7 +65,6 @@ int udpencap_port = 4500; /* triggers decapsulation */
int
ipsp_process_packet(struct mbuf *m, struct tdb *tdb, int af, int tunalready)
{
- struct timeval tv;
int i, off, error;
struct mbuf *mp;
#ifdef INET6
@@ -135,18 +134,12 @@ ipsp_process_packet(struct mbuf *m, struct tdb *tdb, int af, int tunalready)
*/
if (tdb->tdb_first_use == 0) {
tdb->tdb_first_use = time_second;
-
- tv.tv_usec = 0;
-
- tv.tv_sec = tdb->tdb_first_use + tdb->tdb_exp_first_use;
if (tdb->tdb_flags & TDBF_FIRSTUSE)
- timeout_add(&tdb->tdb_first_tmo,
- hzto(&tv));
-
- tv.tv_sec = tdb->tdb_first_use + tdb->tdb_soft_first_use;
+ timeout_add_sec(&tdb->tdb_first_tmo,
+ tdb->tdb_exp_first_use);
if (tdb->tdb_flags & TDBF_SOFT_FIRSTUSE)
- timeout_add(&tdb->tdb_sfirst_tmo,
- hzto(&tv));
+ timeout_add_sec(&tdb->tdb_sfirst_tmo,
+ tdb->tdb_soft_first_use);
}
/*