From 1222539b6394ce40c12127425e341be7447471ee Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Tue, 7 Feb 2017 17:25:47 +0000 Subject: 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@ --- sys/arch/i386/pci/glxsb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sys/arch/i386/pci') 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 @@ -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) { -- cgit v1.2.3