On 21/12/16(Wed) 18:22, Alexander Bluhm wrote:
> On Wed, Dec 21, 2016 at 05:21:53PM +0100, Alexander Bluhm wrote:
> > > @@ -430,15 +430,16 @@ nd6_llinfo_timer(void *arg)
> > >  void
> > >  nd6_timer_work(void *null)
> > >  {
> > > - int s;
> > >   struct nd_defrouter *dr, *ndr;
> > >   struct nd_prefix *pr, *npr;
> > >   struct in6_ifaddr *ia6, *nia6;
> > > + int s;
> > >  
> > > - s = splsoftnet();
> > >   timeout_set(&nd6_timer_ch, nd6_timer, NULL);
> > >   timeout_add_sec(&nd6_timer_ch, nd6_prune);
> > >  
> > > + NET_LOCK(s);
> > > +
> > 
> > Moving timeout_set() out of the splsoftnet() feels wrong.  The whole
> > task construct could be replaced with a timeout_set_proc(), I will
> > make a diff.
> 
> This diff replaces the nd6_timer timeout and task with a timeout
> proc.

Can we wait until the experiment is complete?  Until then I'd like
to keep timeout_set_proc() only for timeout converted because they
need the NET_LOCK().  

If we discover a flaw and need to "back out" we can simply do

        #define timeout_set_proc(x)     timeout_set

and

        #define NET_LOCK(s)     s = splsoftnet()

But if we start to convert other stuff, like the diff below does, this
wont work.

> 
> ok?
> 
> bluhm
> 
> Index: netinet6/ip6_input.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_input.c,v
> retrieving revision 1.172
> diff -u -p -r1.172 ip6_input.c
> --- netinet6/ip6_input.c      20 Dec 2016 18:33:43 -0000      1.172
> +++ netinet6/ip6_input.c      21 Dec 2016 16:49:17 -0000
> @@ -119,7 +119,6 @@ struct niqueue ip6intrq = NIQUEUE_INITIA
>  
>  struct ip6stat ip6stat;
>  
> -void ip6_init2(void *);
>  int ip6_check_rh0hdr(struct mbuf *, int *);
>  
>  int ip6_hbhchcheck(struct mbuf *, int *, int *, int *);
> @@ -157,19 +156,8 @@ ip6_init(void)
>       ip6_randomid_init();
>       nd6_init();
>       frag6_init();
> -     ip6_init2(NULL);
>  
>       mq_init(&ip6send_mq, 64, IPL_SOFTNET);
> -}
> -
> -void
> -ip6_init2(void *dummy)
> -{
> -
> -     /* nd6_timer_init */
> -     bzero(&nd6_timer_ch, sizeof(nd6_timer_ch));
> -     timeout_set(&nd6_timer_ch, nd6_timer, NULL);
> -     timeout_add_sec(&nd6_timer_ch, 1);
>  }
>  
>  /*
> Index: netinet6/nd6.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/nd6.c,v
> retrieving revision 1.199
> diff -u -p -r1.199 nd6.c
> --- netinet6/nd6.c    20 Dec 2016 18:33:43 -0000      1.199
> +++ netinet6/nd6.c    21 Dec 2016 17:21:12 -0000
> @@ -93,14 +93,13 @@ struct nd_prhead nd_prefix = { 0 };
>  int nd6_recalc_reachtm_interval = ND6_RECALC_REACHTM_INTERVAL;
>  
>  void nd6_slowtimo(void *);
> +void nd6_timer(void *);
>  void nd6_invalidate(struct rtentry *);
>  struct llinfo_nd6 *nd6_free(struct rtentry *, int);
>  void nd6_llinfo_timer(void *);
>  
>  struct timeout nd6_slowtimo_ch;
>  struct timeout nd6_timer_ch;
> -struct task nd6_timer_task;
> -void nd6_timer_work(void *);
>  
>  int fill_drlist(void *, size_t *, size_t);
>  int fill_prlist(void *, size_t *, size_t);
> @@ -122,13 +121,13 @@ nd6_init(void)
>       /* initialization of the default router list */
>       TAILQ_INIT(&nd_defrouter);
>  
> -     task_set(&nd6_timer_task, nd6_timer_work, NULL);
> -
>       nd6_init_done = 1;
>  
>       /* start timer */
>       timeout_set(&nd6_slowtimo_ch, nd6_slowtimo, NULL);
>       timeout_add_sec(&nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL);
> +     timeout_set_proc(&nd6_timer_ch, nd6_timer, NULL);
> +     timeout_add_sec(&nd6_timer_ch, nd6_prune);
>  
>       nd6_rs_init();
>  }
> @@ -428,7 +427,7 @@ nd6_llinfo_timer(void *arg)
>   * ND6 timer routine to expire default route list and prefix list
>   */
>  void
> -nd6_timer_work(void *null)
> +nd6_timer(void *arg)
>  {
>       int s;
>       struct nd_defrouter *dr, *ndr;
> @@ -436,7 +435,6 @@ nd6_timer_work(void *null)
>       struct in6_ifaddr *ia6, *nia6;
>  
>       s = splsoftnet();
> -     timeout_set(&nd6_timer_ch, nd6_timer, NULL);
>       timeout_add_sec(&nd6_timer_ch, nd6_prune);
>  
>       /* expire default router list */
> @@ -483,12 +481,6 @@ nd6_timer_work(void *null)
>               }
>       }
>       splx(s);
> -}
> -
> -void
> -nd6_timer(void *ignored_arg)
> -{
> -     task_add(systq, &nd6_timer_task);
>  }
>  
>  /*
> Index: netinet6/nd6.h
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/nd6.h,v
> retrieving revision 1.65
> diff -u -p -r1.65 nd6.h
> --- netinet6/nd6.h    28 Nov 2016 13:59:51 -0000      1.65
> +++ netinet6/nd6.h    21 Dec 2016 16:48:46 -0000
> @@ -223,8 +223,6 @@ extern int nd6_debug;
>  
>  #define nd6log(x)    do { if (nd6_debug) log x; } while (0)
>  
> -extern struct timeout nd6_timer_ch;
> -
>  union nd_opts {
>       struct nd_opt_hdr *nd_opt_array[9];
>       struct {
> @@ -260,7 +258,6 @@ int nd6_options(union nd_opts *);
>  struct       rtentry *nd6_lookup(struct in6_addr *, int, struct ifnet *, 
> u_int);
>  void nd6_setmtu(struct ifnet *);
>  void nd6_llinfo_settimer(struct llinfo_nd6 *, int);
> -void nd6_timer(void *);
>  void nd6_purge(struct ifnet *);
>  void nd6_nud_hint(struct rtentry *);
>  void nd6_rtrequest(struct ifnet *, int, struct rtentry *);
> 

Reply via email to