diff --git a/sys/net/route.c b/sys/net/route.c index 6107745..d4a5a27 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -114,6 +114,7 @@ __KERNEL_RCSID(0, "$NetBSD: route.c,v 1.168 2016/07/01 05:22:33 ozaki-r Exp $"); #include #include #include +#include #include #include @@ -136,6 +137,8 @@ static struct pool rtentry_pool; static struct pool rttimer_pool; static struct callout rt_timer_ch; /* callout for rt_timer_timer() */ +struct workqueue *rt_timer_wq; +struct work rt_timer_wk; #ifdef RTFLUSH_DEBUG static int _rtcache_debug = 0; @@ -1147,14 +1150,22 @@ static int rt_init_done = 0; * that this is run when the first queue is added... */ +static void rt_timer_work(struct work *, void *); + void rt_timer_init(void) { + int error; + assert(rt_init_done == 0); LIST_INIT(&rttimer_queue_head); callout_init(&rt_timer_ch, 0); callout_reset(&rt_timer_ch, hz, rt_timer_timer, NULL); + error = workqueue_create(&rt_timer_wq, "rt_timer", + rt_timer_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE); + if (error) + panic("%s: workqueue_create failed (%d)\n", __func__, error); rt_init_done = 1; } @@ -1287,9 +1298,8 @@ rt_timer_add(struct rtentry *rt, return 0; } -/* ARGSUSED */ -void -rt_timer_timer(void *arg) +static void +rt_timer_work(struct work *wk, void *arg) { struct rttimer_queue *rtq; struct rttimer *r; @@ -1315,6 +1325,13 @@ rt_timer_timer(void *arg) callout_reset(&rt_timer_ch, hz, rt_timer_timer, NULL); } +void +rt_timer_timer(void *arg) +{ + + workqueue_enqueue(rt_timer_wq, &rt_timer_wk, NULL); +} + static struct rtentry * _rtcache_init(struct route *ro, int flag) { diff --git a/sys/netinet/ip_flow.c b/sys/netinet/ip_flow.c index cfadfc1..00602af 100644 --- a/sys/netinet/ip_flow.c +++ b/sys/netinet/ip_flow.c @@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.72 2016/06/20 06:46:38 knakahara Exp $ #include #include #include +#include #include #include @@ -105,6 +106,10 @@ static int ip_hashsize = IPFLOW_DEFAULT_HASHSIZE; static struct ipflow *ipflow_reap(bool); static void ipflow_sysctl_init(struct sysctllog **); +static void ipflow_slowtimo_work(struct work *, void *); +static struct workqueue *ipflow_slowtimo_wq; +static struct work ipflow_slowtimo_wk; + static size_t ipflow_hash(const struct ip *ip) { @@ -176,6 +181,12 @@ ipflow_reinit(int table_size) void ipflow_init(void) { + int error; + + error = workqueue_create(&ipflow_slowtimo_wq, "ipflow_slowtimo", + ipflow_slowtimo_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE); + if (error != 0) + panic("%s: workqueue_create failed (%d)\n", __func__, error); mutex_init(&ipflow_lock, MUTEX_DEFAULT, IPL_NONE); @@ -419,8 +430,8 @@ ipflow_reap(bool just_one) return NULL; } -void -ipflow_slowtimo(void) +static void +ipflow_slowtimo_work(struct work *wk, void *arg) { struct rtentry *rt; struct ipflow *ipf, *next_ipf; @@ -451,6 +462,13 @@ ipflow_slowtimo(void) } void +ipflow_slowtimo(void) +{ + + workqueue_enqueue(ipflow_slowtimo_wq, &ipflow_slowtimo_wk, NULL); +} + +void ipflow_create(const struct route *ro, struct mbuf *m) { const struct ip *const ip = mtod(m, const struct ip *); diff --git a/sys/netinet6/ip6_flow.c b/sys/netinet6/ip6_flow.c index 7448bb2..23fddde 100644 --- a/sys/netinet6/ip6_flow.c +++ b/sys/netinet6/ip6_flow.c @@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.27 2016/06/20 06:46:38 knakahara Exp #include #include #include +#include #include #include @@ -100,6 +101,10 @@ static struct ip6flowhead *ip6flowtable = NULL; static struct ip6flowhead ip6flowlist; static int ip6flow_inuse; +static void ip6flow_slowtimo_work(struct work *, void *); +static struct workqueue *ip6flow_slowtimo_wq; +static struct work ip6flow_slowtimo_wk; + /* * Insert an ip6flow into the list. */ @@ -217,7 +222,12 @@ ip6flow_init_locked(int table_size) int ip6flow_init(int table_size) { - int ret; + int ret, error; + + error = workqueue_create(&ip6flow_slowtimo_wq, "ip6flow_slowtimo", + ip6flow_slowtimo_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE); + if (error != 0) + panic("%s: workqueue_create failed (%d)\n", __func__, error); mutex_init(&ip6flow_lock, MUTEX_DEFAULT, IPL_NONE); @@ -457,7 +467,7 @@ ip6flow_reap(int just_one) } void -ip6flow_slowtimo(void) +ip6flow_slowtimo_work(struct work *wk, void *arg) { struct ip6flow *ip6f, *next_ip6f; @@ -484,6 +494,13 @@ ip6flow_slowtimo(void) mutex_exit(softnet_lock); } +void +ip6flow_slowtimo(void) +{ + + workqueue_enqueue(ip6flow_slowtimo_wq, &ip6flow_slowtimo_wk, NULL); +} + /* * We have successfully forwarded a packet using the normal * IPv6 stack. Now create/update a flow. diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 58f544a..1078e46 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -56,6 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.201 2016/07/05 06:32:18 ozaki-r Exp $"); #include #include #include +#include #include #include @@ -113,10 +114,13 @@ static int regen_tmpaddr(const struct in6_ifaddr *); static void nd6_free(struct llentry *, int); static void nd6_llinfo_timer(void *); static void nd6_timer(void *); +static void nd6_timer_work(struct work *, void *); static void clear_llinfo_pqueue(struct llentry *); static callout_t nd6_slowtimo_ch; static callout_t nd6_timer_ch; +static struct workqueue *nd6_timer_wq; +static struct work nd6_timer_wk; static int fill_drlist(void *, size_t *, size_t); static int fill_prlist(void *, size_t *, size_t); @@ -126,6 +130,7 @@ MALLOC_DEFINE(M_IP6NDP, "NDP", "IPv6 Neighbour Discovery"); void nd6_init(void) { + int error; /* initialization of the default router list */ TAILQ_INIT(&nd_defrouter); @@ -133,6 +138,11 @@ nd6_init(void) callout_init(&nd6_slowtimo_ch, CALLOUT_MPSAFE); callout_init(&nd6_timer_ch, CALLOUT_MPSAFE); + error = workqueue_create(&nd6_timer_wq, "nd6_timer", + nd6_timer_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE); + if (error) + panic("%s: workqueue_create failed (%d)\n", __func__, error); + /* start timer */ callout_reset(&nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL * hz, nd6_slowtimo, NULL); @@ -556,7 +566,7 @@ out: * ND6 timer routine to expire default route list and prefix list */ static void -nd6_timer(void *ignored_arg) +nd6_timer_work(struct work *wk, void *arg) { struct nd_defrouter *next_dr, *dr; struct nd_prefix *next_pr, *pr; @@ -678,6 +688,13 @@ nd6_timer(void *ignored_arg) mutex_exit(softnet_lock); } +static void +nd6_timer(void *ignored_arg) +{ + + workqueue_enqueue(nd6_timer_wq, &nd6_timer_wk, NULL); +} + /* ia6: deprecated/invalidated temporary address */ static int regen_tmpaddr(const struct in6_ifaddr *ia6)