summaryrefslogtreecommitdiffstats
path: root/sys/dev/random
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2000-07-09 11:52:12 +0000
committermarkm <markm@FreeBSD.org>2000-07-09 11:52:12 +0000
commit89ca69193464a4d38b274170f31e1230f83f97d2 (patch)
tree23899ac28a165c102257976c1b1732610ec89d7c /sys/dev/random
parentbe58a54d861ad1db0bee83f025d12336bae99471 (diff)
downloadFreeBSD-src-89ca69193464a4d38b274170f31e1230f83f97d2.zip
FreeBSD-src-89ca69193464a4d38b274170f31e1230f83f97d2.tar.gz
Yarrow tweaks; separate the fast and slow reseed tasks so that they don't
stomp on each other; provide constant names (as enums) for the harvester to use (makes it more self-documenting).
Diffstat (limited to 'sys/dev/random')
-rw-r--r--sys/dev/random/yarrow.c23
-rw-r--r--sys/dev/random/yarrow.h2
2 files changed, 14 insertions, 11 deletions
diff --git a/sys/dev/random/yarrow.c b/sys/dev/random/yarrow.c
index ab4a69c..dab10b5 100644
--- a/sys/dev/random/yarrow.c
+++ b/sys/dev/random/yarrow.c
@@ -47,17 +47,20 @@
static void generator_gate(void);
static void reseed(int);
-static void random_harvest_internal(struct timespec *nanotime, u_int64_t entropy, u_int bits, u_int frac, u_int source);
+static void random_harvest_internal(struct timespec *nanotime, u_int64_t entropy, u_int bits, u_int frac, enum esource source);
/* Structure holding the entropy state */
struct random_state random_state;
/* When enough entropy has been harvested, asynchronously "stir" it in */
-static struct task regate_task;
+static struct task regate_task[2];
-static struct context {
+struct context {
u_int pool;
-} context = { 0 };
+} context[2] = {
+ { 0 },
+ { 1 }
+ };
static void
regate(void *context, int pending)
@@ -80,7 +83,8 @@ random_init(void)
random_state.pool[1].thresh = 160;
random_state.slowoverthresh = 2;
random_state.which = FAST;
- TASK_INIT(&regate_task, 0, &regate, (void *)&context);
+ TASK_INIT(&regate_task[FAST], FAST, &regate, (void *)&context[FAST]);
+ TASK_INIT(&regate_task[SLOW], SLOW, &regate, (void *)&context[SLOW]);
random_init_harvester(random_harvest_internal);
}
@@ -286,7 +290,7 @@ generator_gate(void)
static void
random_harvest_internal(struct timespec *nanotime, u_int64_t entropy,
- u_int bits, u_int frac, u_int origin)
+ u_int bits, u_int frac, enum esource origin)
{
u_int insert;
int which; /* fast or slow */
@@ -324,16 +328,15 @@ random_harvest_internal(struct timespec *nanotime, u_int64_t entropy,
source->bits += source->frac / 1024;
source->frac %= 1024;
}
- context.pool = which;
if (source->bits >= pool->thresh) {
- /* XXX Needs to be multiply queued? */
- taskqueue_enqueue(taskqueue_swi, &regate_task);
+ /* XXX Slowoverthresh nees to be considered */
+ taskqueue_enqueue(taskqueue_swi, &regate_task[which]);
}
/* bump the insertion point */
source->current = insert;
- /* toggle the pool for next time */
+ /* toggle the pool for next insertion */
random_state.which = !random_state.which;
}
diff --git a/sys/dev/random/yarrow.h b/sys/dev/random/yarrow.h
index 2b6afcf..d2471bc 100644
--- a/sys/dev/random/yarrow.h
+++ b/sys/dev/random/yarrow.h
@@ -41,7 +41,7 @@
void random_init(void);
void random_deinit(void);
-void random_init_harvester(void (*)(struct timespec *, u_int64_t, u_int, u_int, u_int));
+void random_init_harvester(void (*)(struct timespec *, u_int64_t, u_int, u_int, enum esource));
void random_deinit_harvester(void);
/* This is the beasite that needs protecting. It contains all of the
OpenPOWER on IntegriCloud