> Date: Mon, 3 Oct 2016 14:57:34 +0200
> From: Martin Pieuchot <m...@openbsd.org>
> 
> Here are some timeouts that require a process context in order to call
> ip_output().
> 
> The reason is that rtalloc(9) might end up inserting a RTF_CLONING route
> and that requires holding a write lock.  This isn't going to change
> because we're also going to use write locks to protect pf(4) internals. 
> 
> So to not introduce new sleeping points in the socket layer we're going
> to serialize all code paths that might end up in ip_output().  For that
> we're going to use a write lock, for which we need a process context.
> 
> Now that dlg@ fixed the deadlocks pointed by Haesbaert and guenther@,
> let's convert the first timeouts.
> 
> ok?

Let's see if this sticks.

ok kettenis@

> Index: net/if_pflow.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_pflow.c,v
> retrieving revision 1.61
> diff -u -p -r1.61 if_pflow.c
> --- net/if_pflow.c    29 Apr 2016 08:55:03 -0000      1.61
> +++ net/if_pflow.c    3 Oct 2016 12:47:11 -0000
> @@ -548,15 +548,16 @@ pflow_init_timeouts(struct pflow_softc *
>               if (timeout_initialized(&sc->sc_tmo_tmpl))
>                       timeout_del(&sc->sc_tmo_tmpl);
>               if (!timeout_initialized(&sc->sc_tmo))
> -                     timeout_set(&sc->sc_tmo, pflow_timeout, sc);
> +                     timeout_set_proc(&sc->sc_tmo, pflow_timeout, sc);
>               break;
>       case PFLOW_PROTO_10:
>               if (!timeout_initialized(&sc->sc_tmo_tmpl))
> -                     timeout_set(&sc->sc_tmo_tmpl, pflow_timeout_tmpl, sc);
> +                     timeout_set_proc(&sc->sc_tmo_tmpl, pflow_timeout_tmpl,
> +                         sc);
>               if (!timeout_initialized(&sc->sc_tmo))
> -                     timeout_set(&sc->sc_tmo, pflow_timeout, sc);
> +                     timeout_set_proc(&sc->sc_tmo, pflow_timeout, sc);
>               if (!timeout_initialized(&sc->sc_tmo6))
> -                     timeout_set(&sc->sc_tmo6, pflow_timeout6, sc);
> +                     timeout_set_proc(&sc->sc_tmo6, pflow_timeout6, sc);
>  
>               timeout_add_sec(&sc->sc_tmo_tmpl, PFLOW_TMPL_TIMEOUT);
>               break;
> Index: net/if_pfsync.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_pfsync.c,v
> retrieving revision 1.234
> diff -u -p -r1.234 if_pfsync.c
> --- net/if_pfsync.c   27 Sep 2016 04:57:17 -0000      1.234
> +++ net/if_pfsync.c   3 Oct 2016 12:47:11 -0000
> @@ -328,9 +328,9 @@ pfsync_clone_create(struct if_clone *ifc
>       IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
>       ifp->if_hdrlen = sizeof(struct pfsync_header);
>       ifp->if_mtu = ETHERMTU;
> -     timeout_set(&sc->sc_tmo, pfsync_timeout, sc);
> -     timeout_set(&sc->sc_bulk_tmo, pfsync_bulk_update, sc);
> -     timeout_set(&sc->sc_bulkfail_tmo, pfsync_bulk_fail, sc);
> +     timeout_set_proc(&sc->sc_tmo, pfsync_timeout, sc);
> +     timeout_set_proc(&sc->sc_bulk_tmo, pfsync_bulk_update, sc);
> +     timeout_set_proc(&sc->sc_bulkfail_tmo, pfsync_bulk_fail, sc);
>  
>       if_attach(ifp);
>       if_alloc_sadl(ifp);
> @@ -1720,7 +1720,7 @@ pfsync_defer(struct pf_state *st, struct
>       sc->sc_deferred++;
>       TAILQ_INSERT_TAIL(&sc->sc_deferrals, pd, pd_entry);
>  
> -     timeout_set(&pd->pd_tmo, pfsync_defer_tmo, pd);
> +     timeout_set_proc(&pd->pd_tmo, pfsync_defer_tmo, pd);
>       timeout_add_msec(&pd->pd_tmo, 20);
>  
>       schednetisr(NETISR_PFSYNC);
> Index: netinet/ip_carp.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_carp.c,v
> retrieving revision 1.293
> diff -u -p -r1.293 ip_carp.c
> --- netinet/ip_carp.c 25 Jul 2016 16:44:04 -0000      1.293
> +++ netinet/ip_carp.c 3 Oct 2016 12:47:11 -0000
> @@ -831,9 +831,9 @@ carp_new_vhost(struct carp_softc *sc, in
>       vhe->vhid = vhid;
>       vhe->advskew = advskew;
>       vhe->state = INIT;
> -     timeout_set(&vhe->ad_tmo, carp_send_ad, vhe);
> -     timeout_set(&vhe->md_tmo, carp_master_down, vhe);
> -     timeout_set(&vhe->md6_tmo, carp_master_down, vhe);
> +     timeout_set_proc(&vhe->ad_tmo, carp_send_ad, vhe);
> +     timeout_set_proc(&vhe->md_tmo, carp_master_down, vhe);
> +     timeout_set_proc(&vhe->md6_tmo, carp_master_down, vhe);
>  
>       KERNEL_ASSERT_LOCKED(); /* touching carp_vhosts */
>  
> Index: netinet/tcp_timer.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_timer.h,v
> retrieving revision 1.13
> diff -u -p -r1.13 tcp_timer.h
> --- netinet/tcp_timer.h       6 Jul 2011 23:44:20 -0000       1.13
> +++ netinet/tcp_timer.h       3 Oct 2016 12:47:11 -0000
> @@ -116,7 +116,7 @@ const char *tcptimers[] =
>   * Init, arm, disarm, and test TCP timers.
>   */
>  #define      TCP_TIMER_INIT(tp, timer)                                       
> \
> -     timeout_set(&(tp)->t_timer[(timer)], tcp_timer_funcs[(timer)], tp)
> +     timeout_set_proc(&(tp)->t_timer[(timer)], tcp_timer_funcs[(timer)], tp)
>  
>  #define      TCP_TIMER_ARM(tp, timer, nticks)                                
> \
>       timeout_add(&(tp)->t_timer[(timer)], (nticks) * (hz / PR_SLOWHZ))
> Index: netinet/tcp_var.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_var.h,v
> retrieving revision 1.115
> diff -u -p -r1.115 tcp_var.h
> --- netinet/tcp_var.h 20 Jul 2016 19:57:53 -0000      1.115
> +++ netinet/tcp_var.h 3 Oct 2016 12:47:11 -0000
> @@ -217,7 +217,7 @@ extern int tcp_delack_ticks;
>  void tcp_delack(void *);
>  
>  #define TCP_INIT_DELACK(tp)                                          \
> -     timeout_set(&(tp)->t_delack_to, tcp_delack, tp)
> +     timeout_set_proc(&(tp)->t_delack_to, tcp_delack, tp)
>  
>  #define TCP_RESTART_DELACK(tp)                                               
> \
>       timeout_add(&(tp)->t_delack_to, tcp_delack_ticks)
> 
> 

Reply via email to