Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Add counter info at source attach time too, since th...



details:   https://anonhg.NetBSD.org/src/rev/f43799568423
branches:  trunk
changeset: 537880:f43799568423
user:      dan <dan%NetBSD.org@localhost>
date:      Mon Oct 07 09:41:51 2002 +0000

description:
Add counter info at source attach time too, since there might be some
reasonable timing variance in the probing process.

Improve the usefulness and presentation of RND_VERBOSE output.

diffstat:

 sys/dev/rnd.c |  37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diffs (87 lines):

diff -r 065c662c56ce -r f43799568423 sys/dev/rnd.c
--- a/sys/dev/rnd.c     Mon Oct 07 08:20:07 2002 +0000
+++ b/sys/dev/rnd.c     Mon Oct 07 09:41:51 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rnd.c,v 1.30 2002/10/07 04:51:00 dan Exp $     */
+/*     $NetBSD: rnd.c,v 1.31 2002/10/07 09:41:51 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.30 2002/10/07 04:51:00 dan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.31 2002/10/07 09:41:51 dan Exp $");
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
@@ -220,6 +220,11 @@
                }
                selwakeup(&rnd_selq);
 
+#ifdef RND_VERBOSE
+               if (!rnd_have_entropy)
+                       printf("rnd: have initial entropy (%u)\n",
+                              rndpool_get_entropy_count(&rnd_pool));
+#endif
                /*
                 * Allow open of /dev/random now, too.
                 */
@@ -317,7 +322,8 @@
        rnd_ready = 1;
 
 #ifdef RND_VERBOSE
-       printf("Random device ready\n");
+       printf("rnd: initialised (%u)%s", RND_POOLBITS,
+              c ? " with counter\n" : "\n");
 #endif
 }
 
@@ -767,8 +773,22 @@
        LIST_INSERT_HEAD(&rnd_sources, rs, list);
 
 #ifdef RND_VERBOSE
-       printf("%s: attached as an entropy source\n", rs->data.name);
+       printf("rnd: %s attached as an entropy source (", rs->data.name);
+       if (!(flags & RND_FLAG_NO_COLLECT)) {
+               printf("collecting");
+               if (flags & RND_FLAG_NO_ESTIMATE)
+                       printf(" without estimation");
+       }
+       else
+               printf("off");
+       printf(")\n");
 #endif
+
+       /* 
+        * Again, put some more initial junk in the pool.
+        * XXX Bogus, but harder to guess than zeros.
+        */
+       rndpool_add_data(&rnd_pool, &ts, sizeof(u_int32_t), 0);
 }
 
 /*
@@ -805,6 +825,9 @@
        }
 
        splx(s);
+#ifdef RND_VERBOSE
+       printf("rnd: %s detached as an entropy source\n", rs->data.name);
+#endif
 }
 
 /*
@@ -978,6 +1001,12 @@
 {
        int retval, s;
 
+#ifdef RND_VERBOSE
+       if (!rnd_have_entropy)
+               printf("rnd: WARNING! initial entropy low (%u).\n",
+                      rndpool_get_entropy_count(&rnd_pool));
+#endif
+
        s = splsoftclock();
        retval = rndpool_extract_data(&rnd_pool, p, len, flags);
        splx(s);



Home | Main Index | Thread Index | Old Index