From 98adf04abdca2cc0685ed655b4939f0c139db564 Mon Sep 17 00:00:00 2001 From: mpi Date: Sat, 10 Jan 2015 11:43:37 +0000 Subject: [PATCH] Correct some comments and merge in6_if_up() into in6_ifattach() to reflect that IPv6 link-local addresses are no longer automagically configured the first time an interface is brought up. ok henning@, stsp@ --- sys/net/if.c | 11 ++++++----- sys/netinet6/in6.c | 32 ++------------------------------ sys/netinet6/in6.h | 3 +-- sys/netinet6/in6_ifattach.c | 25 ++++++++++++++++++++----- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 9b2f03588b7..28f73adb58a 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.310 2015/01/06 21:26:46 stsp Exp $ */ +/* $OpenBSD: if.c,v 1.311 2015/01/10 11:43:37 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1096,8 +1096,9 @@ if_up(struct ifnet *ifp) #endif rt_ifmsg(ifp); #ifdef INET6 - if (ifp == lo0ifp) /* lo0 is special - needs ::1 */ - in6_if_up(ifp); + /* Userland expects the kernel to set ::1 on lo0. */ + if (ifp == lo0ifp) + in6_ifattach(ifp); #endif #ifndef SMALL_KERNEL rt_if_track(ifp); @@ -1238,7 +1239,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) s = splsoftnet(); if (cmd == SIOCIFAFATTACH) { if (in6ifa_ifpforlinklocal(ifp, 0) == NULL) - in6_if_up(ifp); + in6_ifattach(ifp); } else in6_ifdetach(ifp); splx(s); @@ -1307,7 +1308,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) if (ISSET(ifr->ifr_flags, IFXF_AUTOCONF6)) { if (in6ifa_ifpforlinklocal(ifp, 0) == NULL) { s = splnet(); - in6_if_up(ifp); + in6_ifattach(ifp); splx(s); } } diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 75dcb416765..66b98b70260 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.148 2015/01/06 21:26:46 stsp Exp $ */ +/* $OpenBSD: in6.c,v 1.149 2015/01/10 11:43:37 mpi Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -478,7 +478,7 @@ in6_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp) */ s = splsoftnet(); if (in6ifa_ifpforlinklocal(ifp, 0) == NULL) - in6_if_up(ifp); + in6_ifattach(ifp); error = in6_update_ifa(ifp, ifra, ia6); splx(s); if (error != 0) @@ -2084,34 +2084,6 @@ in6_ifawithscope(struct ifnet *oifp, struct in6_addr *dst, u_int rdomain) return (ia6_best); } -/* - * perform DAD when interface becomes IFF_UP. - */ -void -in6_if_up(struct ifnet *ifp) -{ - struct ifaddr *ifa; - struct in6_ifaddr *ia6; - int dad_delay; /* delay ticks before DAD output */ - - /* - * special cases, like 6to4, are handled in in6_ifattach - */ - in6_ifattach(ifp); - - dad_delay = 0; - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { - if (ifa->ifa_addr->sa_family != AF_INET6) - continue; - ia6 = ifatoia6(ifa); - if (ia6->ia6_flags & IN6_IFF_TENTATIVE) - nd6_dad_start(ifa, &dad_delay); - } - - if (ifp->if_xflags & IFXF_AUTOCONF6) - nd6_rs_output_set_timo(ND6_RS_OUTPUT_QUICK_INTERVAL); -} - int in6if_do_dad(struct ifnet *ifp) { diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 02de60247e2..ec34e7f521e 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.h,v 1.77 2014/12/05 15:50:04 mpi Exp $ */ +/* $OpenBSD: in6.h,v 1.78 2015/01/10 11:43:37 mpi Exp $ */ /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */ /* @@ -430,7 +430,6 @@ void in6_proto_cksum_out(struct mbuf *, struct ifnet *); int in6_localaddr(struct in6_addr *); int in6_addrscope(struct in6_addr *); struct in6_ifaddr *in6_ifawithscope(struct ifnet *, struct in6_addr *, u_int); -void in6_if_up(struct ifnet *); void in6_get_rand_ifid(struct ifnet *, struct in6_addr *); int in6_mask2len(struct in6_addr *, u_char *); diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 52f779eace7..34619102df4 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_ifattach.c,v 1.80 2015/01/08 17:21:01 florian Exp $ */ +/* $OpenBSD: in6_ifattach.c,v 1.81 2015/01/10 11:43:37 mpi Exp $ */ /* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */ /* @@ -344,7 +344,6 @@ in6_ifattach_linklocal(struct ifnet *ifp, struct in6_addr *ifid) /* * Do not let in6_update_ifa() do DAD, since we need a random delay * before sending an NS at the first time the interface becomes up. - * Instead, in6_if_up() will start DAD with a proper random delay. */ ifra.ifra_flags |= IN6_IFF_NODAD; @@ -374,7 +373,7 @@ in6_ifattach_linklocal(struct ifnet *ifp, struct in6_addr *ifid) } /* - * Adjust ia6_flags so that in6_if_up will perform DAD. + * Adjust ia6_flags so that in6_ifattach() will perform DAD. * XXX: Some P2P interfaces seem not to send packets just after * becoming up, so we skip p2p interfaces for safety. */ @@ -546,8 +545,9 @@ in6_nigroup(struct ifnet *ifp, const char *name, int namelen, void in6_ifattach(struct ifnet *ifp) { + struct ifaddr *ifa; struct in6_ifaddr *ia6; - struct in6_addr in6; + int dad_delay; /* delay ticks before DAD output */ /* some of the interfaces are inherently not IPv6 capable */ switch (ifp->if_type) { @@ -585,7 +585,7 @@ in6_ifattach(struct ifnet *ifp) * XXX multiple loopback interface case. */ if ((ifp->if_flags & IFF_LOOPBACK) != 0) { - in6 = in6addr_loopback; + struct in6_addr in6 = in6addr_loopback; if (in6ifa_ifpwithaddr(ifp, &in6) == NULL) { if (in6_ifattach_loopback(ifp) != 0) return; @@ -605,6 +605,21 @@ in6_ifattach(struct ifnet *ifp) } } } + + /* + * perform DAD. + */ + dad_delay = 0; + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + if (ifa->ifa_addr->sa_family != AF_INET6) + continue; + ia6 = ifatoia6(ifa); + if (ia6->ia6_flags & IN6_IFF_TENTATIVE) + nd6_dad_start(ifa, &dad_delay); + } + + if (ifp->if_xflags & IFXF_AUTOCONF6) + nd6_rs_output_set_timo(ND6_RS_OUTPUT_QUICK_INTERVAL); } /* -- 2.20.1