diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2010-09-08 14:15:57 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2010-09-08 14:15:57 +0000 |
commit | 2c0c301deb10662e3dbe20c8870ce9b9ca67853e (patch) | |
tree | 7e67763f699f0be1ffd304ff8f65368363b894fe | |
parent | 1d264ec471038b319a8ce96e1a14dbfa6353698d (diff) |
Reintroduce most crypto/crypto.c r1.55:
Move pool initialization to init_crypto and zap the crypto_pool_initialized
variable. This way we don't have to check if the pool are initialized every
time we do a crypto_getreq().
However, also perform the crypto initialisation earlier in init_main so
that the crypto pools are initialised before they are used.
ok mikeb@ thib@ deraadt@
-rw-r--r-- | sys/crypto/crypto.c | 20 | ||||
-rw-r--r-- | sys/kern/init_main.c | 10 |
2 files changed, 11 insertions, 19 deletions
diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c index e964768b6dc..f30bf32f6b9 100644 --- a/sys/crypto/crypto.c +++ b/sys/crypto/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.57 2010/08/08 04:10:49 jsing Exp $ */ +/* $OpenBSD: crypto.c,v 1.58 2010/09/08 14:15:56 jsing Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -28,14 +28,13 @@ #include <crypto/cryptodev.h> -void init_crypto(void); +void crypto_init(void); struct cryptocap *crypto_drivers = NULL; int crypto_drivers_num = 0; struct pool cryptop_pool; struct pool cryptodesc_pool; -int crypto_pool_initialized = 0; struct workq *crypto_workq; @@ -593,14 +592,6 @@ crypto_getreq(int num) s = splvm(); - if (crypto_pool_initialized == 0) { - pool_init(&cryptop_pool, sizeof(struct cryptop), 0, 0, - 0, "cryptop", NULL); - pool_init(&cryptodesc_pool, sizeof(struct cryptodesc), 0, 0, - 0, "cryptodesc", NULL); - crypto_pool_initialized = 1; - } - crp = pool_get(&cryptop_pool, PR_NOWAIT); if (crp == NULL) { splx(s); @@ -626,9 +617,14 @@ crypto_getreq(int num) } void -init_crypto() +crypto_init(void) { crypto_workq = workq_create("crypto", 1, IPL_HIGH); + + pool_init(&cryptop_pool, sizeof(struct cryptop), 0, 0, + 0, "cryptop", NULL); + pool_init(&cryptodesc_pool, sizeof(struct cryptodesc), 0, 0, + 0, "cryptodesc", NULL); } /* diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 14afa2af599..34beffbe642 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.170 2010/07/26 01:56:27 guenther Exp $ */ +/* $OpenBSD: init_main.c,v 1.171 2010/09/08 14:15:56 jsing Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -140,7 +140,7 @@ void start_init(void *); void start_cleaner(void *); void start_update(void *); void start_reaper(void *); -void init_crypto(void); +void crypto_init(void); void init_exec(void); void kqueue_init(void); void workq_init(void); @@ -387,6 +387,7 @@ main(void *framep) (*pdev->pdev_attach)(pdev->pdev_count); #ifdef CRYPTO + crypto_init(); swcr_init(); #endif /* CRYPTO */ @@ -524,11 +525,6 @@ main(void *framep) if (kthread_create(uvm_aiodone_daemon, NULL, NULL, "aiodoned")) panic("fork aiodoned"); -#ifdef CRYPTO - /* Create the crypto kernel thread. */ - init_crypto(); -#endif /* CRYPTO */ - microtime(&rtv); srandom((u_int32_t)(rtv.tv_sec ^ rtv.tv_usec) ^ arc4random()); |