summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/net/route.c31
-rw-r--r--sys/net/route.h4
2 files changed, 32 insertions, 3 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 2d9f79bf6b1..a1a4539ece2 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.19 2000/05/21 22:19:07 provos Exp $ */
+/* $OpenBSD: route.c,v 1.20 2000/12/09 03:06:55 itojun Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -795,8 +795,10 @@ rt_timer_queue_create(timeout)
R_Malloc(rtq, struct rttimer_queue *, sizeof *rtq);
if (rtq == NULL)
return (NULL);
+ Bzero(rtq, sizeof *rtq);
rtq->rtq_timeout = timeout;
+ rtq->rtq_count = 0;
TAILQ_INIT(&rtq->rtq_head);
LIST_INSERT_HEAD(&rttimer_queue_head, rtq, rtq_link);
@@ -812,7 +814,6 @@ rt_timer_queue_change(rtq, timeout)
rtq->rtq_timeout = timeout;
}
-
void
rt_timer_queue_destroy(rtq, destroy)
struct rttimer_queue *rtq;
@@ -830,6 +831,10 @@ rt_timer_queue_destroy(rtq, destroy)
#else
free(r, M_RTABLE);
#endif
+ if (rtq->rtq_count > 0)
+ rtq->rtq_count--;
+ else
+ printf("rt_timer_queue_destroy: rtq_count reached 0\n");
}
LIST_REMOVE(rtq, rtq_link);
@@ -839,6 +844,14 @@ rt_timer_queue_destroy(rtq, destroy)
*/
}
+unsigned long
+rt_timer_count(rtq)
+ struct rttimer_queue *rtq;
+{
+
+ return rtq->rtq_count;
+}
+
void
rt_timer_remove_all(rt)
struct rtentry *rt;
@@ -853,6 +866,10 @@ rt_timer_remove_all(rt)
#else
free(r, M_RTABLE);
#endif
+ if (r->rtt_queue->rtq_count > 0)
+ r->rtt_queue->rtq_count--;
+ else
+ printf("rt_timer_remove_all: rtq_count reached 0\n");
}
}
@@ -884,6 +901,10 @@ rt_timer_add(rt, func, queue)
#else
free(r, M_RTABLE);
#endif
+ if (r->rtt_queue->rtq_count > 0)
+ r->rtt_queue->rtq_count--;
+ else
+ printf("rt_timer_add: rtq_count reached 0\n");
break; /* only one per list, so we can quit... */
}
}
@@ -895,6 +916,7 @@ rt_timer_add(rt, func, queue)
#endif
if (r == NULL)
return (ENOBUFS);
+ Bzero(r, sizeof(*r));
r->rtt_rt = rt;
r->rtt_time = current_time;
@@ -902,6 +924,7 @@ rt_timer_add(rt, func, queue)
r->rtt_queue = queue;
LIST_INSERT_HEAD(&rt->rt_timer, r, rtt_link);
TAILQ_INSERT_TAIL(&queue->rtq_head, r, rtt_next);
+ r->rtt_queue->rtq_count++;
return (0);
}
@@ -934,6 +957,10 @@ rt_timer_timer(arg)
#else
free(r, M_RTABLE);
#endif
+ if (rtq->rtq_count > 0)
+ rtq->rtq_count--;
+ else
+ printf("rt_timer_timer: rtq_count reached 0\n");
}
}
splx(s);
diff --git a/sys/net/route.h b/sys/net/route.h
index 78e2cb23b8c..088213cdd95 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.h,v 1.8 2000/05/17 00:21:12 deraadt Exp $ */
+/* $OpenBSD: route.h,v 1.9 2000/12/09 03:06:55 itojun Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@@ -259,6 +259,7 @@ struct rttimer {
struct rttimer_queue {
long rtq_timeout;
+ unsigned long rtq_count;
TAILQ_HEAD(, rttimer) rtq_head;
LIST_ENTRY(rttimer_queue) rtq_link;
};
@@ -304,6 +305,7 @@ struct rttimer_queue *
void rt_timer_queue_change __P((struct rttimer_queue *, long));
void rt_timer_queue_destroy __P((struct rttimer_queue *, int));
void rt_timer_remove_all __P((struct rtentry *));
+unsigned long rt_timer_count __P((struct rttimer_queue *));
void rt_timer_timer __P((void *));
void rtable_init __P((void **));
void rtalloc __P((struct route *));