Ignore freed rtcache entries.

This commit is contained in:
mlelstv 2008-07-01 20:18:45 +00:00
parent 802c7519a2
commit be6f2a4b87
2 changed files with 12 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: key.c,v 1.55 2008/05/04 07:22:15 thorpej Exp $ */ /* $NetBSD: key.c,v 1.56 2008/07/01 20:18:45 mlelstv Exp $ */
/* $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $ */ /* $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $ */
/* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */ /* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.55 2008/05/04 07:22:15 thorpej Exp $"); __KERNEL_RCSID(0, "$NetBSD: key.c,v 1.56 2008/07/01 20:18:45 mlelstv Exp $");
/* /*
* This code is referd to RFC 2367 * This code is referd to RFC 2367
@ -7826,11 +7826,13 @@ key_sa_routechange(struct sockaddr *dst)
{ {
struct secashead *sah; struct secashead *sah;
struct route *ro; struct route *ro;
const struct sockaddr *sa;
LIST_FOREACH(sah, &sahtree, chain) { LIST_FOREACH(sah, &sahtree, chain) {
ro = &sah->sa_route; ro = &sah->sa_route;
if (dst->sa_len == rtcache_getdst(ro)->sa_len && sa = rtcache_getdst(ro);
memcmp(dst, rtcache_getdst(ro), dst->sa_len) == 0) if (sa != NULL && dst->sa_len == sa->sa_len &&
memcmp(dst, sa, dst->sa_len) == 0)
rtcache_free(ro); rtcache_free(ro);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: key.c,v 1.160 2008/05/04 07:22:15 thorpej Exp $ */ /* $NetBSD: key.c,v 1.161 2008/07/01 20:18:46 mlelstv Exp $ */
/* $KAME: key.c,v 1.310 2003/09/08 02:23:44 itojun Exp $ */ /* $KAME: key.c,v 1.310 2003/09/08 02:23:44 itojun Exp $ */
/* /*
@ -35,7 +35,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.160 2008/05/04 07:22:15 thorpej Exp $"); __KERNEL_RCSID(0, "$NetBSD: key.c,v 1.161 2008/07/01 20:18:46 mlelstv Exp $");
#include "opt_inet.h" #include "opt_inet.h"
#include "opt_ipsec.h" #include "opt_ipsec.h"
@ -8245,11 +8245,13 @@ key_sa_routechange(dst)
{ {
struct secashead *sah; struct secashead *sah;
struct route *ro; struct route *ro;
const struct sockaddr *sa;
LIST_FOREACH(sah, &sahtree, chain) { LIST_FOREACH(sah, &sahtree, chain) {
ro = &sah->sa_route; ro = &sah->sa_route;
if (dst->sa_len == rtcache_getdst(ro)->sa_len && sa = rtcache_getdst(ro);
memcmp(dst, rtcache_getdst(ro), dst->sa_len) == 0) if (sa != NULL && dst->sa_len == sa->sa_len &&
memcmp(dst, sa, dst->sa_len) == 0)
rtcache_free(ro); rtcache_free(ro);
} }