diff options
author | sam <sam@FreeBSD.org> | 2003-09-01 05:35:55 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2003-09-01 05:35:55 +0000 |
commit | 7a8c89dde15c19a8c1e8eb2976dc9936d9b7329c (patch) | |
tree | c44de6fcda02feb74d7dccf3bde0ea476169307f /sys/netipsec/xform_ipcomp.c | |
parent | 591fec46c46db5741955ea71f2571001a039f4d0 (diff) | |
download | FreeBSD-src-7a8c89dde15c19a8c1e8eb2976dc9936d9b7329c.zip FreeBSD-src-7a8c89dde15c19a8c1e8eb2976dc9936d9b7329c.tar.gz |
Locking and misc cleanups; most of which I've been running for >4 months:
o add locking
o strip irrelevant spl's
o split malloc types to better account for memory use
o remove unused IPSEC_NONBLOCK_ACQUIRE code
o remove dead code
Sponsored by: FreeBSD Foundation
Diffstat (limited to 'sys/netipsec/xform_ipcomp.c')
-rw-r--r-- | sys/netipsec/xform_ipcomp.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/sys/netipsec/xform_ipcomp.c b/sys/netipsec/xform_ipcomp.c index 59e6210..0fcbe1c 100644 --- a/sys/netipsec/xform_ipcomp.c +++ b/sys/netipsec/xform_ipcomp.c @@ -35,6 +35,8 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/mbuf.h> +#include <sys/lock.h> +#include <sys/mutex.h> #include <sys/socket.h> #include <sys/kernel.h> #include <sys/protosw.h> @@ -215,7 +217,7 @@ ipcomp_input_cb(struct cryptop *crp) struct mbuf *m; struct secasvar *sav; struct secasindex *saidx; - int s, hlen = IPCOMP_HLENGTH, error, clen; + int hlen = IPCOMP_HLENGTH, error, clen; u_int8_t nproto; caddr_t addr; @@ -228,8 +230,6 @@ ipcomp_input_cb(struct cryptop *crp) mtag = (struct mtag *) tc->tc_ptr; m = (struct mbuf *) crp->crp_buf; - s = splnet(); - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); if (sav == NULL) { ipcompstat.ipcomps_notdb++; @@ -252,7 +252,6 @@ ipcomp_input_cb(struct cryptop *crp) if (crp->crp_etype == EAGAIN) { KEY_FREESAV(&sav); - splx(s); return crypto_dispatch(crp); } @@ -306,12 +305,10 @@ ipcomp_input_cb(struct cryptop *crp) IPSEC_COMMON_INPUT_CB(m, sav, skip, protoff, NULL); KEY_FREESAV(&sav); - splx(s); return error; bad: if (sav) KEY_FREESAV(&sav); - splx(s); if (m) m_freem(m); if (tc != NULL) @@ -500,7 +497,7 @@ ipcomp_output_cb(struct cryptop *crp) struct ipsecrequest *isr; struct secasvar *sav; struct mbuf *m; - int s, error, skip, rlen; + int error, skip, rlen; tc = (struct tdb_crypto *) crp->crp_opaque; KASSERT(tc != NULL, ("ipcomp_output_cb: null opaque data area!")); @@ -508,9 +505,8 @@ ipcomp_output_cb(struct cryptop *crp) skip = tc->tc_skip; rlen = crp->crp_ilen - skip; - s = splnet(); - isr = tc->tc_isr; + mtx_lock(&isr->lock); sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); if (sav == NULL) { ipcompstat.ipcomps_notdb++; @@ -528,7 +524,7 @@ ipcomp_output_cb(struct cryptop *crp) if (crp->crp_etype == EAGAIN) { KEY_FREESAV(&sav); - splx(s); + mtx_unlock(&isr->lock); return crypto_dispatch(crp); } ipcompstat.ipcomps_noxform++; @@ -581,12 +577,13 @@ ipcomp_output_cb(struct cryptop *crp) /* NB: m is reclaimed by ipsec_process_done. */ error = ipsec_process_done(m, isr); KEY_FREESAV(&sav); - splx(s); + mtx_unlock(&isr->lock); + return error; bad: if (sav) KEY_FREESAV(&sav); - splx(s); + mtx_unlock(&isr->lock); if (m) m_freem(m); free(tc, M_XDATA); |