diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 419c417ce51a..52c6c328bf68 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $NetBSD: nd6.c,v 1.211 2016/11/14 02:34:19 ozaki-r Exp $ */ +/* $NetBSD: nd6.c,v 1.212 2016/12/11 07:37:53 ozaki-r Exp $ */ /* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.211 2016/11/14 02:34:19 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.212 2016/12/11 07:37:53 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -125,6 +125,11 @@ static struct work nd6_timer_wk; static int fill_drlist(void *, size_t *, size_t); static int fill_prlist(void *, size_t *, size_t); +static struct ifnet *nd6_defifp; +static int nd6_defifindex; + +static int nd6_setdefaultiface(int); + MALLOC_DEFINE(M_IP6NDP, "NDP", "IPv6 Neighbour Discovery"); void @@ -2780,3 +2785,32 @@ fill_prlist(void *oldp, size_t *oldlenp, size_t ol) return error; } + +static int +nd6_setdefaultiface(int ifindex) +{ + ifnet_t *ifp; + int error = 0; + int s; + + s = pserialize_read_enter(); + ifp = if_byindex(ifindex); + if (ifp == NULL) { + pserialize_read_exit(s); + return EINVAL; + } + if (nd6_defifindex != ifindex) { + nd6_defifindex = ifindex; + nd6_defifp = nd6_defifindex > 0 ? ifp : NULL; + + /* + * Our current implementation assumes one-to-one maping between + * interfaces and links, so it would be natural to use the + * default interface as the default link. + */ + scope6_setdefault(nd6_defifp); + } + pserialize_read_exit(s); + + return (error); +} diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index c4dc0c0ba940..c35d4d1a8ddd 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -1,4 +1,4 @@ -/* $NetBSD: nd6.h,v 1.74 2016/12/11 07:36:55 ozaki-r Exp $ */ +/* $NetBSD: nd6.h,v 1.75 2016/12/11 07:37:53 ozaki-r Exp $ */ /* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */ /* @@ -354,7 +354,6 @@ extern int nd6_debug; do { if (nd6_debug) log(level, "%s: " fmt, __func__, ##args);} while (0) /* nd6_rtr.c */ -extern int nd6_defifindex; extern int ip6_desync_factor; /* seconds */ extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */ extern u_int32_t ip6_temp_valid_lifetime; /* seconds */ @@ -441,7 +440,6 @@ void prelist_remove(struct nd_prefix *); void pfxlist_onlink_check(void); struct nd_defrouter *defrouter_lookup(const struct in6_addr *, struct ifnet *); void rt6_flush(struct in6_addr *, struct ifnet *); -int nd6_setdefaultiface(int); int in6_tmpifadd(const struct in6_ifaddr *, int, int); bool nd6_accepts_rtadv(const struct nd_ifinfo *); diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 59edd74f22f6..c2fd68fb1591 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $NetBSD: nd6_rtr.c,v 1.121 2016/12/11 07:36:55 ozaki-r Exp $ */ +/* $NetBSD: nd6_rtr.c,v 1.122 2016/12/11 07:37:53 ozaki-r Exp $ */ /* $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.121 2016/12/11 07:36:55 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.122 2016/12/11 07:37:53 ozaki-r Exp $"); #include #include @@ -92,9 +92,6 @@ static struct nd_prefix *nd6_prefix_lookup(struct nd_prefixctl *); extern int nd6_recalc_reachtm_interval; -static struct ifnet *nd6_defifp; -int nd6_defifindex; - int ip6_use_tempaddr = 0; int ip6_desync_factor; @@ -2203,32 +2200,3 @@ rt6_deleteroute_matcher(struct rtentry *rt, void *arg) return 1; } - -int -nd6_setdefaultiface(int ifindex) -{ - ifnet_t *ifp; - int error = 0; - int s; - - s = pserialize_read_enter(); - ifp = if_byindex(ifindex); - if (ifp == NULL) { - pserialize_read_exit(s); - return EINVAL; - } - if (nd6_defifindex != ifindex) { - nd6_defifindex = ifindex; - nd6_defifp = nd6_defifindex > 0 ? ifp : NULL; - - /* - * Our current implementation assumes one-to-one maping between - * interfaces and links, so it would be natural to use the - * default interface as the default link. - */ - scope6_setdefault(nd6_defifp); - } - pserialize_read_exit(s); - - return (error); -}