Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Make rt_refcnt take into account rt_timer
details: https://anonhg.NetBSD.org/src/rev/f40cda7afcd1
branches: trunk
changeset: 340312:f40cda7afcd1
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Mon Aug 31 06:25:15 2015 +0000
description:
Make rt_refcnt take into account rt_timer
diffstat:
sys/net/route.c | 9 +++++++--
sys/net/route.h | 9 ++++++++-
sys/netinet/ip_icmp.c | 8 ++++++--
sys/netinet6/icmp6.c | 16 ++++++++++------
4 files changed, 31 insertions(+), 11 deletions(-)
diffs (163 lines):
diff -r 1aa7847fc18d -r f40cda7afcd1 sys/net/route.c
--- a/sys/net/route.c Mon Aug 31 06:16:08 2015 +0000
+++ b/sys/net/route.c Mon Aug 31 06:25:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.c,v 1.149 2015/08/24 22:21:26 pooka Exp $ */
+/* $NetBSD: route.c,v 1.150 2015/08/31 06:25:15 ozaki-r Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.149 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.150 2015/08/31 06:25:15 ozaki-r Exp $");
#include <sys/param.h>
#ifdef RTFLUSH_DEBUG
@@ -1270,6 +1270,7 @@
TAILQ_REMOVE(&rtq->rtq_head, r, rtt_next);
if (destroy)
RTTIMER_CALLOUT(r);
+ rtfree(r->rtt_rt);
/* we are already at splsoftnet */
pool_put(&rttimer_pool, r);
if (rtq->rtq_count > 0)
@@ -1313,6 +1314,7 @@
r->rtt_queue->rtq_count--;
else
printf("rt_timer_remove_all: rtq_count reached 0\n");
+ rtfree(r->rtt_rt);
/* we are already at splsoftnet */
pool_put(&rttimer_pool, r);
}
@@ -1341,6 +1343,7 @@
r->rtt_queue->rtq_count--;
else
printf("rt_timer_add: rtq_count reached 0\n");
+ rtfree(r->rtt_rt);
} else {
s = splsoftnet();
r = pool_get(&rttimer_pool, PR_NOWAIT);
@@ -1351,6 +1354,7 @@
memset(r, 0, sizeof(*r));
+ rt->rt_refcnt++;
r->rtt_rt = rt;
r->rtt_time = time_uptime;
r->rtt_func = func;
@@ -1377,6 +1381,7 @@
LIST_REMOVE(r, rtt_link);
TAILQ_REMOVE(&rtq->rtq_head, r, rtt_next);
RTTIMER_CALLOUT(r);
+ rtfree(r->rtt_rt);
pool_put(&rttimer_pool, r);
if (rtq->rtq_count > 0)
rtq->rtq_count--;
diff -r 1aa7847fc18d -r f40cda7afcd1 sys/net/route.h
--- a/sys/net/route.h Mon Aug 31 06:16:08 2015 +0000
+++ b/sys/net/route.h Mon Aug 31 06:25:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.h,v 1.93 2015/08/24 04:44:54 ozaki-r Exp $ */
+/* $NetBSD: route.h,v 1.94 2015/08/31 06:25:15 ozaki-r Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -412,6 +412,13 @@
return rt->rt_gwroute;
}
+static inline void
+rt_assert_referenced(const struct rtentry *rt)
+{
+
+ KASSERT(rt->rt_refcnt > 0);
+}
+
void rtcache_copy(struct route *, const struct route *);
void rtcache_free(struct route *);
struct rtentry *
diff -r 1aa7847fc18d -r f40cda7afcd1 sys/netinet/ip_icmp.c
--- a/sys/netinet/ip_icmp.c Mon Aug 31 06:16:08 2015 +0000
+++ b/sys/netinet/ip_icmp.c Mon Aug 31 06:25:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_icmp.c,v 1.141 2015/08/24 22:21:26 pooka Exp $ */
+/* $NetBSD: ip_icmp.c,v 1.142 2015/08/31 06:25:15 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -94,7 +94,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.141 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.142 2015/08/31 06:25:15 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -1214,7 +1214,9 @@
static void
icmp_mtudisc_timeout(struct rtentry *rt, struct rttimer *r)
{
+
KASSERT(rt != NULL);
+ rt_assert_referenced(rt);
if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) ==
(RTF_DYNAMIC | RTF_HOST)) {
@@ -1230,7 +1232,9 @@
static void
icmp_redirect_timeout(struct rtentry *rt, struct rttimer *r)
{
+
KASSERT(rt != NULL);
+ rt_assert_referenced(rt);
if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) ==
(RTF_DYNAMIC | RTF_HOST)) {
diff -r 1aa7847fc18d -r f40cda7afcd1 sys/netinet6/icmp6.c
--- a/sys/netinet6/icmp6.c Mon Aug 31 06:16:08 2015 +0000
+++ b/sys/netinet6/icmp6.c Mon Aug 31 06:25:15 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: icmp6.c,v 1.175 2015/08/24 22:21:27 pooka Exp $ */
+/* $NetBSD: icmp6.c,v 1.176 2015/08/31 06:25:15 ozaki-r Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.175 2015/08/24 22:21:27 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.176 2015/08/31 06:25:15 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -2714,8 +2714,10 @@
static void
icmp6_mtudisc_timeout(struct rtentry *rt, struct rttimer *r)
{
- if (rt == NULL)
- panic("icmp6_mtudisc_timeout: bad route to timeout");
+
+ KASSERT(rt != NULL);
+ rt_assert_referenced(rt);
+
if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) ==
(RTF_DYNAMIC | RTF_HOST)) {
rtrequest((int) RTM_DELETE, rt_getkey(rt),
@@ -2729,8 +2731,10 @@
static void
icmp6_redirect_timeout(struct rtentry *rt, struct rttimer *r)
{
- if (rt == NULL)
- panic("icmp6_redirect_timeout: bad route to timeout");
+
+ KASSERT(rt != NULL);
+ rt_assert_referenced(rt);
+
if ((rt->rt_flags & (RTF_GATEWAY | RTF_DYNAMIC | RTF_HOST)) ==
(RTF_GATEWAY | RTF_DYNAMIC | RTF_HOST)) {
rtrequest((int) RTM_DELETE, rt_getkey(rt),
Home |
Main Index |
Thread Index |
Old Index