summaryrefslogtreecommitdiff
path: root/sys/net/route.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2022-04-20 09:38:27 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2022-04-20 09:38:27 +0000
commit8e6531a10e872013b88f67d8fd35bb6bf0fd5ee3 (patch)
treea7833921ce410ea036de32ca16298efeb12d40b4 /sys/net/route.c
parent4e0fffb6766f5da3eee90a610d029915c5285ff7 (diff)
Route timeout was a mixture of int, u_int and long. Use type int
for timeout, add sysctl bounds checking between 0 and max int, and use time_t for absolute times. Some code assumes that the route timeout queue can be NULL and at some places this was checked. Better make sure that all queues always exist. The pool_get for struct rttimer_queue is only called from initialization and from syscall, so PR_WAITOK is possible. Keep the special hack when ip_mtudisc is set to 0. Destroy the queue and generate an empty one. If redirect timeout is 0, it should not time out. Check the value in IPv6 to make the behavior like IPv4. Sysctl net.inet6.icmp6.redirtimeout had no effect as the queue timeout was not modified. Make icmp6_sysctl() look like icmp_sysctl(). OK claudio@
Diffstat (limited to 'sys/net/route.c')
-rw-r--r--sys/net/route.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 0730e11be14..8779fa70b06 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.404 2022/04/19 19:19:31 bluhm Exp $ */
+/* $OpenBSD: route.c,v 1.405 2022/04/20 09:38:25 bluhm Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -1399,13 +1399,11 @@ rt_timer_init(void)
}
struct rttimer_queue *
-rt_timer_queue_create(u_int timeout)
+rt_timer_queue_create(int timeout)
{
struct rttimer_queue *rtq;
- rtq = pool_get(&rttimer_queue_pool, PR_NOWAIT | PR_ZERO);
- if (rtq == NULL)
- return (NULL);
+ rtq = pool_get(&rttimer_queue_pool, PR_WAITOK | PR_ZERO);
rtq->rtq_timeout = timeout;
rtq->rtq_count = 0;
@@ -1416,7 +1414,7 @@ rt_timer_queue_create(u_int timeout)
}
void
-rt_timer_queue_change(struct rttimer_queue *rtq, long timeout)
+rt_timer_queue_change(struct rttimer_queue *rtq, int timeout)
{
rtq->rtq_timeout = timeout;
}
@@ -1470,10 +1468,10 @@ rt_timer_add(struct rtentry *rt, void (*func)(struct rtentry *,
struct rttimer *), struct rttimer_queue *queue, u_int rtableid)
{
struct rttimer *r;
- long current_time;
+ time_t current_time;
current_time = getuptime();
- rt->rt_expire = getuptime() + queue->rtq_timeout;
+ rt->rt_expire = current_time + queue->rtq_timeout;
/*
* If there's already a timer with this action, destroy it before
@@ -1514,7 +1512,7 @@ rt_timer_timer(void *arg)
struct timeout *to = (struct timeout *)arg;
struct rttimer_queue *rtq;
struct rttimer *r;
- long current_time;
+ time_t current_time;
current_time = getuptime();