Skip to content

Commit

Permalink
move sanity check against pcbsp upwards
Browse files Browse the repository at this point in the history
  • Loading branch information
itojun committed Jun 22, 2002
1 parent 09b8183 commit 05d2fd3
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions kame/sys/netinet6/ipsec.c
@@ -1,4 +1,4 @@
/* $KAME: ipsec.c,v 1.157 2002/06/22 12:03:06 itojun Exp $ */
/* $KAME: ipsec.c,v 1.158 2002/06/22 12:25:14 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -456,6 +456,12 @@ ipsec4_getpolicybysock(m, dir, so, error)
panic("ipsec4_getpolicybysock: unsupported address family\n");
}

#ifdef DIAGNOSTIC
/* sanity check */
if (pcbsp == NULL)
panic("ipsec4_getpolicybysock: pcbsp is NULL.\n");
#endif

/* if we have a cached entry, and if it is still valid, use it. */
ipsecstat.spdcachelookup++;
currsp = ipsec_checkpcbcache(m, pcbsp, dir);
Expand All @@ -465,10 +471,6 @@ ipsec4_getpolicybysock(m, dir, so, error)
}
ipsecstat.spdcachemiss++;

/* sanity check */
if (pcbsp == NULL)
panic("ipsec4_getpolicybysock: pcbsp is NULL.\n");

switch (dir) {
case IPSEC_DIR_INBOUND:
currsp = pcbsp->sp_in;
Expand Down Expand Up @@ -658,6 +660,12 @@ ipsec6_getpolicybysock(m, dir, so, error)

pcbsp = sotoin6pcb(so)->in6p_sp;

#ifdef DIAGNOSTIC
/* sanity check */
if (pcbsp == NULL)
panic("ipsec6_getpolicybysock: pcbsp is NULL.\n");
#endif

/* if we have a cached entry, and if it is still valid, use it. */
ipsec6stat.spdcachelookup++;
currsp = ipsec_checkpcbcache(m, pcbsp, dir);
Expand All @@ -667,10 +675,6 @@ ipsec6_getpolicybysock(m, dir, so, error)
}
ipsec6stat.spdcachemiss++;

/* sanity check */
if (pcbsp == NULL)
panic("ipsec6_getpolicybysock: pcbsp is NULL.\n");

switch (dir) {
case IPSEC_DIR_INBOUND:
currsp = pcbsp->sp_in;
Expand Down

0 comments on commit 05d2fd3

Please sign in to comment.