diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2017-02-07 17:25:47 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2017-02-07 17:25:47 +0000 |
commit | 1222539b6394ce40c12127425e341be7447471ee (patch) | |
tree | 721477aee6fbd097fd777cf68fa80f12b72bca78 | |
parent | b5f0b38252e2338e048adce12dde40f7a6cae620 (diff) |
Reduce the per-packet allocation costs for crypto operations (cryptop)
by pre-allocating two cryptodesc objects and storing them in an array
instead of a linked list. If more than two cryptodesc objects are
required use mallocarray to fetch them. Adapt the drivers to the new
API.
This change results in one pool-get per ESP packet instead of three.
It also simplifies softraid crypto where more cryptodesc objects are
allocated than used.
From, with and ok markus@, ok bluhm@
"looks sane" mpi@
-rw-r--r-- | sys/arch/amd64/amd64/aesni.c | 8 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/via.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/i386/via.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/pci/glxsb.c | 10 | ||||
-rw-r--r-- | sys/crypto/crypto.c | 42 | ||||
-rw-r--r-- | sys/crypto/cryptodev.h | 10 | ||||
-rw-r--r-- | sys/crypto/cryptosoft.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/hifn7751.c | 17 | ||||
-rw-r--r-- | sys/dev/pci/safe.c | 15 | ||||
-rw-r--r-- | sys/dev/pci/ubsec.c | 15 | ||||
-rw-r--r-- | sys/dev/softraid_crypto.c | 22 | ||||
-rw-r--r-- | sys/netinet/ip_ah.c | 6 | ||||
-rw-r--r-- | sys/netinet/ip_esp.c | 14 | ||||
-rw-r--r-- | sys/netinet/ip_ipcomp.c | 6 |
14 files changed, 102 insertions, 90 deletions
diff --git a/sys/arch/amd64/amd64/aesni.c b/sys/arch/amd64/amd64/aesni.c index b712cdceaef..dd8dbfd3ed9 100644 --- a/sys/arch/amd64/amd64/aesni.c +++ b/sys/arch/amd64/amd64/aesni.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aesni.c,v 1.39 2016/09/15 02:00:16 dlg Exp $ */ +/* $OpenBSD: aesni.c,v 1.40 2017/02/07 17:25:45 patrick Exp $ */ /*- * Copyright (c) 2003 Jason Wright * Copyright (c) 2003, 2004 Theo de Raadt @@ -616,9 +616,12 @@ aesni_process(struct cryptop *crp) struct aesni_session *ses; struct cryptodesc *crd, *crda, *crde; int err = 0; + int i; if (crp == NULL || crp->crp_callback == NULL) return (EINVAL); + if (crp->crp_ndesc < 1) + return (EINVAL); mtx_enter(&aesni_sc->sc_mtx); LIST_FOREACH(ses, &aesni_sc->sc_sessions, ses_entries) { @@ -633,7 +636,8 @@ aesni_process(struct cryptop *crp) } crda = crde = NULL; - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { + for (i = 0; i < crp->crp_ndesc; i++) { + crd = &crp->crp_desc[i]; switch (crd->crd_alg) { case CRYPTO_AES_CBC: case CRYPTO_AES_CTR: diff --git a/sys/arch/amd64/amd64/via.c b/sys/arch/amd64/amd64/via.c index f631f5aa303..53cfe1813f5 100644 --- a/sys/arch/amd64/amd64/via.c +++ b/sys/arch/amd64/amd64/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.21 2015/08/28 00:03:53 deraadt Exp $ */ +/* $OpenBSD: via.c,v 1.22 2017/02/07 17:25:45 patrick Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -441,9 +441,12 @@ viac3_crypto_process(struct cryptop *crp) struct viac3_session *ses; struct cryptodesc *crd; int sesn, err = 0; + int i; if (crp == NULL || crp->crp_callback == NULL) return (EINVAL); + if (crp->crp_ndesc < 1) + return (EINVAL); sesn = VIAC3_SESSION(crp->crp_sid); if (sesn >= sc->sc_nsessions) { @@ -456,7 +459,8 @@ viac3_crypto_process(struct cryptop *crp) goto out; } - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { + for (i = 0; i < crp->crp_ndesc; i++) { + crd = &crp->crp_desc[i]; switch (crd->crd_alg) { case CRYPTO_AES_CBC: if ((err = viac3_crypto_encdec(crp, crd, ses, sc, diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c index 3e007c4ba80..2765dc596ec 100644 --- a/sys/arch/i386/i386/via.c +++ b/sys/arch/i386/i386/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.35 2015/09/08 07:12:56 deraadt Exp $ */ +/* $OpenBSD: via.c,v 1.36 2017/02/07 17:25:45 patrick Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -444,9 +444,12 @@ viac3_crypto_process(struct cryptop *crp) struct viac3_session *ses; struct cryptodesc *crd; int sesn, err = 0; + int i; if (crp == NULL || crp->crp_callback == NULL) return (EINVAL); + if (crp->crp_ndesc < 1) + return (EINVAL); sesn = VIAC3_SESSION(crp->crp_sid); if (sesn >= sc->sc_nsessions) { @@ -459,7 +462,8 @@ viac3_crypto_process(struct cryptop *crp) goto out; } - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { + for (i = 0; i < crp->crp_ndesc; i++) { + crd = &crp->crp_desc[i]; switch (crd->crd_alg) { case CRYPTO_AES_CBC: if ((err = viac3_crypto_encdec(crp, crd, ses, sc, diff --git a/sys/arch/i386/pci/glxsb.c b/sys/arch/i386/pci/glxsb.c index c93a86452b4..21786ab4ece 100644 --- a/sys/arch/i386/pci/glxsb.c +++ b/sys/arch/i386/pci/glxsb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glxsb.c,v 1.30 2015/09/08 08:33:26 deraadt Exp $ */ +/* $OpenBSD: glxsb.c,v 1.31 2017/02/07 17:25:45 patrick Exp $ */ /* * Copyright (c) 2006 Tom Cosgrove <tom@openbsd.org> @@ -778,7 +778,7 @@ glxsb_crypto_process(struct cryptop *crp) struct glxsb_session *ses; struct cryptodesc *crd; int sesn,err = 0; - int s; + int s, i; s = splnet(); @@ -786,8 +786,7 @@ glxsb_crypto_process(struct cryptop *crp) err = EINVAL; goto out; } - crd = crp->crp_desc; - if (crd == NULL) { + if (crp->crp_ndesc < 1) { err = EINVAL; goto out; } @@ -803,7 +802,8 @@ glxsb_crypto_process(struct cryptop *crp) goto out; } - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { + for (i = 0; i < crp->crp_ndesc; i++) { + crd = &crp->crp_desc[i]; switch (crd->crd_alg) { case CRYPTO_AES_CBC: if (ses->ses_swd_enc) { diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c index 650eda28826..2ee1cb6d887 100644 --- a/sys/crypto/crypto.c +++ b/sys/crypto/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.78 2016/09/19 18:09:40 tedu Exp $ */ +/* $OpenBSD: crypto.c,v 1.79 2017/02/07 17:25:46 patrick Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -400,18 +400,17 @@ crypto_dispatch(struct cryptop *crp) int crypto_invoke(struct cryptop *crp) { - struct cryptodesc *crd; u_int64_t nid; u_int32_t hid; int error; - int s; + int s, i; /* Sanity checks. */ if (crp == NULL || crp->crp_callback == NULL) return EINVAL; s = splvm(); - if (crp->crp_desc == NULL || crypto_drivers == NULL) { + if (crp->crp_ndesc < 1 || crypto_drivers == NULL) { crp->crp_etype = EINVAL; crypto_done(crp); splx(s); @@ -449,8 +448,9 @@ crypto_invoke(struct cryptop *crp) migrate: /* Migrate session. */ - for (crd = crp->crp_desc; crd->crd_next; crd = crd->crd_next) - crd->CRD_INI.cri_next = &(crd->crd_next->CRD_INI); + for (i = 0; i < crp->crp_ndesc - 1; i++) + crp->crp_desc[i].CRD_INI.cri_next = &crp->crp_desc[i+1].CRD_INI; + crp->crp_desc[crp->crp_ndesc].CRD_INI.cri_next = NULL; if (crypto_newsession(&nid, &(crp->crp_desc->CRD_INI), 0) == 0) crp->crp_sid = nid; @@ -467,16 +467,12 @@ crypto_invoke(struct cryptop *crp) void crypto_freereq(struct cryptop *crp) { - struct cryptodesc *crd; - if (crp == NULL) return; - while ((crd = crp->crp_desc) != NULL) { - crp->crp_desc = crd->crd_next; - pool_put(&cryptodesc_pool, crd); - } - + if (crp->crp_ndescalloc > 2) + free(crp->crp_desc, M_CRYPTO_DATA, + crp->crp_ndescalloc * sizeof(struct cryptodesc)); pool_put(&cryptop_pool, crp); } @@ -486,22 +482,22 @@ crypto_freereq(struct cryptop *crp) struct cryptop * crypto_getreq(int num) { - struct cryptodesc *crd; struct cryptop *crp; - + crp = pool_get(&cryptop_pool, PR_NOWAIT | PR_ZERO); if (crp == NULL) return NULL; - while (num--) { - crd = pool_get(&cryptodesc_pool, PR_NOWAIT | PR_ZERO); - if (crd == NULL) { - crypto_freereq(crp); + crp->crp_desc = crp->crp_sdesc; + crp->crp_ndescalloc = crp->crp_ndesc = num; + + if (num > 2) { + crp->crp_desc = mallocarray(num, sizeof(struct cryptodesc), + M_CRYPTO_DATA, M_NOWAIT | M_ZERO); + if (crp->crp_desc == NULL) { + pool_put(&cryptop_pool, crp); return NULL; } - - crd->crd_next = crp->crp_desc; - crp->crp_desc = crd; } return crp; @@ -515,8 +511,6 @@ crypto_init(void) pool_init(&cryptop_pool, sizeof(struct cryptop), 0, IPL_VM, 0, "cryptop", NULL); - pool_init(&cryptodesc_pool, sizeof(struct cryptodesc), 0, IPL_VM, 0, - "cryptodesc", NULL); } /* diff --git a/sys/crypto/cryptodev.h b/sys/crypto/cryptodev.h index bd915817ebd..c64f74ff663 100644 --- a/sys/crypto/cryptodev.h +++ b/sys/crypto/cryptodev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptodev.h,v 1.69 2017/02/07 15:10:48 bluhm Exp $ */ +/* $OpenBSD: cryptodev.h,v 1.70 2017/02/07 17:25:46 patrick Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) @@ -147,8 +147,6 @@ struct cryptodesc { #define crd_rnd CRD_INI.cri_rnd #define crd_alg CRD_INI.cri_alg #define crd_klen CRD_INI.cri_klen - - struct cryptodesc *crd_next; }; /* Structure describing complete operation */ @@ -179,7 +177,11 @@ struct cryptop { void *crp_buf; /* Data to be processed */ void *crp_opaque; /* Opaque pointer, passed along */ - struct cryptodesc *crp_desc; /* Linked list of processing descriptors */ + + struct cryptodesc *crp_desc; /* List of processing descriptors */ + struct cryptodesc crp_sdesc[2]; /* Static array for small ops */ + int crp_ndesc; /* Amount of descriptors to use */ + int crp_ndescalloc;/* Amount of descriptors allocated */ void (*crp_callback)(struct cryptop *); /* Callback function */ diff --git a/sys/crypto/cryptosoft.c b/sys/crypto/cryptosoft.c index 06792eb0a9a..315210c5407 100644 --- a/sys/crypto/cryptosoft.c +++ b/sys/crypto/cryptosoft.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptosoft.c,v 1.81 2016/09/02 09:12:49 tom Exp $ */ +/* $OpenBSD: cryptosoft.c,v 1.82 2017/02/07 17:25:46 patrick Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) @@ -495,7 +495,8 @@ swcr_authenc(struct cryptop *crp) ivlen = blksz = iskip = oskip = 0; - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { + for (i = 0; i < crp->crp_ndesc; i++) { + crd = &crp->crp_desc[i]; for (sw = swcr_sessions[crp->crp_sid & 0xffffffff]; sw && sw->sw_alg != crd->crd_alg; sw = sw->sw_next) @@ -1020,12 +1021,13 @@ swcr_process(struct cryptop *crp) struct swcr_data *sw; u_int32_t lid; int type; + int i; /* Sanity check */ if (crp == NULL) return EINVAL; - if (crp->crp_desc == NULL || crp->crp_buf == NULL) { + if (crp->crp_ndesc < 1 || crp->crp_buf == NULL) { crp->crp_etype = EINVAL; goto done; } @@ -1042,7 +1044,8 @@ swcr_process(struct cryptop *crp) type = CRYPTO_BUF_IOV; /* Go through crypto descriptors, processing as we go */ - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { + for (i = 0; i < crp->crp_ndesc; i++) { + crd = &crp->crp_desc[i]; /* * Find the crypto context. * diff --git a/sys/dev/pci/hifn7751.c b/sys/dev/pci/hifn7751.c index 3814bdcf545..6f55e6783e5 100644 --- a/sys/dev/pci/hifn7751.c +++ b/sys/dev/pci/hifn7751.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hifn7751.c,v 1.176 2017/01/19 10:20:29 jsg Exp $ */ +/* $OpenBSD: hifn7751.c,v 1.177 2017/02/07 17:25:46 patrick Exp $ */ /* * Invertex AEON / Hifn 7751 driver @@ -1927,7 +1927,7 @@ hifn_process(struct cryptop *crp) struct hifn_command *cmd = NULL; int card, session, err = 0, ivlen; struct hifn_softc *sc; - struct cryptodesc *crd1, *crd2, *maccrd, *enccrd; + struct cryptodesc *crd1, *crd2 = NULL, *maccrd, *enccrd; if (crp == NULL || crp->crp_callback == NULL) { hifnstats.hst_invalid++; @@ -1969,12 +1969,13 @@ hifn_process(struct cryptop *crp) goto errout; /* XXX we don't handle contiguous buffers! */ } - crd1 = crp->crp_desc; - if (crd1 == NULL) { + if (crp->crp_ndesc < 1) { err = EINVAL; goto errout; } - crd2 = crd1->crd_next; + crd1 = &crp->crp_desc[0]; + if (crp->crp_ndesc >= 2) + crd2 = &crp->crp_desc[1]; if (crd2 == NULL) { if (crd1->crd_alg == CRYPTO_MD5_HMAC || @@ -2291,9 +2292,11 @@ hifn_callback(struct hifn_softc *sc, struct hifn_command *cmd, macbuf += sizeof(struct hifn_comp_result); macbuf += sizeof(struct hifn_mac_result); - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { + for (i = 0; i < crp->crp_ndesc; i++) { int len; + crd = &crp->crp_desc[i]; + if (crd->crd_alg == CRYPTO_MD5_HMAC || crd->crd_alg == CRYPTO_SHA1_HMAC) len = 12; @@ -2326,7 +2329,7 @@ int hifn_compression(struct hifn_softc *sc, struct cryptop *crp, struct hifn_command *cmd) { - struct cryptodesc *crd = crp->crp_desc; + struct cryptodesc *crd = &crp->crp_desc[0]; int s, err = 0; cmd->compcrd = crd; diff --git a/sys/dev/pci/safe.c b/sys/dev/pci/safe.c index 44bf9f0edc9..0a4c0de75a5 100644 --- a/sys/dev/pci/safe.c +++ b/sys/dev/pci/safe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: safe.c,v 1.41 2015/12/10 21:00:51 naddy Exp $ */ +/* $OpenBSD: safe.c,v 1.42 2017/02/07 17:25:46 patrick Exp $ */ /*- * Copyright (c) 2003 Sam Leffler, Errno Consulting @@ -301,7 +301,7 @@ safe_process(struct cryptop *crp) { int err = 0, i, nicealign, uniform, s; struct safe_softc *sc; - struct cryptodesc *crd1, *crd2, *maccrd, *enccrd; + struct cryptodesc *crd1, *crd2 = NULL, *maccrd, *enccrd; int bypass, oplen, ivsize, card; int16_t coffset; struct safe_session *ses; @@ -360,13 +360,14 @@ safe_process(struct cryptop *crp) sa = &re->re_sa; ses = &sc->sc_sessions[re->re_sesn]; - crd1 = crp->crp_desc; - if (crd1 == NULL) { + if (crp->crp_ndesc < 1) { safestats.st_nodesc++; err = EINVAL; goto errout; } - crd2 = crd1->crd_next; + crd1 = &crp->crp_desc[0]; + if (crp->crp_ndesc >= 2) + crd2 = &crp->crp_desc[1]; cmd0 = SAFE_SA_CMD0_BASIC; /* basic group operation */ cmd1 = 0; @@ -1608,6 +1609,7 @@ safe_callback(struct safe_softc *sc, struct safe_ringentry *re) { struct cryptop *crp = (struct cryptop *)re->re_crp; struct cryptodesc *crd; + int i; safestats.st_opackets++; safestats.st_obytes += (re->re_dst_map == NULL) ? @@ -1644,7 +1646,8 @@ safe_callback(struct safe_softc *sc, struct safe_ringentry *re) if (re->re_flags & SAFE_QFLAGS_COPYOUTICV) { /* copy out ICV result */ - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { + for (i = 0; i < crp->crp_ndesc; i++) { + crd = &crp->crp_desc[i]; if (!(crd->crd_alg == CRYPTO_MD5_HMAC || crd->crd_alg == CRYPTO_SHA1_HMAC)) continue; diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c index cbefa8576ca..70517670e7b 100644 --- a/sys/dev/pci/ubsec.c +++ b/sys/dev/pci/ubsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ubsec.c,v 1.162 2016/05/30 23:38:21 dlg Exp $ */ +/* $OpenBSD: ubsec.c,v 1.163 2017/02/07 17:25:46 patrick Exp $ */ /* * Copyright (c) 2000 Jason L. Wright (jason@thought.net) @@ -776,7 +776,7 @@ ubsec_process(struct cryptop *crp) struct ubsec_q *q = NULL; int card, err = 0, i, j, s, nicealign; struct ubsec_softc *sc; - struct cryptodesc *crd1, *crd2, *maccrd, *enccrd; + struct cryptodesc *crd1, *crd2 = NULL, *maccrd, *enccrd; int encoffset = 0, macoffset = 0, cpskip, cpoffset; int sskip, dskip, stheend, dtheend; int16_t coffset; @@ -835,12 +835,13 @@ ubsec_process(struct cryptop *crp) dmap->d_dma->d_mcr.mcr_flags = 0; q->q_crp = crp; - crd1 = crp->crp_desc; - if (crd1 == NULL) { + if (crp->crp_ndesc < 1) { err = EINVAL; goto errout; } - crd2 = crd1->crd_next; + crd1 = &crp->crp_desc[0]; + if (crp->crp_ndesc >= 2) + crd2 = &crp->crp_desc[1]; if (crd2 == NULL) { if (crd1->crd_alg == CRYPTO_MD5_HMAC || @@ -1330,6 +1331,7 @@ ubsec_callback(struct ubsec_softc *sc, struct ubsec_q *q) u_int8_t *ctx = (u_int8_t *)(dmap->d_alloc.dma_vaddr + offsetof(struct ubsec_dmachunk, d_ctx)); struct ubsec_pktctx_hdr *ph = (struct ubsec_pktctx_hdr *)ctx; + int i; ubsecstats.hst_opackets++; ubsecstats.hst_obytes += dmap->d_alloc.dma_size; @@ -1355,7 +1357,8 @@ ubsec_callback(struct ubsec_softc *sc, struct ubsec_q *q) crp->crp_buf = (caddr_t)q->q_dst_m; } - for (crd = crp->crp_desc; crd; crd = crd->crd_next) { + for (i = 0; i < crp->crp_ndesc; i++) { + crd = &crp->crp_desc[i]; if (crd->crd_alg != CRYPTO_MD5_HMAC && crd->crd_alg != CRYPTO_SHA1_HMAC) continue; diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c index 2dc4c6b2328..c419686997e 100644 --- a/sys/dev/softraid_crypto.c +++ b/sys/dev/softraid_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_crypto.c,v 1.132 2017/02/07 15:10:48 bluhm Exp $ */ +/* $OpenBSD: softraid_crypto.c,v 1.133 2017/02/07 17:25:46 patrick Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org> @@ -64,7 +64,6 @@ struct sr_crypto_wu { struct uio cr_uio; struct iovec cr_iov; struct cryptop *cr_crp; - struct cryptodesc *cr_descs; void *cr_dmabuf; }; @@ -270,15 +269,11 @@ sr_crypto_prepare(struct sr_workunit *wu, int encrypt) /* * We preallocated enough crypto descs for up to MAXPHYS of I/O. - * Since there may be less than that we need to tweak the linked list + * Since there may be less than that we need to tweak the amount * of crypto desc structures to be just long enough for our needs. */ - crd = crwu->cr_descs; - for (i = 0; i < ((MAXPHYS >> DEV_BSHIFT) - n); i++) { - crd = crd->crd_next; - KASSERT(crd); - } - crwu->cr_crp->crp_desc = crd; + KASSERT(crwu->cr_crp->crp_ndescalloc >= n); + crwu->cr_crp->crp_ndesc = n; flags = (encrypt ? CRD_F_ENCRYPT : 0) | CRD_F_IV_PRESENT | CRD_F_IV_EXPLICIT; @@ -297,8 +292,8 @@ sr_crypto_prepare(struct sr_workunit *wu, int encrypt) crwu->cr_crp->crp_alloctype = M_DEVBUF; crwu->cr_crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_NOQUEUE; crwu->cr_crp->crp_buf = &crwu->cr_uio; - for (i = 0, crd = crwu->cr_crp->crp_desc; crd; - i++, blkno++, crd = crd->crd_next) { + for (i = 0; i < crwu->cr_crp->crp_ndesc; i++, blkno++) { + crd = &crwu->cr_crp->crp_desc[i]; crd->crd_skip = i << DEV_BSHIFT; crd->crd_len = DEV_BSIZE; crd->crd_inject = 0; @@ -946,7 +941,6 @@ sr_crypto_alloc_resources(struct sr_discipline *sd) crwu->cr_crp = crypto_getreq(MAXPHYS >> DEV_BSHIFT); if (crwu->cr_crp == NULL) return (ENOMEM); - crwu->cr_descs = crwu->cr_crp->crp_desc; } memset(&cri, 0, sizeof(cri)); @@ -1005,10 +999,8 @@ sr_crypto_free_resources(struct sr_discipline *sd) crwu = (struct sr_crypto_wu *)wu; if (crwu->cr_dmabuf) dma_free(crwu->cr_dmabuf, MAXPHYS); - if (crwu->cr_crp) { - crwu->cr_crp->crp_desc = crwu->cr_descs; + if (crwu->cr_crp) crypto_freereq(crwu->cr_crp); - } } sr_wu_free(sd); diff --git a/sys/netinet/ip_ah.c b/sys/netinet/ip_ah.c index 425f3ff7ef8..d67711fad7a 100644 --- a/sys/netinet/ip_ah.c +++ b/sys/netinet/ip_ah.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ah.c,v 1.126 2017/02/07 15:10:48 bluhm Exp $ */ +/* $OpenBSD: ip_ah.c,v 1.127 2017/02/07 17:25:46 patrick Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -629,7 +629,7 @@ ah_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) return ENOBUFS; } - crda = crp->crp_desc; + crda = &crp->crp_desc[0]; crda->crd_skip = 0; crda->crd_len = m->m_pkthdr.len; @@ -1090,7 +1090,7 @@ ah_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, return ENOBUFS; } - crda = crp->crp_desc; + crda = &crp->crp_desc[0]; crda->crd_skip = 0; crda->crd_inject = skip + rplen; diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c index 403b82520f8..0f8d3928eaf 100644 --- a/sys/netinet/ip_esp.c +++ b/sys/netinet/ip_esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_esp.c,v 1.144 2017/02/07 15:10:48 bluhm Exp $ */ +/* $OpenBSD: ip_esp.c,v 1.145 2017/02/07 17:25:46 patrick Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -461,8 +461,8 @@ esp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) } if (esph) { - crda = crp->crp_desc; - crde = crda->crd_next; + crda = &crp->crp_desc[0]; + crde = &crp->crp_desc[1]; /* Authentication descriptor */ crda->crd_skip = skip; @@ -488,7 +488,7 @@ esp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) /* Copy the authenticator */ m_copydata(m, m->m_pkthdr.len - alen, alen, (caddr_t)(tc + 1)); } else - crde = crp->crp_desc; + crde = &crp->crp_desc[0]; /* Crypto operation descriptor */ crp->crp_ilen = m->m_pkthdr.len; /* Total input length */ @@ -958,8 +958,8 @@ esp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, } if (espx) { - crde = crp->crp_desc; - crda = crde->crd_next; + crde = &crp->crp_desc[0]; + crda = &crp->crp_desc[1]; /* Encryption descriptor. */ crde->crd_skip = skip + hlen; @@ -977,7 +977,7 @@ esp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, else crde->crd_len = m->m_pkthdr.len - (skip + hlen + alen); } else - crda = crp->crp_desc; + crda = &crp->crp_desc[0]; /* IPsec-specific opaque crypto info. */ tc = malloc(sizeof(*tc), M_XDATA, M_NOWAIT | M_ZERO); diff --git a/sys/netinet/ip_ipcomp.c b/sys/netinet/ip_ipcomp.c index 3717fc212ad..d4dc26c48bc 100644 --- a/sys/netinet/ip_ipcomp.c +++ b/sys/netinet/ip_ipcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipcomp.c,v 1.51 2017/02/07 15:10:48 bluhm Exp $ */ +/* $OpenBSD: ip_ipcomp.c,v 1.52 2017/02/07 17:25:46 patrick Exp $ */ /* * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org) @@ -158,7 +158,7 @@ ipcomp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) ipcompstat.ipcomps_crypto++; return ENOBUFS; } - crdc = crp->crp_desc; + crdc = &crp->crp_desc[0]; crdc->crd_skip = skip + hlen; crdc->crd_len = m->m_pkthdr.len - (skip + hlen); @@ -474,7 +474,7 @@ ipcomp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, ipcompstat.ipcomps_crypto++; return ENOBUFS; } - crdc = crp->crp_desc; + crdc = &crp->crp_desc[0]; /* Compression descriptor */ crdc->crd_skip = skip; |