summaryrefslogtreecommitdiffstats
path: root/sys/dev/random
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2000-11-25 19:13:29 +0000
committermarkm <markm@FreeBSD.org>2000-11-25 19:13:29 +0000
commit6ac673bf3ce6085f5f69239cbe8b7c589420612f (patch)
tree6330dea7cb1bd93c13cc0160be5cdb9de47357eb /sys/dev/random
parentcad5a0b6850de5fd5f30e60d61d0101ca92d3daa (diff)
downloadFreeBSD-src-6ac673bf3ce6085f5f69239cbe8b7c589420612f.zip
FreeBSD-src-6ac673bf3ce6085f5f69239cbe8b7c589420612f.tar.gz
Greatly improve the boot-up unblocking time of the entropy device.
Diffstat (limited to 'sys/dev/random')
-rw-r--r--sys/dev/random/randomdev.c11
-rw-r--r--sys/dev/random/yarrow.c10
-rw-r--r--sys/dev/random/yarrow.h2
3 files changed, 19 insertions, 4 deletions
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c
index 13230db..37aeb3d 100644
--- a/sys/dev/random/randomdev.c
+++ b/sys/dev/random/randomdev.c
@@ -51,6 +51,7 @@
#include "opt_noblockrandom.h"
static d_open_t random_open;
+static d_close_t random_close;
static d_read_t random_read;
static d_write_t random_write;
static d_ioctl_t random_ioctl;
@@ -62,7 +63,7 @@ static d_poll_t random_poll;
static struct cdevsw random_cdevsw = {
/* open */ random_open,
- /* close */ (d_close_t *)nullop,
+ /* close */ random_close,
/* read */ random_read,
/* write */ random_write,
/* ioctl */ random_ioctl,
@@ -104,6 +105,14 @@ random_open(dev_t dev, int flags, int fmt, struct proc *p)
}
static int
+random_close(dev_t dev, int flags, int fmt, struct proc *p)
+{
+ if ((flags & FWRITE) && (securelevel > 0 || suser(p)))
+ random_reseed();
+ return 0;
+}
+
+static int
random_read(dev_t dev, struct uio *uio, int flag)
{
u_int c, ret;
diff --git a/sys/dev/random/yarrow.c b/sys/dev/random/yarrow.c
index 8480897..c53e7c1 100644
--- a/sys/dev/random/yarrow.c
+++ b/sys/dev/random/yarrow.c
@@ -455,9 +455,6 @@ write_random(void *buf, u_int count)
random_harvest_internal(get_cyclecount(), (char *)buf + i, count,
0, 0, RANDOM_WRITE);
}
-
- /* Explicit reseed */
- reseed(FAST);
}
static void
@@ -527,3 +524,10 @@ random_harvest_internal(u_int64_t somecounter, void *entropy, u_int count,
mtx_exit(&random_harvest_mtx, MTX_DEF);
}
}
+
+/* Helper routine to perform explicit reseeds */
+void
+random_reseed(void)
+{
+ reseed(FAST);
+}
diff --git a/sys/dev/random/yarrow.h b/sys/dev/random/yarrow.h
index 9904d24..49cc602 100644
--- a/sys/dev/random/yarrow.h
+++ b/sys/dev/random/yarrow.h
@@ -45,6 +45,8 @@ void random_init_harvester(void (*)(u_int64_t, void *, u_int, u_int, u_int, enum
void random_deinit_harvester(void);
void random_set_wakeup_exit(void *);
+void random_reseed(void);
+
u_int read_random_real(void *, u_int);
void write_random(void *, u_int);
OpenPOWER on IntegriCloud