svn commit: r258074 - in projects/random_number_generator/sys: dev/glxsb dev/random kern modules net netgraph sys
Mark Murray
markm at FreeBSD.org
Tue Nov 12 22:43:31 UTC 2013
Author: markm
Date: Tue Nov 12 22:43:27 2013
New Revision: 258074
URL: http://svnweb.freebsd.org/changeset/base/258074
Log:
More code eyeballing and fixup:
* Use sbuf_*(9) for printing interesting stuff from sysctls. Much neater, and gets rid of static buffers.
* Use a bitmask to decide which sources to harvest instead of checking inside a structure. Much more general.
* Tidy up the usual comments, constants and variable names.
* Fix module building on amd64.
Modified:
projects/random_number_generator/sys/dev/glxsb/glxsb.c
projects/random_number_generator/sys/dev/random/ivy.c
projects/random_number_generator/sys/dev/random/live_entropy_sources.c
projects/random_number_generator/sys/dev/random/nehemiah.c
projects/random_number_generator/sys/dev/random/random_adaptors.c
projects/random_number_generator/sys/dev/random/random_adaptors.h
projects/random_number_generator/sys/dev/random/random_harvestq.c
projects/random_number_generator/sys/dev/random/randomdev.c
projects/random_number_generator/sys/dev/random/randomdev.h
projects/random_number_generator/sys/dev/random/randomdev_soft.c
projects/random_number_generator/sys/dev/random/yarrow.c
projects/random_number_generator/sys/kern/kern_intr.c
projects/random_number_generator/sys/modules/Makefile
projects/random_number_generator/sys/net/if_ethersubr.c
projects/random_number_generator/sys/net/if_tun.c
projects/random_number_generator/sys/netgraph/ng_iface.c
projects/random_number_generator/sys/sys/random.h
Modified: projects/random_number_generator/sys/dev/glxsb/glxsb.c
==============================================================================
--- projects/random_number_generator/sys/dev/glxsb/glxsb.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/glxsb/glxsb.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -476,7 +476,7 @@ glxsb_rnd(void *v)
if (status & SB_RNS_TRNG_VALID) {
value = bus_read_4(sc->sc_sr, SB_RANDOM_NUM);
/* feed with one uint32 */
- random_harvest(&value, 4, 32/2, RANDOM_PURE_GLXSB);
+ random_harvest(&value, sizeof(value), 32/2, RANDOM_PURE_GLXSB);
}
callout_reset(&sc->sc_rngco, sc->sc_rnghz, glxsb_rnd, sc);
Modified: projects/random_number_generator/sys/dev/random/ivy.c
==============================================================================
--- projects/random_number_generator/sys/dev/random/ivy.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/ivy.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -47,9 +47,8 @@ __FBSDID("$FreeBSD$");
#include <dev/random/randomdev.h>
#include <dev/random/randomdev_soft.h>
-#include <dev/random/random_harvestq.h>
-#include <dev/random/live_entropy_sources.h>
#include <dev/random/random_adaptors.h>
+#include <dev/random/live_entropy_sources.h>
#define RETRY_COUNT 10
@@ -109,7 +108,7 @@ rdrand_modevent(module_t mod, int type,
case MOD_LOAD:
if (cpu_feature2 & CPUID2_RDRAND) {
live_entropy_source_register(&random_ivy);
- printf("random: live provider: %s\n", random_ivy.ident);
+ printf("random: live provider: \"%s\"\n", random_ivy.les_ident);
}
break;
Modified: projects/random_number_generator/sys/dev/random/live_entropy_sources.c
==============================================================================
--- projects/random_number_generator/sys/dev/random/live_entropy_sources.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/live_entropy_sources.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/queue.h>
#include <sys/random.h>
+#include <sys/sbuf.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
@@ -48,14 +49,14 @@ __FBSDID("$FreeBSD$");
#include "live_entropy_sources.h"
-LIST_HEAD(les_head, live_entropy_sources);
-static struct les_head les_sources = LIST_HEAD_INITIALIZER(les_sources);
-
/*
- * The live_lock protects the consistency of the "struct les_head les_sources"
+ * The les_lock protects the consistency of the "struct les_head les_sources"
*/
static struct sx les_lock; /* need a sleepable lock */
+LIST_HEAD(les_head, live_entropy_sources);
+static struct les_head les_sources = LIST_HEAD_INITIALIZER(les_sources);
+
void
live_entropy_source_register(struct live_entropy_source *rsource)
{
@@ -92,23 +93,27 @@ live_entropy_source_deregister(struct li
static int
live_entropy_source_handler(SYSCTL_HANDLER_ARGS)
{
- /* XXX: FIX!! Fixed array size */
- char buf[128];
struct live_entropy_sources *lles;
- int count;
+ struct sbuf sbuf;
+ int error, count;
sx_slock(&les_lock);
- buf[0] = '\0';
+ sbuf_new_for_sysctl(&sbuf, NULL, 64, req);
+
count = 0;
LIST_FOREACH(lles, &les_sources, lles_entries) {
- strcat(buf, (count++ ? "," : ""));
- strcat(buf, lles->lles_rsource->les_ident);
+ sbuf_cat(&sbuf, (count++ ? ",'" : "'"));
+ sbuf_cat(&sbuf, lles->lles_rsource->les_ident);
+ sbuf_cat(&sbuf, "'");
}
+ error = sbuf_finish(&sbuf);
+ sbuf_delete(&sbuf);
+
sx_sunlock(&les_lock);
- return (SYSCTL_OUT(req, buf, strlen(buf)));
+ return (error);
}
/*
@@ -128,8 +133,9 @@ live_entropy_source_handler(SYSCTL_HANDL
void
live_entropy_sources_feed(void)
{
+ /* XXX: This wastes a few words of space */
+ static u_int destination[ENTROPYSOURCE];
static struct harvest_event event;
- static u_int dest = 0;
struct live_entropy_sources *lles;
int i, n;
@@ -153,7 +159,7 @@ live_entropy_sources_feed(void)
event.he_size = n;
event.he_bits = (n*8)/2;
event.he_source = lles->lles_rsource->les_source;
- event.he_destination = dest++;
+ event.he_destination = destination[event.he_source]++;
/* Do the actual entropy insertion */
harvest_process_event(&event);
Modified: projects/random_number_generator/sys/dev/random/nehemiah.c
==============================================================================
--- projects/random_number_generator/sys/dev/random/nehemiah.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/nehemiah.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -45,9 +45,8 @@ __FBSDID("$FreeBSD$");
#include <dev/random/randomdev.h>
#include <dev/random/randomdev_soft.h>
-#include <dev/random/random_harvestq.h>
-#include <dev/random/live_entropy_sources.h>
#include <dev/random/random_adaptors.h>
+#include <dev/random/live_entropy_sources.h>
static void random_nehemiah_init(void);
static void random_nehemiah_deinit(void);
@@ -132,7 +131,7 @@ nehemiah_modevent(module_t mod, int type
case MOD_LOAD:
if (via_feature_rng & VIA_HAS_RNG) {
live_entropy_source_register(&random_nehemiah);
- printf("random: live provider: %s\n", random_nehemiah.ident);
+ printf("random: live provider: \"%s\"\n", random_nehemiah.les_ident);
random_nehemiah_init();
}
break;
Modified: projects/random_number_generator/sys/dev/random/random_adaptors.c
==============================================================================
--- projects/random_number_generator/sys/dev/random/random_adaptors.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/random_adaptors.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/poll.h>
#include <sys/queue.h>
#include <sys/random.h>
+#include <sys/sbuf.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
@@ -46,12 +47,16 @@ __FBSDID("$FreeBSD$");
#include <dev/random/randomdev.h>
#include <dev/random/random_adaptors.h>
+/* These are the data structures and associated items that need to be locked against
+ * "under-the-feet" changes.
+ */
+static struct sx random_adaptors_lock; /* need a sleepable lock */
+
LIST_HEAD(adaptors_head, random_adaptors);
static struct adaptors_head random_adaptors_list = LIST_HEAD_INITIALIZER(random_adaptors_list);
-static struct sx random_adaptors_lock; /* need a sleepable lock */
+static struct random_adaptor *random_adaptor = NULL; /* Currently active adaptor */
-/* Contains a pointer to the currently active adaptor */
-static struct random_adaptor *random_adaptor = NULL;
+/* End of data items requiring lock protection */
MALLOC_DEFINE(M_ENTROPY, "entropy", "Entropy harvesting buffers and data structures");
@@ -70,6 +75,7 @@ random_adaptor_register(const char *name
sx_xlock(&random_adaptors_lock);
+ /* XXX: FIX!! Make sure we are not inserting a duplicate */
LIST_INSERT_HEAD(&random_adaptors_list, rra, rra_entries);
random_adaptor_choose();
@@ -112,9 +118,13 @@ random_adaptor_block(int flag)
int ret;
KASSERT(random_adaptor != NULL, ("No active random adaptor in %s", __func__));
+
sx_slock(&random_adaptors_lock);
+
ret = random_adaptor->ra_block(flag);
+
sx_sunlock(&random_adaptors_lock);
+
return ret;
}
@@ -185,7 +195,7 @@ random_adaptor_choose(void)
char rngs[128], *token, *cp;
struct random_adaptors *rra, *rrai;
struct random_adaptor *random_adaptor_previous;
- u_int primax;
+ int primax;
/* We are going to be messing with random_adaptor.
* Exclusive lock is mandatory.
@@ -215,7 +225,7 @@ random_adaptor_choose(void)
}
}
- primax = 0U;
+ primax = 0;
if (random_adaptor == NULL) {
/*
* Fall back to the highest priority item on the available
@@ -245,57 +255,53 @@ random_adaptor_choose(void)
static int
random_sysctl_adaptors_handler(SYSCTL_HANDLER_ARGS)
{
- /* XXX: FIX!! Fixed array size, but see below, this may be OK */
- char buf[128], *pbuf;
struct random_adaptors *rra;
- int count, snp;
- size_t lbuf;
-
- buf[0] = '\0';
- pbuf = buf;
- lbuf = 256;
- count = 0;
+ struct sbuf sbuf;
+ int error, count;
sx_slock(&random_adaptors_lock);
- LIST_FOREACH(rra, &random_adaptors_list, rra_entries) {
- snp = snprintf(pbuf, lbuf, "%s%s(%d)",
+ sbuf_new_for_sysctl(&sbuf, NULL, 64, req);
+
+ count = 0;
+ LIST_FOREACH(rra, &random_adaptors_list, rra_entries)
+ sbuf_printf(&sbuf, "%s%s(%d)",
(count++ ? "," : ""), rra->rra_name, rra->rra_ra->ra_priority);
- KASSERT(snp > 0, ("buffer overflow"));
- lbuf -= (size_t)snp;
- pbuf += snp;
- }
+
+ error = sbuf_finish(&sbuf);
+ sbuf_delete(&sbuf);
sx_sunlock(&random_adaptors_lock);
- return (SYSCTL_OUT(req, buf, strlen(buf)));
+ return (error);
}
static int
random_sysctl_active_adaptor_handler(SYSCTL_HANDLER_ARGS)
{
- /* XXX: FIX!! Fixed array size, but see below, this may be OK */
- char buf[32];
struct random_adaptors *rra;
- const char *name;
+ struct sbuf sbuf;
+ int error;
KASSERT(random_adaptor != NULL, ("No active random adaptor in %s", __func__));
- name = NULL;
- buf[0] = '\0';
-
sx_slock(&random_adaptors_lock);
+ sbuf_new_for_sysctl(&sbuf, NULL, 16, req);
+
LIST_FOREACH(rra, &random_adaptors_list, rra_entries)
if (rra->rra_ra == random_adaptor) {
- strncpy(buf, rra->rra_name, sizeof(buf));
+ sbuf_cat(&sbuf, rra->rra_name);
break;
}
+ error = sbuf_finish(&sbuf);
+ sbuf_delete(&sbuf);
+
sx_sunlock(&random_adaptors_lock);
- return (SYSCTL_OUT(req, buf, strlen(buf)));
+ return (error);
}
/* ARGSUSED */
Modified: projects/random_number_generator/sys/dev/random/random_adaptors.h
==============================================================================
--- projects/random_number_generator/sys/dev/random/random_adaptors.h Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/random_adaptors.h Tue Nov 12 22:43:27 2013 (r258074)
@@ -43,7 +43,7 @@ typedef void random_adaptor_reseed_func_
struct random_adaptor {
const char *ra_ident;
int ra_seeded;
- u_int ra_priority;
+ int ra_priority;
random_adaptor_init_func_t *ra_init;
random_adaptor_deinit_func_t *ra_deinit;
random_adaptor_block_func_t *ra_block;
Modified: projects/random_number_generator/sys/dev/random/random_harvestq.c
==============================================================================
--- projects/random_number_generator/sys/dev/random/random_harvestq.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/random_harvestq.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -231,6 +231,7 @@ void
random_harvestq_internal(const void *entropy, u_int count, u_int bits,
enum random_entropy_source origin)
{
+ /* XXX: This wastes a few words of space */
static u_int destination[ENTROPYSOURCE];
struct harvest_event *event;
Modified: projects/random_number_generator/sys/dev/random/randomdev.c
==============================================================================
--- projects/random_number_generator/sys/dev/random/randomdev.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/randomdev.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -84,9 +84,8 @@ static struct cdev *random_dev;
/* Allow the sysadmin to select the broad category of
* entropy types to harvest.
- * Here because the rest of the kernel checks these in random_harvest() calls.
*/
-struct harvest_select harvest = { 1, 1, 1, 1, 1 };
+u_int randomdev_harvest_source_mask = ((1<<RANDOM_ENVIRONMENTAL_END) - 1);
/* Set up the sysctl root node for the entropy device */
SYSCTL_NODE(_kern, OID_AUTO, random, CTLFLAG_RW, 0, "Random Number Generator");
@@ -216,7 +215,8 @@ randomdev_deinit_harvester(void)
void
random_harvest(const void *entropy, u_int count, u_int bits, enum random_entropy_source origin)
{
- (*reap_func)(entropy, count, bits, origin);
+ if (randomdev_harvest_source_mask & (1<<origin))
+ (*reap_func)(entropy, count, bits, origin);
}
/* If the entropy device is not loaded, don't act on harvesting calls
@@ -243,7 +243,7 @@ read_random(void *buf, int count)
* provide _some_ kind of output. No warranty of the quality of
* this output is made, mainly because its lousy. Caveat Emptor.
*/
-/* XXX: FIX!! Move this to dummy_rng.c */
+/* XXX: FIX!! Move this to dummy_rng.c ? */
static int
random_read_phony(void *buf, int count)
{
Modified: projects/random_number_generator/sys/dev/random/randomdev.h
==============================================================================
--- projects/random_number_generator/sys/dev/random/randomdev.h Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/randomdev.h Tue Nov 12 22:43:27 2013 (r258074)
@@ -46,6 +46,8 @@ void randomdev_init_harvester(void (*)(c
int (*)(void *, int));
void randomdev_deinit_harvester(void);
+extern u_int randomdev_harvest_source_mask;
+
/* kern.random sysctls */
#ifdef SYSCTL_DECL /* from sysctl.h */
SYSCTL_DECL(_kern_random);
Modified: projects/random_number_generator/sys/dev/random/randomdev_soft.c
==============================================================================
--- projects/random_number_generator/sys/dev/random/randomdev_soft.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/randomdev_soft.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/poll.h>
#include <sys/random.h>
+#include <sys/sbuf.h>
#include <sys/selinfo.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
@@ -129,10 +130,35 @@ random_check_boolean(SYSCTL_HANDLER_ARGS
return (sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req));
}
+/* ARGSUSED */
+RANDOM_CHECK_UINT(harvestmask, 0, ((1<<RANDOM_ENVIRONMENTAL_END) - 1));
+
+/* ARGSUSED */
+static int
+random_print_harvestmask(SYSCTL_HANDLER_ARGS)
+{
+ struct sbuf sbuf;
+ int error, i;
+
+ error = sysctl_wire_old_buffer(req, 0);
+ if (error != 0)
+ return (error);
+
+ sbuf_new_for_sysctl(&sbuf, NULL, 128, req);
+
+ for (i = 31; i >= 0; i--)
+ sbuf_cat(&sbuf, (randomdev_harvest_source_mask & (1<<i)) ? "1" : "0");
+
+ error = sbuf_finish(&sbuf);
+ sbuf_delete(&sbuf);
+
+ return (error);
+}
+
void
randomdev_init(void)
{
- struct sysctl_oid *random_sys_o, *random_sys_harvest_o;
+ struct sysctl_oid *random_sys_o;
#if defined(RANDOM_YARROW)
random_yarrow_init_alg(&random_clist);
@@ -152,37 +178,17 @@ randomdev_init(void)
&random_soft_processor.ra_seeded, 0, random_check_boolean, "I",
"Seeded State");
- random_sys_harvest_o = SYSCTL_ADD_NODE(&random_clist,
+ SYSCTL_ADD_PROC(&random_clist,
SYSCTL_CHILDREN(random_sys_o),
- OID_AUTO, "harvest", CTLFLAG_RW, 0,
- "Entropy Sources");
+ OID_AUTO, "source_mask", CTLTYPE_UINT | CTLFLAG_RW,
+ &randomdev_harvest_source_mask, ((1<<RANDOM_ENVIRONMENTAL_END) - 1),
+ random_check_uint_harvestmask, "IU",
+ "Entropy harvesting mask");
- /* XXX: FIX!! This is yucky. Rather do it as a bitfield? */
- SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_sys_harvest_o),
- OID_AUTO, "ethernet", CTLTYPE_INT | CTLFLAG_RW,
- &harvest.ethernet, 1, random_check_boolean, "I",
- "Harvest NIC entropy");
SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_sys_harvest_o),
- OID_AUTO, "point_to_point", CTLTYPE_INT | CTLFLAG_RW,
- &harvest.point_to_point, 1, random_check_boolean, "I",
- "Harvest serial net entropy");
- SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_sys_harvest_o),
- OID_AUTO, "interrupt", CTLTYPE_INT | CTLFLAG_RW,
- &harvest.interrupt, 1, random_check_boolean, "I",
- "Harvest IRQ entropy");
- SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_sys_harvest_o),
- OID_AUTO, "swi", CTLTYPE_INT | CTLFLAG_RW,
- &harvest.swi, 1, random_check_boolean, "I",
- "Harvest SWI entropy");
- SYSCTL_ADD_PROC(&random_clist,
- SYSCTL_CHILDREN(random_sys_harvest_o),
- OID_AUTO, "uma", CTLTYPE_INT | CTLFLAG_RW,
- &harvest.uma, 1, random_check_boolean, "I",
- "Harvest UMA allocator entropy");
+ SYSCTL_CHILDREN(random_sys_o),
+ OID_AUTO, "source_mask_bin", CTLTYPE_STRING | CTLFLAG_RD,
+ NULL, 0, random_print_harvestmask, "A", "Entropy harvesting mask (printable)");
/* Register the randomness processing routine */
#if defined(RANDOM_YARROW)
Modified: projects/random_number_generator/sys/dev/random/yarrow.c
==============================================================================
--- projects/random_number_generator/sys/dev/random/yarrow.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/dev/random/yarrow.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -116,20 +116,6 @@ random_yarrow_process_event(struct harve
struct source *source;
enum random_entropy_source src;
-#if 0
- /* XXX: Fix!! Do this better with DTrace */
- {
- int i;
-
- printf("Harvest:%16jX ", event->somecounter);
- for (i = 0; i < event->size; i++)
- printf("%02X", event->entropy[i]);
- for (; i < 16; i++)
- printf(" ");
- printf(" %2d %2d %02X %02X\n", event->size, event->bits, event->source, event->destination);
- }
-#endif
-
/* Accumulate the event into the appropriate pool
* where each event carries the destination information
*/
@@ -307,10 +293,10 @@ reseed(u_int fastslow)
/* 7. Dump to seed file */
#ifdef RANDOM_RWFILE_WRITE_OK /* XXX: Not defined so writes ain't gonna happen */
- seed_file = "/var/db/entropy/seed_cache";
+ seed_file = "<some file>";
error = randomdev_write_file(seed_file, <generated entropy>, PAGE_SIZE);
- if (error == 0) {
- printf("random: entropy seed file '%s' successfully written\n", seed_file);
+ if (error == 0)
+ printf("random: entropy seed file '%s' successfully written\n", seed_file);
#endif
/* Unblock the device if it was blocked due to being unseeded */
Modified: projects/random_number_generator/sys/kern/kern_intr.c
==============================================================================
--- projects/random_number_generator/sys/kern/kern_intr.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/kern/kern_intr.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -896,13 +896,10 @@ intr_event_schedule_thread(struct intr_e
* If any of the handlers for this ithread claim to be good
* sources of entropy, then gather some.
*/
- if (harvest.interrupt && ie->ie_flags & IE_ENTROPY) {
- CTR3(KTR_INTR, "%s: pid %d (%s) gathering entropy", __func__,
- p->p_pid, td->td_name);
+ if (ie->ie_flags & IE_ENTROPY) {
entropy.event = (uintptr_t)ie;
entropy.td = ctd;
- random_harvest(&entropy, sizeof(entropy), 2,
- RANDOM_INTERRUPT);
+ random_harvest(&entropy, sizeof(entropy), 2, RANDOM_INTERRUPT);
}
KASSERT(p != NULL, ("ithread %s has no process", ie->ie_name));
@@ -1050,13 +1047,10 @@ intr_event_schedule_thread(struct intr_e
* If any of the handlers for this ithread claim to be good
* sources of entropy, then gather some.
*/
- if (harvest.interrupt && ie->ie_flags & IE_ENTROPY) {
- CTR3(KTR_INTR, "%s: pid %d (%s) gathering entropy", __func__,
- p->p_pid, td->td_name);
+ if (ie->ie_flags & IE_ENTROPY) {
entropy.event = (uintptr_t)ie;
entropy.td = ctd;
- random_harvest(&entropy, sizeof(entropy), 2,
- RANDOM_INTERRUPT);
+ random_harvest(&entropy, sizeof(entropy), 2, RANDOM_INTERRUPT);
}
KASSERT(p != NULL, ("ithread %s has no process", ie->ie_name));
@@ -1141,14 +1135,9 @@ swi_sched(void *cookie, int flags)
CTR3(KTR_INTR, "swi_sched: %s %s need=%d", ie->ie_name, ih->ih_name,
ih->ih_need);
- if (harvest.swi) {
- CTR2(KTR_INTR, "swi_sched: pid %d (%s) gathering entropy",
- curproc->p_pid, curthread->td_name);
- entropy.event = (uintptr_t)ih;
- entropy.td = curthread;
- random_harvest(&entropy, sizeof(entropy), 1,
- RANDOM_SWI);
- }
+ entropy.event = (uintptr_t)ih;
+ entropy.td = curthread;
+ random_harvest(&entropy, sizeof(entropy), 1, RANDOM_SWI);
/*
* Set ih_need for this handler so that if the ithread is already
Modified: projects/random_number_generator/sys/modules/Makefile
==============================================================================
--- projects/random_number_generator/sys/modules/Makefile Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/modules/Makefile Tue Nov 12 22:43:27 2013 (r258074)
@@ -744,6 +744,8 @@ _opensolaris= opensolaris
.endif
.if ${MK_CRYPT} != "no" || defined(ALL_MODULES)
_padlock= padlock
+_padlock_rng= padlock_rng
+_rdrand_rng= rdrand_rng
.endif
_pccard= pccard
_qlxge= qlxge
Modified: projects/random_number_generator/sys/net/if_ethersubr.c
==============================================================================
--- projects/random_number_generator/sys/net/if_ethersubr.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/net/if_ethersubr.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -641,8 +641,7 @@ ether_input_internal(struct ifnet *ifp,
m->m_flags |= M_PROMISC;
}
- if (harvest.ethernet)
- random_harvest(&(m->m_data), 12, 2, RANDOM_NET_ETHER);
+ random_harvest(&(m->m_data), 12, 2, RANDOM_NET_ETHER);
ether_demux(ifp, m);
CURVNET_RESTORE();
Modified: projects/random_number_generator/sys/net/if_tun.c
==============================================================================
--- projects/random_number_generator/sys/net/if_tun.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/net/if_tun.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -918,8 +918,7 @@ tunwrite(struct cdev *dev, struct uio *u
m_freem(m);
return (EAFNOSUPPORT);
}
- if (harvest.point_to_point)
- random_harvest(&(m->m_data), 12, 2, RANDOM_NET_TUN);
+ random_harvest(&(m->m_data), 12, 2, RANDOM_NET_TUN);
ifp->if_ibytes += m->m_pkthdr.len;
ifp->if_ipackets++;
CURVNET_SET(ifp->if_vnet);
Modified: projects/random_number_generator/sys/netgraph/ng_iface.c
==============================================================================
--- projects/random_number_generator/sys/netgraph/ng_iface.c Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/netgraph/ng_iface.c Tue Nov 12 22:43:27 2013 (r258074)
@@ -775,8 +775,7 @@ ng_iface_rcvdata(hook_p hook, item_p ite
m_freem(m);
return (EAFNOSUPPORT);
}
- if (harvest.point_to_point)
- random_harvest(&(m->m_data), 12, 2, RANDOM_NET_NG);
+ random_harvest(&(m->m_data), 12, 2, RANDOM_NET_NG);
M_SETFIB(m, ifp->if_fib);
netisr_dispatch(isr, m);
return (0);
Modified: projects/random_number_generator/sys/sys/random.h
==============================================================================
--- projects/random_number_generator/sys/sys/random.h Tue Nov 12 21:42:59 2013 (r258073)
+++ projects/random_number_generator/sys/sys/random.h Tue Nov 12 22:43:27 2013 (r258074)
@@ -36,6 +36,9 @@ int read_random(void *, int);
/*
* Note: if you add or remove members of random_entropy_source, remember to also update the
* KASSERT regarding what valid members are in random_harvest_internal().
+ *
+ * NOTE: complain loudly to markm@ or on the lists if this enum gets more than 32
+ * distinct values (0-31)!
*/
enum random_entropy_source {
RANDOM_START = 0,
@@ -50,6 +53,7 @@ enum random_entropy_source {
RANDOM_INTERRUPT,
RANDOM_SWI,
RANDOM_UMA_ALLOC,
+ RANDOM_ENVIRONMENTAL_END,
/* High-quality HW RNGs from here on. */
RANDOM_PURE_OCTEON,
RANDOM_PURE_SAFE,
More information about the svn-src-projects
mailing list