| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: in.c,v 1.224 2018/04/06 09:19:16 ozaki-r Exp $ */ | | 1 | /* $NetBSD: in.c,v 1.225 2018/04/06 09:20:29 ozaki-r Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | | 4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -81,27 +81,27 @@ | | | @@ -81,27 +81,27 @@ |
81 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 81 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
82 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 82 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
83 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 83 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
84 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 84 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
85 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 85 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
86 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 86 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
87 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 87 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
88 | * SUCH DAMAGE. | | 88 | * SUCH DAMAGE. |
89 | * | | 89 | * |
90 | * @(#)in.c 8.4 (Berkeley) 1/9/95 | | 90 | * @(#)in.c 8.4 (Berkeley) 1/9/95 |
91 | */ | | 91 | */ |
92 | | | 92 | |
93 | #include <sys/cdefs.h> | | 93 | #include <sys/cdefs.h> |
94 | __KERNEL_RCSID(0, "$NetBSD: in.c,v 1.224 2018/04/06 09:19:16 ozaki-r Exp $"); | | 94 | __KERNEL_RCSID(0, "$NetBSD: in.c,v 1.225 2018/04/06 09:20:29 ozaki-r Exp $"); |
95 | | | 95 | |
96 | #include "arp.h" | | 96 | #include "arp.h" |
97 | | | 97 | |
98 | #ifdef _KERNEL_OPT | | 98 | #ifdef _KERNEL_OPT |
99 | #include "opt_inet.h" | | 99 | #include "opt_inet.h" |
100 | #include "opt_inet_conf.h" | | 100 | #include "opt_inet_conf.h" |
101 | #include "opt_mrouting.h" | | 101 | #include "opt_mrouting.h" |
102 | #include "opt_net_mpsafe.h" | | 102 | #include "opt_net_mpsafe.h" |
103 | #endif | | 103 | #endif |
104 | | | 104 | |
105 | #include <sys/param.h> | | 105 | #include <sys/param.h> |
106 | #include <sys/ioctl.h> | | 106 | #include <sys/ioctl.h> |
107 | #include <sys/errno.h> | | 107 | #include <sys/errno.h> |
| @@ -1136,30 +1136,32 @@ in_ifinit(struct ifnet *ifp, struct in_i | | | @@ -1136,30 +1136,32 @@ in_ifinit(struct ifnet *ifp, struct in_i |
1136 | !in_hosteq(ia->ia_addr.sin_addr, oldaddr.sin_addr); | | 1136 | !in_hosteq(ia->ia_addr.sin_addr, oldaddr.sin_addr); |
1137 | if (!scrub) | | 1137 | if (!scrub) |
1138 | scrub = oldaddr.sin_family != ia->ia_dstaddr.sin_family || | | 1138 | scrub = oldaddr.sin_family != ia->ia_dstaddr.sin_family || |
1139 | !in_hosteq(ia->ia_dstaddr.sin_addr, olddst.sin_addr); | | 1139 | !in_hosteq(ia->ia_dstaddr.sin_addr, olddst.sin_addr); |
1140 | | | 1140 | |
1141 | /* | | 1141 | /* |
1142 | * Configure address flags. | | 1142 | * Configure address flags. |
1143 | * We need to do this early because they maybe adjusted | | 1143 | * We need to do this early because they maybe adjusted |
1144 | * by if_addr_init depending on the address. | | 1144 | * by if_addr_init depending on the address. |
1145 | */ | | 1145 | */ |
1146 | if (ia->ia4_flags & IN_IFF_DUPLICATED) | | 1146 | if (ia->ia4_flags & IN_IFF_DUPLICATED) |
1147 | hostIsNew = 1; | | 1147 | hostIsNew = 1; |
1148 | ia->ia4_flags = 0; | | 1148 | ia->ia4_flags = 0; |
1149 | if (ifp->if_link_state == LINK_STATE_DOWN) | | 1149 | if (ip_dad_count > 0) { |
1150 | ia->ia4_flags |= IN_IFF_DETACHED; | | 1150 | if (ifp->if_link_state == LINK_STATE_DOWN) |
1151 | else if (hostIsNew && if_do_dad(ifp)) | | 1151 | ia->ia4_flags |= IN_IFF_DETACHED; |
1152 | ia->ia4_flags |= IN_IFF_TRYTENTATIVE; | | 1152 | else if (hostIsNew && if_do_dad(ifp)) |
| | | 1153 | ia->ia4_flags |= IN_IFF_TRYTENTATIVE; |
| | | 1154 | } |
1153 | | | 1155 | |
1154 | /* | | 1156 | /* |
1155 | * Give the interface a chance to initialize | | 1157 | * Give the interface a chance to initialize |
1156 | * if this is its first address, | | 1158 | * if this is its first address, |
1157 | * and to validate the address if necessary. | | 1159 | * and to validate the address if necessary. |
1158 | */ | | 1160 | */ |
1159 | s = splsoftnet(); | | 1161 | s = splsoftnet(); |
1160 | error = if_addr_init(ifp, &ia->ia_ifa, true); | | 1162 | error = if_addr_init(ifp, &ia->ia_ifa, true); |
1161 | splx(s); | | 1163 | splx(s); |
1162 | /* Now clear the try tentative flag, its job is done. */ | | 1164 | /* Now clear the try tentative flag, its job is done. */ |
1163 | ia->ia4_flags &= ~IN_IFF_TRYTENTATIVE; | | 1165 | ia->ia4_flags &= ~IN_IFF_TRYTENTATIVE; |
1164 | if (error != 0) { | | 1166 | if (error != 0) { |
1165 | ia->ia_addr = oldaddr; | | 1167 | ia->ia_addr = oldaddr; |