Move away from using hzto(9); OK dlg
authormikeb <mikeb@openbsd.org>
Thu, 11 Jun 2015 15:59:17 +0000 (15:59 +0000)
committermikeb <mikeb@openbsd.org>
Thu, 11 Jun 2015 15:59:17 +0000 (15:59 +0000)
sys/net/if_bridge.c
sys/net/pfkeyv2_convert.c
sys/netinet/ipsec_input.c
sys/netinet/ipsec_output.c

index 887ae42..68fa9ba 100644 (file)
@@ -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);
index ab32269..cbad909 100644 (file)
@@ -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;
 
index 7ecab1e..a95dbda 100644 (file)
@@ -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);
        }
 
        /*
index b6bb451..2ddd05d 100644 (file)
@@ -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);
        }
 
        /*