On Sun, Nov 27, 2022 at 09:23:25PM +0000, Klemens Nanni wrote:
> Only ip6_init() calls nd6_init(), exactly once, just like it calls
> frag6_init() which on the other hand does not have some fra6_init_done
> to guard against itself.
> 
> Like all other domains, ip6_init() is called in domaininit(), early in
> the kernel's main().
> 
> This variable was probably never useful and dates back to nd6.c r1.1:
>     bring in KAME IPv6 code, dated 19991208.
> 
> Feedback? OK?

OK bluhm@

> NB:  While here, nd6 and frag6 could statically initalise their lists
> right away (they're both static/local to nd6.c and frag6.c anyway), but

I see no big adavantage of variable initializer over ..._init()
function.  The latter is there anyway.

> that should probably be another diff, if at all, with more static added
> to those files.

Why is static in the kernel a benefit?  There were times when static
was no allowed to have more complete symbol list.

> diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
> index 9fdaf8138d1..07ccf615746 100644
> --- a/sys/netinet6/nd6.c
> +++ b/sys/netinet6/nd6.c
> @@ -104,21 +104,12 @@ struct task nd6_expire_task;
>  void
>  nd6_init(void)
>  {
> -     static int nd6_init_done = 0;
> -
> -     if (nd6_init_done) {
> -             log(LOG_NOTICE, "%s called more than once\n", __func__);
> -             return;
> -     }
> -
>       TAILQ_INIT(&nd6_list);
>       pool_init(&nd6_pool, sizeof(struct llinfo_nd6), 0,
>           IPL_SOFTNET, 0, "nd6", NULL);
>  
>       task_set(&nd6_expire_task, nd6_expire, NULL);
>  
> -     nd6_init_done = 1;
> -
>       /* start timer */
>       timeout_set_proc(&nd6_timer_to, nd6_timer, NULL);
>       timeout_set_proc(&nd6_slowtimo_ch, nd6_slowtimo, NULL);

Reply via email to