correct in*_pcbrtentry. check cached value correctly.

This commit is contained in:
itojun 2002-05-28 11:10:52 +00:00
parent b9f810de55
commit 4121fa09fc
2 changed files with 28 additions and 35 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_pcb.c,v 1.76 2002/05/28 10:07:51 itojun Exp $ */
/* $NetBSD: in_pcb.c,v 1.77 2002/05/28 11:10:52 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.76 2002/05/28 10:07:51 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.77 2002/05/28 11:10:52 itojun Exp $");
#include "opt_ipsec.h"
@ -833,21 +833,18 @@ in_pcbrtentry(inp)
ro = &inp->inp_route;
if (ro->ro_rt == NULL || (ro->ro_rt->rt_flags & RTF_UP) == 0) {
/*
* No route yet, so try to acquire one.
*/
if (!in_nullhost(inp->inp_faddr)) {
if (ro->ro_rt) {
RTFREE(ro->ro_rt);
ro->ro_rt = (struct rtentry *)NULL;
}
bzero(&ro->ro_dst, sizeof(struct sockaddr_in));
ro->ro_dst.sa_family = AF_INET;
ro->ro_dst.sa_len = sizeof(ro->ro_dst);
satosin(&ro->ro_dst)->sin_addr = inp->inp_faddr;
rtalloc(ro);
}
if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 ||
!in_hosteq(satosin(&ro->ro_dst)->sin_addr, inp->inp_faddr))) {
RTFREE(ro->ro_rt);
ro->ro_rt = (struct rtentry *)NULL;
}
if (ro->ro_rt == (struct rtentry *)NULL &&
!in_nullhost(inp->inp_faddr)) {
bzero(&ro->ro_dst, sizeof(struct sockaddr_in));
ro->ro_dst.sa_family = AF_INET;
ro->ro_dst.sa_len = sizeof(ro->ro_dst);
satosin(&ro->ro_dst)->sin_addr = inp->inp_faddr;
rtalloc(ro);
}
return (ro->ro_rt);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_pcb.c,v 1.47 2002/05/28 10:07:52 itojun Exp $ */
/* $NetBSD: in6_pcb.c,v 1.48 2002/05/28 11:10:53 itojun Exp $ */
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
/*
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.47 2002/05/28 10:07:52 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.48 2002/05/28 11:10:53 itojun Exp $");
#include "opt_ipsec.h"
@ -834,22 +834,18 @@ in6_pcbrtentry(in6p)
ro = &in6p->in6p_route;
dst6 = (struct sockaddr_in6 *)&ro->ro_dst;
if (ro->ro_rt == NULL || (ro->ro_rt->rt_flags & RTF_UP) == 0 ||
dst6->sin6_family != AF_INET6) {
/*
* No route yet, so try to acquire one.
*/
if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
if (ro->ro_rt) {
RTFREE(ro->ro_rt);
ro->ro_rt = (struct rtentry *)NULL;
}
bzero(dst6, sizeof(*dst6));
dst6->sin6_family = AF_INET6;
dst6->sin6_len = sizeof(struct sockaddr_in6);
dst6->sin6_addr = in6p->in6p_faddr;
rtalloc((struct route *)ro);
}
if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 ||
!IN6_ARE_ADDR_EQUAL(&dst6->sin6_addr, &in6p->in6p_faddr))) {
RTFREE(ro->ro_rt);
ro->ro_rt = (struct rtentry *)NULL;
}
if (ro->ro_rt == (struct rtentry *)NULL &&
!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
bzero(dst6, sizeof(*dst6));
dst6->sin6_family = AF_INET6;
dst6->sin6_len = sizeof(struct sockaddr_in6);
dst6->sin6_addr = in6p->in6p_faddr;
rtalloc((struct route *)ro);
}
return (ro->ro_rt);
}