Module Name:    src
Committed By:   jmcneill
Date:           Fri Feb 12 19:48:26 UTC 2021

Modified Files:
        src/sys/kern: kern_entropy.c

Log Message:
entropy: Only print consolidation warning of AB_DEBUG.

The previous fix for PR kern/55458 changed printf to log(LOG_DEBUG, ...) with
the intent of hiding the message unless 'boot -x'. But this did not actually
suppress the message to console as log(LOG_DEBUG, ...) will print to console
if syslogd is not running yet.

So instead, just check for AB_DEBUG flag directly in boothowto, and only
printf the message if it is set.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/kern/kern_entropy.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.29 src/sys/kern/kern_entropy.c:1.30
--- src/sys/kern/kern_entropy.c:1.29	Thu Jan 21 17:33:55 2021
+++ src/sys/kern/kern_entropy.c	Fri Feb 12 19:48:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.29 2021/01/21 17:33:55 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.30 2021/02/12 19:48:26 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.29 2021/01/21 17:33:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.30 2021/02/12 19:48:26 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -98,6 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_entropy
 #include <sys/percpu.h>
 #include <sys/poll.h>
 #include <sys/queue.h>
+#include <sys/reboot.h>
 #include <sys/rnd.h>		/* legacy kernel API */
 #include <sys/rndio.h>		/* userland ioctl interface */
 #include <sys/rndsource.h>	/* kernel rndsource driver API */
@@ -1031,9 +1032,11 @@ entropy_do_consolidate(void)
 	atomic_store_relaxed(&E->needed, E->needed - diff);
 	E->pending -= diff;
 	if (__predict_false(E->needed > 0)) {
-		if (ratecheck(&lasttime, &interval))
-			log(LOG_DEBUG, "entropy: WARNING:"
+		if (ratecheck(&lasttime, &interval) &&
+		    (boothowto & AB_DEBUG) != 0) {
+			printf("entropy: WARNING:"
 			    " consolidating less than full entropy\n");
+		}
 	}
 
 	/* Advance the epoch and notify waiters.  */

Reply via email to