Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/dist/pf/net Pull up following revision(s) (requested ...



details:   https://anonhg.NetBSD.org/src/rev/62de3e99c575
branches:  netbsd-8
changeset: 851082:62de3e99c575
user:      snj <snj%NetBSD.org@localhost>
date:      Wed Oct 25 07:01:19 2017 +0000

description:
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

diffstat:

 sys/dist/pf/net/pf_ioctl.c |  39 ++++++++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 7 deletions(-)

diffs (85 lines):

diff -r 8807e4584d2d -r 62de3e99c575 sys/dist/pf/net/pf_ioctl.c
--- a/sys/dist/pf/net/pf_ioctl.c        Wed Oct 25 06:56:41 2017 +0000
+++ b/sys/dist/pf/net/pf_ioctl.c        Wed Oct 25 07:01:19 2017 +0000
@@ -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 @@
 #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 @@
 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 @@
        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 @@
 #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)



Home | Main Index | Thread Index | Old Index