X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/1c79356b52d46aa6b508fb032f5ae709b1f2897b..ff6e181ae92fc6f1e89841290f461d1f2f9badd9:/bsd/netkey/keydb.c diff --git a/bsd/netkey/keydb.c b/bsd/netkey/keydb.c index 9c2bebccf..8da09b877 100644 --- a/bsd/netkey/keydb.c +++ b/bsd/netkey/keydb.c @@ -29,13 +29,6 @@ * SUCH DAMAGE. */ -#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__) -#include "opt_inet.h" -#ifdef __NetBSD__ -#include "opt_ipsec.h" -#endif -#endif - #include #include #include @@ -56,11 +49,9 @@ #include -#if defined(__FreeBSD__) && __FreeBSD__ >= 3 MALLOC_DEFINE(M_SECA, "key mgmt", "security associations, key management"); -#endif -static void keydb_delsecasvar __P((struct secasvar *)); +static void keydb_delsecasvar(struct secasvar *); /* * secpolicy management @@ -70,7 +61,7 @@ keydb_newsecpolicy() { struct secpolicy *p; - p = (struct secpolicy *)_MALLOC(sizeof(*p), M_SECA, M_NOWAIT); + p = (struct secpolicy *)_MALLOC(sizeof(*p), M_SECA, M_WAITOK); if (!p) return p; bzero(p, sizeof(*p)); @@ -94,7 +85,7 @@ keydb_newsecashead() struct secashead *p; int i; - p = (struct secashead *)_MALLOC(sizeof(*p), M_SECA, M_NOWAIT); + p = (struct secashead *)_MALLOC(sizeof(*p), M_SECA, M_WAITOK); if (!p) return p; bzero(p, sizeof(*p)); @@ -119,7 +110,7 @@ keydb_newsecasvar() { struct secasvar *p; - p = (struct secasvar *)_MALLOC(sizeof(*p), M_SECA, M_NOWAIT); + p = (struct secasvar *)_MALLOC(sizeof(*p), M_SECA, M_WAITOK); if (!p) return p; bzero(p, sizeof(*p)); @@ -133,11 +124,7 @@ keydb_refsecasvar(p) { int s; -#ifdef __NetBSD__ - s = splsoftnet(); -#else s = splnet(); -#endif p->refcnt++; splx(s); } @@ -148,13 +135,10 @@ keydb_freesecasvar(p) { int s; -#ifdef __NetBSD__ - s = splsoftnet(); -#else s = splnet(); -#endif p->refcnt--; - if (p->refcnt == 0) + /* negative refcnt will cause panic intentionally */ + if (p->refcnt <= 0) keydb_delsecasvar(p); splx(s); } @@ -179,13 +163,13 @@ keydb_newsecreplay(wsize) { struct secreplay *p; - p = (struct secreplay *)_MALLOC(sizeof(*p), M_SECA, M_NOWAIT); + p = (struct secreplay *)_MALLOC(sizeof(*p), M_SECA, M_WAITOK); if (!p) return p; bzero(p, sizeof(*p)); if (wsize != 0) { - p->bitmap = (caddr_t)_MALLOC(wsize, M_SECA, M_NOWAIT); + p->bitmap = (caddr_t)_MALLOC(wsize, M_SECA, M_WAITOK); if (!p->bitmap) { _FREE(p, M_SECA); return NULL; @@ -214,7 +198,7 @@ keydb_newsecreg() { struct secreg *p; - p = (struct secreg *)_MALLOC(sizeof(*p), M_SECA, M_NOWAIT); + p = (struct secreg *)_MALLOC(sizeof(*p), M_SECA, M_WAITOK); if (p) bzero(p, sizeof(*p)); return p;