Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys correct in*_pcbrtentry. check cached value correctly.
details: https://anonhg.NetBSD.org/src/rev/cfd13c738ded
branches: trunk
changeset: 531879:cfd13c738ded
user: itojun <itojun%NetBSD.org@localhost>
date: Tue May 28 11:10:52 2002 +0000
description:
correct in*_pcbrtentry. check cached value correctly.
diffstat:
sys/netinet/in_pcb.c | 31 ++++++++++++++-----------------
sys/netinet6/in6_pcb.c | 32 ++++++++++++++------------------
2 files changed, 28 insertions(+), 35 deletions(-)
diffs (105 lines):
diff -r e747abcf577c -r cfd13c738ded sys/netinet/in_pcb.c
--- a/sys/netinet/in_pcb.c Tue May 28 10:17:27 2002 +0000
+++ b/sys/netinet/in_pcb.c Tue May 28 11:10:52 2002 +0000
@@ -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 @@
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);
}
diff -r e747abcf577c -r cfd13c738ded sys/netinet6/in6_pcb.c
--- a/sys/netinet6/in6_pcb.c Tue May 28 10:17:27 2002 +0000
+++ b/sys/netinet6/in6_pcb.c Tue May 28 11:10:52 2002 +0000
@@ -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 @@
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);
}
Home |
Main Index |
Thread Index |
Old Index