Do rt_refcnt++ when set a rtentry to another rtentry's rt_gwroute
And also do rtfree when deref a rtentry from rt_gwroute.
This commit is contained in:
parent
817770d6b0
commit
54c4f3b688
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: route.h,v 1.95 2015/08/31 08:02:44 ozaki-r Exp $ */
|
||||
/* $NetBSD: route.h,v 1.96 2015/09/02 11:35:11 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
|
@ -413,6 +413,15 @@ rt_get_gwroute(struct rtentry *rt)
|
|||
return rt->rt_gwroute;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rt_set_gwroute(struct rtentry *rt, struct rtentry *gwrt)
|
||||
{
|
||||
|
||||
rt->rt_gwroute = gwrt;
|
||||
if (rt->rt_gwroute != NULL)
|
||||
rt->rt_gwroute->rt_refcnt++;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rt_assert_referenced(const struct rtentry *rt)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ip_output.c,v 1.246 2015/08/24 22:21:26 pooka Exp $ */
|
||||
/* $NetBSD: ip_output.c,v 1.247 2015/09/02 11:35:11 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -91,7 +91,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.246 2015/08/24 22:21:26 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.247 2015/09/02 11:35:11 ozaki-r Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -260,7 +260,8 @@ retry:
|
|||
error = EHOSTUNREACH;
|
||||
goto bad;
|
||||
}
|
||||
gwrt = rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1);
|
||||
gwrt = rtalloc1(rt->rt_gateway, 1);
|
||||
rt_set_gwroute(rt, gwrt);
|
||||
RTFREE_IF_NEEDED(rt);
|
||||
rt = gwrt;
|
||||
if (rt == NULL) {
|
||||
|
@ -269,6 +270,8 @@ retry:
|
|||
}
|
||||
/* the "G" test below also prevents rt == rt0 */
|
||||
if ((rt->rt_flags & RTF_GATEWAY) != 0 || rt->rt_ifp != ifp) {
|
||||
if (rt0->rt_gwroute != NULL)
|
||||
rtfree(rt0->rt_gwroute);
|
||||
rt0->rt_gwroute = NULL;
|
||||
error = EHOSTUNREACH;
|
||||
goto bad;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nd6.c,v 1.173 2015/09/02 08:03:10 ozaki-r Exp $ */
|
||||
/* $NetBSD: nd6.c,v 1.174 2015/09/02 11:35:11 ozaki-r Exp $ */
|
||||
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.173 2015/09/02 08:03:10 ozaki-r Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.174 2015/09/02 11:35:11 ozaki-r Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_net_mpsafe.h"
|
||||
|
@ -2215,8 +2215,8 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
|
|||
rtfree(rt);
|
||||
rt = rt0;
|
||||
lookup:
|
||||
gwrt = rt->rt_gwroute =
|
||||
rtalloc1(rt->rt_gateway, 1);
|
||||
gwrt = rtalloc1(rt->rt_gateway, 1);
|
||||
rt_set_gwroute(rt, gwrt);
|
||||
rtfree(rt);
|
||||
rt = gwrt;
|
||||
if (rt == NULL)
|
||||
|
@ -2224,6 +2224,8 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
|
|||
/* the "G" test below also prevents rt == rt0 */
|
||||
if ((rt->rt_flags & RTF_GATEWAY) ||
|
||||
(rt->rt_ifp != ifp)) {
|
||||
if (rt0->rt_gwroute != NULL)
|
||||
rtfree(rt0->rt_gwroute);
|
||||
rt0->rt_gwroute = NULL;
|
||||
senderr(EHOSTUNREACH);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue