fixed that the kernel crashed when key_spdacquire() was called
because key_spdacquire() had been implemented imcopletely. sync w/kame
This commit is contained in:
parent
731484776c
commit
8453a28003
@ -1,5 +1,5 @@
|
||||
/* $NetBSD: key.c,v 1.85 2003/07/22 11:12:15 itojun Exp $ */
|
||||
/* $KAME: key.c,v 1.249 2002/06/14 14:46:22 itojun Exp $ */
|
||||
/* $NetBSD: key.c,v 1.86 2003/07/25 09:04:48 itojun Exp $ */
|
||||
/* $KAME: key.c,v 1.299 2003/07/25 08:48:05 sakane Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.85 2003/07/22 11:12:15 itojun Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.86 2003/07/25 09:04:48 itojun Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -1913,8 +1913,10 @@ key_spdacquire(sp)
|
||||
struct secpolicy *sp;
|
||||
{
|
||||
struct mbuf *result = NULL, *m;
|
||||
#ifndef IPSEC_NONBLOCK_ACQUIRE
|
||||
struct secspacq *newspacq;
|
||||
int error;
|
||||
#endif
|
||||
int error = -1;
|
||||
|
||||
/* sanity check */
|
||||
if (sp == NULL)
|
||||
@ -1924,6 +1926,7 @@ key_spdacquire(sp)
|
||||
if (sp->policy != IPSEC_POLICY_IPSEC)
|
||||
panic("key_spdacquire: policy mismathed. IPsec is expected.");
|
||||
|
||||
#ifndef IPSEC_NONBLOCK_ACQUIRE
|
||||
/* get an entry to check whether sent message or not. */
|
||||
if ((newspacq = key_getspacq(sp->spidx)) != NULL) {
|
||||
if (key_blockacq_count < newspacq->count) {
|
||||
@ -1942,6 +1945,7 @@ key_spdacquire(sp)
|
||||
/* add to acqtree */
|
||||
LIST_INSERT_HEAD(&spacqtree, newspacq, chain);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* create new sadb_msg to reply. */
|
||||
m = key_setsadbmsg(SADB_X_SPDACQUIRE, 0, 0, 0, 0, 0);
|
||||
@ -1951,6 +1955,16 @@ key_spdacquire(sp)
|
||||
}
|
||||
result = m;
|
||||
|
||||
/* set sadb_x_policy */
|
||||
if (sp) {
|
||||
m = key_setsadbxpolicy(sp->policy, sp->dir, sp->id);
|
||||
if (!m) {
|
||||
error = ENOBUFS;
|
||||
goto fail;
|
||||
}
|
||||
m_cat(result, m);
|
||||
}
|
||||
|
||||
result->m_pkthdr.len = 0;
|
||||
for (m = result; m; m = m->m_next)
|
||||
result->m_pkthdr.len += m->m_len;
|
||||
@ -1958,7 +1972,7 @@ key_spdacquire(sp)
|
||||
mtod(result, struct sadb_msg *)->sadb_msg_len =
|
||||
PFKEY_UNIT64(result->m_pkthdr.len);
|
||||
|
||||
return key_sendup_mbuf(NULL, m, KEY_SENDUP_REGISTERED);
|
||||
return key_sendup_mbuf(NULL, result, KEY_SENDUP_REGISTERED);
|
||||
|
||||
fail:
|
||||
if (result)
|
||||
|
Loading…
Reference in New Issue
Block a user