Reorganize in6_tmpaddrtimer stuffs
- Move the related functions to where in6_tmpaddrtimer_ch exists - Hide global variable in6_tmpaddrtimer_ch - Rename ip6_init2 to in6_tmpaddrtimer_init - Reduce callers of callout_reset - Use callout_schedule
This commit is contained in:
parent
bf3ec4633d
commit
e32ddc921e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_ifattach.c,v 1.115 2018/05/01 07:21:39 maxv Exp $ */
|
||||
/* $NetBSD: in6_ifattach.c,v 1.116 2019/10/16 07:40:40 ozaki-r Exp $ */
|
||||
/* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */
|
||||
|
||||
/*
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.115 2018/05/01 07:21:39 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.116 2019/10/16 07:40:40 ozaki-r Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -63,7 +63,7 @@ unsigned long in6_maxmtu = 0;
|
||||
|
||||
int ip6_auto_linklocal = 1; /* enable by default */
|
||||
|
||||
callout_t in6_tmpaddrtimer_ch;
|
||||
static callout_t in6_tmpaddrtimer_ch;
|
||||
|
||||
|
||||
#if 0
|
||||
@ -75,6 +75,9 @@ static int get_ifid(struct ifnet *, struct ifnet *, struct in6_addr *);
|
||||
static int in6_ifattach_linklocal(struct ifnet *, struct ifnet *);
|
||||
static int in6_ifattach_loopback(struct ifnet *);
|
||||
|
||||
static void in6_tmpaddrtimer_schedule(void);
|
||||
static void in6_tmpaddrtimer(void *);
|
||||
|
||||
#define EUI64_GBIT 0x01
|
||||
#define EUI64_UBIT 0x02
|
||||
#define EUI64_TO_IFID(in6) do {(in6)->s6_addr[8] ^= EUI64_UBIT; } while (/*CONSTCOND*/ 0)
|
||||
@ -849,6 +852,25 @@ in6_get_tmpifid(struct ifnet *ifp, u_int8_t *retbuf,
|
||||
}
|
||||
|
||||
void
|
||||
in6_tmpaddrtimer_init(void)
|
||||
{
|
||||
|
||||
/* timer for regeneration of temporary addresses randomize ID */
|
||||
callout_init(&in6_tmpaddrtimer_ch, CALLOUT_MPSAFE);
|
||||
callout_setfunc(&in6_tmpaddrtimer_ch, in6_tmpaddrtimer, NULL);
|
||||
in6_tmpaddrtimer_schedule();
|
||||
}
|
||||
|
||||
static void
|
||||
in6_tmpaddrtimer_schedule(void)
|
||||
{
|
||||
|
||||
callout_schedule(&in6_tmpaddrtimer_ch,
|
||||
(ip6_temp_preferred_lifetime - ip6_desync_factor -
|
||||
ip6_temp_regen_advance) * hz);
|
||||
}
|
||||
|
||||
static void
|
||||
in6_tmpaddrtimer(void *ignored_arg)
|
||||
{
|
||||
struct nd_ifinfo *ndi;
|
||||
@ -860,9 +882,7 @@ in6_tmpaddrtimer(void *ignored_arg)
|
||||
mutex_enter(softnet_lock);
|
||||
KERNEL_LOCK(1, NULL);
|
||||
|
||||
callout_reset(&in6_tmpaddrtimer_ch,
|
||||
(ip6_temp_preferred_lifetime - ip6_desync_factor -
|
||||
ip6_temp_regen_advance) * hz, in6_tmpaddrtimer, NULL);
|
||||
in6_tmpaddrtimer_schedule();
|
||||
|
||||
memset(nullbuf, 0, sizeof(nullbuf));
|
||||
s = pserialize_read_enter();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_ifattach.h,v 1.13 2009/09/19 13:11:02 christos Exp $ */
|
||||
/* $NetBSD: in6_ifattach.h,v 1.14 2019/10/16 07:40:40 ozaki-r Exp $ */
|
||||
/* $KAME: in6_ifattach.h,v 1.8 2000/04/12 03:51:30 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -37,7 +37,6 @@
|
||||
void in6_ifattach(struct ifnet *, struct ifnet *);
|
||||
void in6_ifdetach(struct ifnet *);
|
||||
int in6_get_tmpifid(struct ifnet *, u_int8_t *, const u_int8_t *, int);
|
||||
void in6_tmpaddrtimer(void *);
|
||||
int in6_get_hw_ifid(struct ifnet *, struct in6_addr *);
|
||||
int in6_nigroup(struct ifnet *, const char *, int, struct sockaddr_in6 *);
|
||||
#endif /* _KERNEL */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_var.h,v 1.100 2018/05/29 04:38:29 ozaki-r Exp $ */
|
||||
/* $NetBSD: in6_var.h,v 1.101 2019/10/16 07:40:40 ozaki-r Exp $ */
|
||||
/* $KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -584,7 +584,6 @@ extern const struct in6_addr zeroin6_addr;
|
||||
extern const u_char inet6ctlerrmap[];
|
||||
extern unsigned long in6_maxmtu;
|
||||
extern bool in6_present;
|
||||
extern callout_t in6_tmpaddrtimer_ch;
|
||||
|
||||
/*
|
||||
* Macro for finding the internet address structure (in6_ifaddr) corresponding
|
||||
@ -680,6 +679,7 @@ do { \
|
||||
#endif
|
||||
|
||||
void in6_init(void);
|
||||
void in6_tmpaddrtimer_init(void);
|
||||
|
||||
void in6_multi_lock(int);
|
||||
void in6_multi_unlock(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip6_input.c,v 1.211 2019/09/19 05:31:50 ozaki-r Exp $ */
|
||||
/* $NetBSD: ip6_input.c,v 1.212 2019/10/16 07:40:40 ozaki-r Exp $ */
|
||||
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.211 2019/09/19 05:31:50 ozaki-r Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.212 2019/10/16 07:40:40 ozaki-r Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_gateway.h"
|
||||
@ -134,7 +134,6 @@ percpu_t *ip6stat_percpu;
|
||||
|
||||
percpu_t *ip6_forward_rt_percpu __cacheline_aligned;
|
||||
|
||||
static void ip6_init2(void);
|
||||
static void ip6intr(void *);
|
||||
static bool ip6_badaddr(struct ip6_hdr *);
|
||||
static struct m_tag *ip6_setdstifaddr(struct mbuf *, const struct in6_ifaddr *);
|
||||
@ -185,7 +184,7 @@ ip6_init(void)
|
||||
frag6_init();
|
||||
ip6_desync_factor = cprng_fast32() % MAX_TEMP_DESYNC_FACTOR;
|
||||
|
||||
ip6_init2();
|
||||
in6_tmpaddrtimer_init();
|
||||
#ifdef GATEWAY
|
||||
ip6flow_init(ip6_hashsize);
|
||||
#endif
|
||||
@ -197,18 +196,6 @@ ip6_init(void)
|
||||
ip6_forward_rt_percpu = rtcache_percpu_alloc();
|
||||
}
|
||||
|
||||
static void
|
||||
ip6_init2(void)
|
||||
{
|
||||
|
||||
/* timer for regeneration of temporary addresses randomize ID */
|
||||
callout_init(&in6_tmpaddrtimer_ch, CALLOUT_MPSAFE);
|
||||
callout_reset(&in6_tmpaddrtimer_ch,
|
||||
(ip6_temp_preferred_lifetime - ip6_desync_factor -
|
||||
ip6_temp_regen_advance) * hz,
|
||||
in6_tmpaddrtimer, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* IP6 input interrupt handling. Just pass the packet to ip6_input.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user