Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netipsec Run key_timehandler in thread context (workqueue)
details: https://anonhg.NetBSD.org/src/rev/6fca27520bbf
branches: trunk
changeset: 823950:6fca27520bbf
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Tue May 16 02:59:22 2017 +0000
description:
Run key_timehandler in thread context (workqueue)
The handler involves object deallocations so we want to not run
it in softint.
diffstat:
sys/netipsec/key.c | 31 ++++++++++++++++++++++++-------
sys/netipsec/key.h | 3 +--
2 files changed, 25 insertions(+), 9 deletions(-)
diffs (106 lines):
diff -r de7e08f45391 -r 6fca27520bbf sys/netipsec/key.c
--- a/sys/netipsec/key.c Mon May 15 21:30:37 2017 +0000
+++ b/sys/netipsec/key.c Tue May 16 02:59:22 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.125 2017/05/15 09:55:29 ozaki-r Exp $ */
+/* $NetBSD: key.c,v 1.126 2017/05/16 02:59:22 ozaki-r Exp $ */
/* $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $ */
/* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.125 2017/05/15 09:55:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.126 2017/05/16 02:59:22 ozaki-r Exp $");
/*
* This code is referd to RFC 2367
@@ -64,6 +64,7 @@
#include <sys/cprng.h>
#include <sys/psref.h>
#include <sys/lwp.h>
+#include <sys/workqueue.h>
#include <net/if.h>
#include <net/route.h>
@@ -533,7 +534,12 @@
static void key_sp_unlink (struct secpolicy *sp);
static struct mbuf *key_alloc_mbuf (int);
-struct callout key_timehandler_ch;
+
+static void key_timehandler(void *);
+static void key_timehandler_work(struct work *, void *);
+static struct callout key_timehandler_ch;
+static struct workqueue *key_timehandler_wq;
+static struct work key_timehandler_wk;
#ifdef IPSEC_REF_DEBUG
#define REFLOG(label, p, where, tag) \
@@ -4548,14 +4554,14 @@
* scanning SPD and SAD to check status for each entries,
* and do to remove or to expire.
*/
-void
-key_timehandler(void* arg)
+static void
+key_timehandler_work(struct work *wk, void *arg)
{
u_int dir;
int s;
time_t now = time_uptime;
- s = splsoftnet(); /*called from softclock()*/
+ s = splsoftnet();
mutex_enter(softnet_lock);
/* SPD */
@@ -4764,6 +4770,13 @@
return;
}
+static void
+key_timehandler(void *arg)
+{
+
+ workqueue_enqueue(key_timehandler_wq, &key_timehandler_wk, NULL);
+}
+
u_long
key_random(void)
{
@@ -7696,11 +7709,15 @@
static int
key_do_init(void)
{
- int i;
+ int i, error;
pfkeystat_percpu = percpu_alloc(sizeof(uint64_t) * PFKEY_NSTATS);
callout_init(&key_timehandler_ch, 0);
+ error = workqueue_create(&key_timehandler_wq, "key_timehandler",
+ key_timehandler_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE);
+ if (error != 0)
+ panic("%s: workqueue_create failed (%d)\n", __func__, error);
for (i = 0; i < IPSEC_DIR_MAX; i++) {
LIST_INIT(&sptree[i]);
diff -r de7e08f45391 -r 6fca27520bbf sys/netipsec/key.h
--- a/sys/netipsec/key.h Mon May 15 21:30:37 2017 +0000
+++ b/sys/netipsec/key.h Tue May 16 02:59:22 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.h,v 1.15 2017/05/15 09:55:29 ozaki-r Exp $ */
+/* $NetBSD: key.h,v 1.16 2017/05/16 02:59:22 ozaki-r Exp $ */
/* $FreeBSD: src/sys/netipsec/key.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $KAME: key.h,v 1.21 2001/07/27 03:51:30 itojun Exp $ */
@@ -96,7 +96,6 @@
int key_cmpspidx_exactly (const struct secpolicyindex *, const struct secpolicyindex *);
int key_cmpspidx_withmask (const struct secpolicyindex *, const struct secpolicyindex *);
int key_spdacquire (const struct secpolicy *);
-void key_timehandler (void*);
u_long key_random (void);
void key_randomfill (void *, size_t);
void key_freereg (struct socket *);
Home |
Main Index |
Thread Index |
Old Index