From 396c12b15b5bc3869a89e2d194724cd4d35e8e14 Mon Sep 17 00:00:00 2001 From: "Angelos D. Keromytis" Date: Fri, 7 Jun 2002 23:18:30 +0000 Subject: Detect wrap-around of timeout and set it to its maximum value. Hacky way of getting the max value attributed to millert@ --- sys/net/pfkeyv2_convert.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sys/net/pfkeyv2_convert.c b/sys/net/pfkeyv2_convert.c index bf2562fcd55..a882fea570c 100644 --- a/sys/net/pfkeyv2_convert.c +++ b/sys/net/pfkeyv2_convert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2_convert.c,v 1.10 2002/06/07 04:47:06 ho Exp $ */ +/* $OpenBSD: pfkeyv2_convert.c,v 1.11 2002/06/07 23:18:29 angelos Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@keromytis.org) * @@ -270,9 +270,11 @@ 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; - tv.tv_sec += tdb->tdb_exp_timeout; - timeout_add(&tdb->tdb_timer_tmo, - hzto(&tv)); + 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)); } else tdb->tdb_flags &= ~TDBF_TIMER; @@ -299,9 +301,11 @@ 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; - tv.tv_sec += tdb->tdb_soft_timeout; - timeout_add(&tdb->tdb_stimer_tmo, - hzto(&tv)); + 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)); } else tdb->tdb_flags &= ~TDBF_SOFT_TIMER; -- cgit v1.2.3