diff options
| author | dan <dan@NetBSD.org> | 2002-10-08 09:59:27 +0000 |
|---|---|---|
| committer | dan <dan@NetBSD.org> | 2002-10-08 09:59:27 +0000 |
| commit | 7c2a3f904425466b66095bfcfdec906b26f9961d (patch) | |
| tree | 5ce6f5a1270e574ebab34b50cfbed6814844fbf4 /sys/dev | |
| parent | 234b47175211ac1563a1117437236ebdc171d708 (diff) | |
mix in another counter when the psuedo-device attachment is called,
this actually happens *after* most of the sources have attached, so microtime
is as safe now as it was when they attached.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/rnd.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 90fa0fc8b42..d8f0b814a72 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $NetBSD: rnd.c,v 1.32 2002/10/07 11:02:20 dan Exp $ */ +/* $NetBSD: rnd.c,v 1.33 2002/10/08 09:59:27 dan Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.32 2002/10/07 11:02:20 dan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.33 2002/10/08 09:59:27 dan Exp $"); #include <sys/param.h> #include <sys/ioctl.h> @@ -286,8 +286,19 @@ rnd_estimate_entropy(rndsource_t *rs, u_int32_t t) void rndattach(int num) { + u_int32_t c; + /* + * rnd_init() is actually called very early on in the boot + * process, pseudo's don't get attached until much later + * (after many of the sources have been attached). + * XXX Maybe this is left "in case", maybe it should be an assert? + */ rnd_init(); + + /* mix in another counter */ + c = rnd_counter(); + rndpool_add_data(&rnd_pool, &c, sizeof(u_int32_t), 0); } void @@ -298,6 +309,10 @@ rnd_init(void) if (rnd_ready) return; + /* + * take a counter early, hoping that there's some variance in + * the following operations + */ c = rnd_counter(); LIST_INIT(&rnd_sources); |
