Module Name:    src
Committed By:   snj
Date:           Wed Oct 25 07:01:19 UTC 2017

Modified Files:
        src/sys/dist/pf/net [netbsd-8]: pf_ioctl.c

Log Message:
Pull up following revision(s) (requested by pgoyette in ticket #322):
        sys/dist/pf/net/pf_ioctl.c: revision 1.52
Defer initialization of pf_status.host_id
The call to cprng_fast32() requires that per-cpu data has been initialized
by corng_fast_init(), which doesn't get called until after the first part
of auto-configuration is done, long after pfattach() calls cprng_fast32().
Fixed PR kern/52620


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.51.10.1 src/sys/dist/pf/net/pf_ioctl.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/dist/pf/net/pf_ioctl.c
diff -u src/sys/dist/pf/net/pf_ioctl.c:1.51 src/sys/dist/pf/net/pf_ioctl.c:1.51.10.1
--- src/sys/dist/pf/net/pf_ioctl.c:1.51	Thu Aug 20 14:40:18 2015
+++ src/sys/dist/pf/net/pf_ioctl.c	Wed Oct 25 07:01:19 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pf_ioctl.c,v 1.51 2015/08/20 14:40:18 christos Exp $	*/
+/*	$NetBSD: pf_ioctl.c,v 1.51.10.1 2017/10/25 07:01:19 snj Exp $	*/
 /*	$OpenBSD: pf_ioctl.c,v 1.182 2007/06/24 11:17:13 mcbride Exp $ */
 
 /*
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pf_ioctl.c,v 1.51 2015/08/20 14:40:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf_ioctl.c,v 1.51.10.1 2017/10/25 07:01:19 snj Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -66,6 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: pf_ioctl.c,v
 #include <sys/kauth.h>
 #include <sys/module.h>
 #include <sys/cprng.h>
+#include <sys/device.h>
 #endif /* __NetBSD__ */
 
 #include <net/if.h>
@@ -166,6 +167,10 @@ int			 pf_rtlabel_add(struct pf_addr_wra
 void			 pf_rtlabel_remove(struct pf_addr_wrap *);
 void			 pf_rtlabel_copyout(struct pf_addr_wrap *);
 
+#ifdef __NetBSD__
+void	pf_deferred_init(device_t);
+#endif
+
 #define DPFPRINTF(n, x) if (pf_status.debug >= (n)) printf x
 
 #ifdef __NetBSD__
@@ -310,15 +315,19 @@ pfattach(int num)
 	bzero(&pf_status, sizeof(pf_status));
 	pf_status.debug = PF_DEBUG_URGENT;
 
+#ifdef __NetBSD__
+	/*
+	 * Defer rest of initialization until we can use cprng_fast32()
+	 * which requires per-CPU data to have been initialized which
+	 * in turn requires that all CPUs have been discovered and
+	 * attached!
+	 */
+	config_interrupts(NULL, pf_deferred_init);
+#else
 	/* XXX do our best to avoid a conflict */
 	pf_status.hostid = cprng_fast32();
 
 	/* require process context to purge states, so perform in a thread */
-#ifdef __NetBSD__
-	if (kthread_create(PRI_NONE, 0, NULL, pf_purge_thread, NULL, NULL,
-	    "pfpurge"))
-		panic("pfpurge thread");
-#else
 	kthread_create_deferred(pf_thread_create, NULL);
 #endif /* !__NetBSD__ */
 
@@ -328,6 +337,22 @@ pfattach(int num)
 #endif /* __NetBSD__ */
 }
 
+#ifdef __NetBSD__
+/* ARGSUSED */
+void
+pf_deferred_init(device_t dev)
+{
+
+	/* XXX do our best to avoid a conflict */
+	pf_status.hostid = cprng_fast32();
+
+	/* require process context to purge states, so perform in a thread */
+	if (kthread_create(PRI_NONE, 0, NULL, pf_purge_thread, NULL, NULL,
+	    "pfpurge"))
+		panic("pfpurge thread");
+}
+#endif /* __NetBSD__ */
+
 #ifdef _MODULE
 void
 pfdetach(void)

Reply via email to