diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 5f35ff90e7d0..97aec2561936 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_subr.c,v 1.271 2017/07/29 05:08:48 maxv Exp $ */ +/* $NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.271 2017/07/29 05:08:48 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.272 2018/01/19 07:53:01 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -382,8 +382,6 @@ struct mowner tcp_sock_rx_mowner = MOWNER_INIT("tcp", "sock rx"); struct mowner tcp_sock_tx_mowner = MOWNER_INIT("tcp", "sock tx"); #endif -callout_t tcp_slowtimo_ch; - static int do_tcpinit(void) { @@ -424,8 +422,7 @@ do_tcpinit(void) vtw_earlyinit(); - callout_init(&tcp_slowtimo_ch, CALLOUT_MPSAFE); - callout_reset(&tcp_slowtimo_ch, 1, tcp_slowtimo, NULL); + tcp_slowtimo_init(); return 0; } diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index fa2e1bccbf8f..6487b36e6ae2 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_timer.c,v 1.92 2017/07/28 19:16:41 maxv Exp $ */ +/* $NetBSD: tcp_timer.c,v 1.93 2018/01/19 07:53:01 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,11 +93,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.92 2017/07/28 19:16:41 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.93 2018/01/19 07:53:01 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" #include "opt_tcp_debug.h" +#include "opt_net_mpsafe.h" #endif #include @@ -108,6 +109,8 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.92 2017/07/28 19:16:41 maxv Exp $"); #include #include #include +#include +#include #include @@ -149,6 +152,15 @@ u_int tcp_keepcnt = 0; /* max idle probes */ int tcp_maxpersistidle = 0; /* max idle time in persist */ +static callout_t tcp_slowtimo_ch; +#ifdef NET_MPSAFE +static struct workqueue *tcp_slowtimo_wq; +static struct work tcp_slowtimo_wk; +#endif + +static void tcp_slowtimo_work(struct work *, void *); +static void tcp_slowtimo(void *); + /* * Time to delay the ACK. This is initialized in tcp_init(), unless * its patched. @@ -193,6 +205,21 @@ tcp_timer_init(void) tcp_delack_ticks = TCP_DELACK_TICKS; } +void +tcp_slowtimo_init(void) +{ +#ifdef NET_MPSAFE + int error; + + error = workqueue_create(&tcp_slowtimo_wq, "tcp_slowtimo", + tcp_slowtimo_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE); + if (error != 0) + panic("%s: workqueue_create failed (%d)\n", __func__, error); +#endif + callout_init(&tcp_slowtimo_ch, CALLOUT_MPSAFE); + callout_reset(&tcp_slowtimo_ch, 1, tcp_slowtimo, NULL); +} + /* * Callout to process delayed ACKs for a TCPCB. */ @@ -229,8 +256,8 @@ tcp_delack(void *arg) * Updates the timers in all active tcb's and * causes finite state machine actions if timers expire. */ -void -tcp_slowtimo(void *arg) +static void +tcp_slowtimo_work(struct work *wk, void *arg) { mutex_enter(softnet_lock); @@ -241,6 +268,17 @@ tcp_slowtimo(void *arg) callout_schedule(&tcp_slowtimo_ch, hz / PR_SLOWHZ); } +static void +tcp_slowtimo(void *arg) +{ + +#ifdef NET_MPSAFE + workqueue_enqueue(tcp_slowtimo_wq, &tcp_slowtimo_wk, NULL); +#else + tcp_slowtimo_work(NULL, NULL); +#endif +} + /* * Cancel all timers for TCP tp. */ diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h index 629f8e0f7f36..fd209cd93a3c 100644 --- a/sys/netinet/tcp_timer.h +++ b/sys/netinet/tcp_timer.h @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_timer.h,v 1.28 2011/05/24 18:37:52 gdt Exp $ */ +/* $NetBSD: tcp_timer.h,v 1.29 2018/01/19 07:53:01 ozaki-r Exp $ */ /*- * Copyright (c) 2001, 2005 The NetBSD Foundation, Inc. @@ -190,6 +190,7 @@ extern int tcp_ttl; /* time to live for TCP segs */ extern const int tcp_backoff[]; void tcp_timer_init(void); +void tcp_slowtimo_init(void); #endif #endif /* !_NETINET_TCP_TIMER_H_ */ diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 542450d05850..faf0a5ec92e4 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_var.h,v 1.181 2017/11/15 09:55:22 ozaki-r Exp $ */ +/* $NetBSD: tcp_var.h,v 1.182 2018/01/19 07:53:01 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -928,8 +928,6 @@ void tcp_setpersist(struct tcpcb *); int tcp_signature_compute(struct mbuf *, struct tcphdr *, int, int, int, u_char *, u_int); #endif -void tcp_slowtimo(void *); -extern callout_t tcp_slowtimo_ch; void tcp_fasttimo(void); struct mbuf * tcp_template(struct tcpcb *);