Fri Jan 27 17:25:34 2017 UTC ()
Don't hold softnet_lock if NET_MPSAFE.

Some functions lock softnet_lock while waiting in pserialize_perform() in pfil_add_hook().
(e.g. key_timehandler(), etc)


(ryo)
diff -r1.5 -r1.6 src/sys/net/npf/npf_os.c

cvs diff -r1.5 -r1.6 src/sys/net/npf/npf_os.c (expand / switch to context diff)
--- src/sys/net/npf/npf_os.c 2017/01/03 00:58:05 1.5
+++ src/sys/net/npf/npf_os.c 2017/01/27 17:25:34 1.6
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_os.c,v 1.5 2017/01/03 00:58:05 rmind Exp $	*/
+/*	$NetBSD: npf_os.c,v 1.6 2017/01/27 17:25:34 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2009-2016 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_os.c,v 1.5 2017/01/03 00:58:05 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_os.c,v 1.6 2017/01/27 17:25:34 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pf.h"
@@ -65,6 +65,7 @@
 #ifdef _KERNEL
 #ifndef _MODULE
 #include "opt_modular.h"
+#include "opt_net_mpsafe.h"
 #endif
 #include "ioconf.h"
 #endif
@@ -396,8 +397,10 @@
 	npf_t *npf = npf_getkernctx();
 	int error = 0;
 
+#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
 	KERNEL_LOCK(1, NULL);
+#endif
 
 	/* Init: interface re-config and attach/detach hook. */
 	if (!npf_ph_if) {
@@ -452,8 +455,10 @@
 	npf_ifaddr_syncall(npf);
 	pfil_registered = true;
 out:
+#ifndef NET_MPSAFE
 	KERNEL_UNLOCK_ONE(NULL);
 	mutex_exit(softnet_lock);
+#endif
 
 	return error;
 }
@@ -466,8 +471,10 @@
 {
 	npf_t *npf = npf_getkernctx();
 
+#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
 	KERNEL_LOCK(1, NULL);
+#endif
 
 	if (fini && npf_ph_if) {
 		(void)pfil_remove_ihook(npf_ifhook, NULL,
@@ -485,8 +492,10 @@
 	}
 	pfil_registered = false;
 
+#ifndef NET_MPSAFE
 	KERNEL_UNLOCK_ONE(NULL);
 	mutex_exit(softnet_lock);
+#endif
 }
 
 bool