| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: in6.c,v 1.172 2014/07/01 05:49:19 rtr Exp $ */ | | 1 | /* $NetBSD: in6.c,v 1.173 2014/07/01 07:51:29 ozaki-r Exp $ */ |
2 | /* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */ | | 2 | /* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | | 5 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -52,27 +52,27 @@ | | | @@ -52,27 +52,27 @@ |
52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
59 | * SUCH DAMAGE. | | 59 | * SUCH DAMAGE. |
60 | * | | 60 | * |
61 | * @(#)in.c 8.2 (Berkeley) 11/15/93 | | 61 | * @(#)in.c 8.2 (Berkeley) 11/15/93 |
62 | */ | | 62 | */ |
63 | | | 63 | |
64 | #include <sys/cdefs.h> | | 64 | #include <sys/cdefs.h> |
65 | __KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.172 2014/07/01 05:49:19 rtr Exp $"); | | 65 | __KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.173 2014/07/01 07:51:29 ozaki-r Exp $"); |
66 | | | 66 | |
67 | #include "opt_inet.h" | | 67 | #include "opt_inet.h" |
68 | #include "opt_compat_netbsd.h" | | 68 | #include "opt_compat_netbsd.h" |
69 | | | 69 | |
70 | #include <sys/param.h> | | 70 | #include <sys/param.h> |
71 | #include <sys/ioctl.h> | | 71 | #include <sys/ioctl.h> |
72 | #include <sys/errno.h> | | 72 | #include <sys/errno.h> |
73 | #include <sys/malloc.h> | | 73 | #include <sys/malloc.h> |
74 | #include <sys/socket.h> | | 74 | #include <sys/socket.h> |
75 | #include <sys/socketvar.h> | | 75 | #include <sys/socketvar.h> |
76 | #include <sys/sockio.h> | | 76 | #include <sys/sockio.h> |
77 | #include <sys/systm.h> | | 77 | #include <sys/systm.h> |
78 | #include <sys/proc.h> | | 78 | #include <sys/proc.h> |
| @@ -1321,27 +1321,28 @@ in6_update_ifa1(struct ifnet *ifp, struc | | | @@ -1321,27 +1321,28 @@ in6_update_ifa1(struct ifnet *ifp, struc |
1321 | if (in6m_sol != NULL && | | 1321 | if (in6m_sol != NULL && |
1322 | in6m_sol->in6m_state == MLD_REPORTPENDING) { | | 1322 | in6m_sol->in6m_state == MLD_REPORTPENDING) { |
1323 | mindelay = in6m_sol->in6m_timer; | | 1323 | mindelay = in6m_sol->in6m_timer; |
1324 | } | | 1324 | } |
1325 | maxdelay = MAX_RTR_SOLICITATION_DELAY * hz; | | 1325 | maxdelay = MAX_RTR_SOLICITATION_DELAY * hz; |
1326 | if (maxdelay - mindelay == 0) | | 1326 | if (maxdelay - mindelay == 0) |
1327 | dad_delay = 0; | | 1327 | dad_delay = 0; |
1328 | else { | | 1328 | else { |
1329 | dad_delay = | | 1329 | dad_delay = |
1330 | (cprng_fast32() % (maxdelay - mindelay)) + | | 1330 | (cprng_fast32() % (maxdelay - mindelay)) + |
1331 | mindelay; | | 1331 | mindelay; |
1332 | } | | 1332 | } |
1333 | } | | 1333 | } |
1334 | nd6_dad_start(&ia->ia_ifa, dad_delay); | | 1334 | /* +1 ensures callout is always used */ |
| | | 1335 | nd6_dad_start(&ia->ia_ifa, dad_delay + 1); |
1335 | } | | 1336 | } |
1336 | | | 1337 | |
1337 | return error; | | 1338 | return error; |
1338 | | | 1339 | |
1339 | unlink: | | 1340 | unlink: |
1340 | /* | | 1341 | /* |
1341 | * XXX: if a change of an existing address failed, keep the entry | | 1342 | * XXX: if a change of an existing address failed, keep the entry |
1342 | * anyway. | | 1343 | * anyway. |
1343 | */ | | 1344 | */ |
1344 | if (hostIsNew) | | 1345 | if (hostIsNew) |
1345 | in6_unlink_ifa(ia, ifp); | | 1346 | in6_unlink_ifa(ia, ifp); |
1346 | return error; | | 1347 | return error; |
1347 | | | 1348 | |
| @@ -2145,35 +2146,37 @@ in6_if_link_up(struct ifnet *ifp) | | | @@ -2145,35 +2146,37 @@ in6_if_link_up(struct ifnet *ifp) |
2145 | /* If detached then mark as tentative */ | | 2146 | /* If detached then mark as tentative */ |
2146 | if (ia->ia6_flags & IN6_IFF_DETACHED) { | | 2147 | if (ia->ia6_flags & IN6_IFF_DETACHED) { |
2147 | ia->ia6_flags &= ~IN6_IFF_DETACHED; | | 2148 | ia->ia6_flags &= ~IN6_IFF_DETACHED; |
2148 | if (in6if_do_dad(ifp)) { | | 2149 | if (in6if_do_dad(ifp)) { |
2149 | ia->ia6_flags |= IN6_IFF_TENTATIVE; | | 2150 | ia->ia6_flags |= IN6_IFF_TENTATIVE; |
2150 | nd6log((LOG_ERR, "in6_if_up: " | | 2151 | nd6log((LOG_ERR, "in6_if_up: " |
2151 | "%s marked tentative\n", | | 2152 | "%s marked tentative\n", |
2152 | ip6_sprintf(&ia->ia_addr.sin6_addr))); | | 2153 | ip6_sprintf(&ia->ia_addr.sin6_addr))); |
2153 | } else if ((ia->ia6_flags & IN6_IFF_TENTATIVE) == 0) | | 2154 | } else if ((ia->ia6_flags & IN6_IFF_TENTATIVE) == 0) |
2154 | nd6_newaddrmsg(ifa); | | 2155 | nd6_newaddrmsg(ifa); |
2155 | } | | 2156 | } |
2156 | | | 2157 | |
2157 | if (ia->ia6_flags & IN6_IFF_TENTATIVE) { | | 2158 | if (ia->ia6_flags & IN6_IFF_TENTATIVE) { |
| | | 2159 | int delay; |
2158 | /* | | 2160 | /* |
2159 | * The TENTATIVE flag was likely set by hand | | 2161 | * The TENTATIVE flag was likely set by hand |
2160 | * beforehand, implicitly indicating the need for DAD. | | 2162 | * beforehand, implicitly indicating the need for DAD. |
2161 | * We may be able to skip the random delay in this | | 2163 | * We may be able to skip the random delay in this |
2162 | * case, but we impose delays just in case. | | 2164 | * case, but we impose delays just in case. |
2163 | */ | | 2165 | */ |
2164 | nd6_dad_start(ifa, | | 2166 | delay = cprng_fast32() % |
2165 | cprng_fast32() % | | 2167 | (MAX_RTR_SOLICITATION_DELAY * hz); |
2166 | (MAX_RTR_SOLICITATION_DELAY * hz)); | | 2168 | /* +1 ensures callout is always used */ |
| | | 2169 | nd6_dad_start(ifa, delay + 1); |
2167 | } | | 2170 | } |
2168 | } | | 2171 | } |
2169 | | | 2172 | |
2170 | /* Restore any detached prefixes */ | | 2173 | /* Restore any detached prefixes */ |
2171 | pfxlist_onlink_check(); | | 2174 | pfxlist_onlink_check(); |
2172 | } | | 2175 | } |
2173 | | | 2176 | |
2174 | void | | 2177 | void |
2175 | in6_if_up(struct ifnet *ifp) | | 2178 | in6_if_up(struct ifnet *ifp) |
2176 | { | | 2179 | { |
2177 | | | 2180 | |
2178 | /* | | 2181 | /* |
2179 | * special cases, like 6to4, are handled in in6_ifattach | | 2182 | * special cases, like 6to4, are handled in in6_ifattach |