Good-bye, rtcache_check(). Call both rtcache_validate() and

rtcache_update(,1) instead of rtcache_check().
This commit is contained in:
dyoung 2008-01-12 02:58:58 +00:00
parent 5bf14fd932
commit 1386ee4adf
5 changed files with 34 additions and 57 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: route.h,v 1.62 2008/01/11 01:38:45 dyoung Exp $ */
/* $NetBSD: route.h,v 1.63 2008/01/12 02:58:58 dyoung Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -423,21 +423,6 @@ rtcache_validate(const struct route *ro)
}
static inline void
rtcache_check1(struct route *ro, int clone)
{
/* XXX The rt_ifp check should be asserted. */
if (rtcache_validate(ro) == NULL)
rtcache_update(ro, clone);
KASSERT(ro->_ro_rt == NULL || ro->_ro_rt->rt_ifp != NULL);
}
static inline void
rtcache_check(struct route *ro)
{
return rtcache_check1(ro, 1);
}
static inline void
RTFREE(struct rtentry *rt)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: ddp_usrreq.c,v 1.27 2008/01/10 08:04:18 dyoung Exp $ */
/* $NetBSD: ddp_usrreq.c,v 1.28 2008/01/12 02:58:58 dyoung Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.27 2008/01/10 08:04:18 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.28 2008/01/12 02:58:58 dyoung Exp $");
#include "opt_mbuftrace.h"
@ -366,8 +366,8 @@ at_pcbconnect(ddp, addr, l)
* If we've changed our address, we may have an old "good looking"
* route here. Attempt to detect it.
*/
rtcache_check(ro);
if ((rt = rtcache_getrt(ro)) != NULL) {
if ((rt = rtcache_validate(ro)) != NULL ||
(rt = rtcache_update(ro, 1)) != NULL) {
if (hintnet) {
net = hintnet;
} else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_output.c,v 1.189 2007/12/29 15:13:55 degroote Exp $ */
/* $NetBSD: ip_output.c,v 1.190 2008/01/12 02:58:58 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.189 2007/12/29 15:13:55 degroote Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.190 2008/01/12 02:58:58 dyoung Exp $");
#include "opt_pfil_hooks.h"
#include "opt_inet.h"
@ -307,9 +307,9 @@ ip_output(struct mbuf *m0, ...)
else if (dst->sin_family != AF_INET ||
!in_hosteq(dst->sin_addr, ip->ip_dst))
rtcache_free(ro);
else
rtcache_check(ro);
if ((rt = rtcache_getrt(ro)) == NULL) {
if ((rt = rtcache_validate(ro)) == NULL &&
(rt = rtcache_update(ro, 1)) == NULL) {
dst = &u.dst4;
rtcache_setdst(ro, &u.dst);
}
@ -334,8 +334,8 @@ ip_output(struct mbuf *m0, ...)
IFP_TO_IA(ifp, ia);
} else {
if (rt == NULL)
rtcache_init(ro);
if ((rt = rtcache_getrt(ro)) == NULL) {
rt = rtcache_init(ro);
if (rt == NULL) {
ipstat.ips_noroute++;
error = EHOSTUNREACH;
goto bad;
@ -1723,8 +1723,7 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m)
sockaddr_in_init(&u.dst4, &mreq->imr_multiaddr, 0);
rtcache_setdst(&ro, &u.dst);
rtcache_init(&ro);
ifp = (rt = rtcache_getrt(&ro)) != NULL ? rt->rt_ifp
ifp = (rt = rtcache_init(&ro)) != NULL ? rt->rt_ifp
: NULL;
rtcache_free(&ro);
} else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_pcb.c,v 1.92 2008/01/10 08:06:11 dyoung Exp $ */
/* $NetBSD: in6_pcb.c,v 1.93 2008/01/12 02:58:58 dyoung Exp $ */
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.92 2008/01/10 08:06:11 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.93 2008/01/12 02:58:58 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -928,18 +928,15 @@ in6_pcbrtentry(struct in6pcb *in6p)
KASSERT(IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr));
if (cdst.sa4->sin_addr.s_addr != in6p->in6p_faddr.s6_addr32[3])
rtcache_free(ro);
else
rtcache_check(ro);
}
#endif
else {
if (!IN6_ARE_ADDR_EQUAL(&cdst.sa6->sin6_addr,
&in6p->in6p_faddr))
rtcache_free(ro);
else
rtcache_check(ro);
}
rt = rtcache_getrt(ro);
if ((rt = rtcache_validate(ro)) == NULL)
rt = rtcache_update(ro, 1);
#ifdef INET
if (rt == NULL && IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr)) {
union {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_forward.c,v 1.60 2008/01/10 08:06:12 dyoung Exp $ */
/* $NetBSD: ip6_forward.c,v 1.61 2008/01/12 02:58:58 dyoung Exp $ */
/* $KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.60 2008/01/10 08:06:12 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.61 2008/01/12 02:58:58 dyoung Exp $");
#include "opt_ipsec.h"
#include "opt_pfil_hooks.h"
@ -360,25 +360,7 @@ ip6_forward(struct mbuf *m, int srcrt)
}
#endif /* FAST_IPSEC */
if (!srcrt) {
/*
* rtcache_getdst(ip6_forward_rt)->sin6_addr is equal to
* ip6->ip6_dst
*/
rtcache_check(&ip6_forward_rt);
if (rtcache_getrt(&ip6_forward_rt) == NULL) {
if (rtcache_init(&ip6_forward_rt) == NULL) {
ip6stat.ip6s_noroute++;
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_noroute) */
if (mcopy) {
icmp6_error(mcopy, ICMP6_DST_UNREACH,
ICMP6_DST_UNREACH_NOROUTE, 0);
}
m_freem(m);
return;
}
}
} else {
if (srcrt) {
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
@ -395,6 +377,20 @@ ip6_forward(struct mbuf *m, int srcrt)
m_freem(m);
return;
}
} else if (rtcache_validate(&ip6_forward_rt) == NULL &&
rtcache_update(&ip6_forward_rt, 1) == NULL) {
/*
* rtcache_getdst(ip6_forward_rt)->sin6_addr was equal to
* ip6->ip6_dst
*/
ip6stat.ip6s_noroute++;
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_noroute) */
if (mcopy) {
icmp6_error(mcopy, ICMP6_DST_UNREACH,
ICMP6_DST_UNREACH_NOROUTE, 0);
}
m_freem(m);
return;
}
dst = satocsin6(rtcache_getdst(&ip6_forward_rt));
rt = rtcache_getrt(&ip6_forward_rt);