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)
This commit is contained in:
ryo 2017-01-27 17:25:34 +00:00
parent ee8d32bb92
commit 672772a1a5

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: npf_os.c,v 1.5 2017/01/03 00:58:05 rmind Exp $");
#ifdef _KERNEL
#ifndef _MODULE
#include "opt_modular.h"
#include "opt_net_mpsafe.h"
#endif
#include "ioconf.h"
#endif
@ -396,8 +397,10 @@ npf_pfil_register(bool init)
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_pfil_register(bool init)
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_pfil_unregister(bool fini)
{
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 @@ npf_pfil_unregister(bool fini)
}
pfil_registered = false;
#ifndef NET_MPSAFE
KERNEL_UNLOCK_ONE(NULL);
mutex_exit(softnet_lock);
#endif
}
bool