| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ip_icmp.c,v 1.159 2017/02/17 04:32:10 ozaki-r Exp $ */ | | 1 | /* $NetBSD: ip_icmp.c,v 1.160 2017/03/06 07:31:15 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. |
| @@ -84,27 +84,27 @@ | | | @@ -84,27 +84,27 @@ |
84 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 84 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
85 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 85 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
86 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 86 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
87 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 87 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
88 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 88 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
89 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 89 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
90 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 90 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
91 | * SUCH DAMAGE. | | 91 | * SUCH DAMAGE. |
92 | * | | 92 | * |
93 | * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 | | 93 | * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 |
94 | */ | | 94 | */ |
95 | | | 95 | |
96 | #include <sys/cdefs.h> | | 96 | #include <sys/cdefs.h> |
97 | __KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.159 2017/02/17 04:32:10 ozaki-r Exp $"); | | 97 | __KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.160 2017/03/06 07:31:15 ozaki-r Exp $"); |
98 | | | 98 | |
99 | #ifdef _KERNEL_OPT | | 99 | #ifdef _KERNEL_OPT |
100 | #include "opt_ipsec.h" | | 100 | #include "opt_ipsec.h" |
101 | #endif | | 101 | #endif |
102 | | | 102 | |
103 | #include <sys/param.h> | | 103 | #include <sys/param.h> |
104 | #include <sys/systm.h> | | 104 | #include <sys/systm.h> |
105 | #include <sys/mbuf.h> | | 105 | #include <sys/mbuf.h> |
106 | #include <sys/protosw.h> | | 106 | #include <sys/protosw.h> |
107 | #include <sys/socket.h> | | 107 | #include <sys/socket.h> |
108 | #include <sys/socketvar.h> /* For softnet_lock */ | | 108 | #include <sys/socketvar.h> /* For softnet_lock */ |
109 | #include <sys/kmem.h> | | 109 | #include <sys/kmem.h> |
110 | #include <sys/time.h> | | 110 | #include <sys/time.h> |
| @@ -185,30 +185,27 @@ static void _icmp_input(struct mbuf *, i | | | @@ -185,30 +185,27 @@ static void _icmp_input(struct mbuf *, i |
185 | | | 185 | |
186 | void | | 186 | void |
187 | icmp_init(void) | | 187 | icmp_init(void) |
188 | { | | 188 | { |
189 | | | 189 | |
190 | sysctl_netinet_icmp_setup(NULL); | | 190 | sysctl_netinet_icmp_setup(NULL); |
191 | | | 191 | |
192 | mutex_init(&icmp_mtx, MUTEX_DEFAULT, IPL_NONE); | | 192 | mutex_init(&icmp_mtx, MUTEX_DEFAULT, IPL_NONE); |
193 | /* | | 193 | /* |
194 | * This is only useful if the user initializes redirtimeout to | | 194 | * This is only useful if the user initializes redirtimeout to |
195 | * something other than zero. | | 195 | * something other than zero. |
196 | */ | | 196 | */ |
197 | mutex_enter(&icmp_mtx); | | 197 | mutex_enter(&icmp_mtx); |
198 | if (icmp_redirtimeout != 0) { | | 198 | icmp_redirect_timeout_q = rt_timer_queue_create(icmp_redirtimeout); |
199 | icmp_redirect_timeout_q = | | | |
200 | rt_timer_queue_create(icmp_redirtimeout); | | | |
201 | } | | | |
202 | mutex_exit(&icmp_mtx); | | 199 | mutex_exit(&icmp_mtx); |
203 | | | 200 | |
204 | icmpstat_percpu = percpu_alloc(sizeof(uint64_t) * ICMP_NSTATS); | | 201 | icmpstat_percpu = percpu_alloc(sizeof(uint64_t) * ICMP_NSTATS); |
205 | icmp_wqinput = wqinput_create("icmp", _icmp_input); | | 202 | icmp_wqinput = wqinput_create("icmp", _icmp_input); |
206 | } | | 203 | } |
207 | | | 204 | |
208 | void | | 205 | void |
209 | icmp_mtudisc_lock(void) | | 206 | icmp_mtudisc_lock(void) |
210 | { | | 207 | { |
211 | | | 208 | |
212 | mutex_enter(&icmp_mtx); | | 209 | mutex_enter(&icmp_mtx); |
213 | } | | 210 | } |
214 | | | 211 | |
| @@ -1195,28 +1192,26 @@ icmp_mtudisc(struct icmp *icp, struct in | | | @@ -1195,28 +1192,26 @@ icmp_mtudisc(struct icmp *icp, struct in |
1195 | | | 1192 | |
1196 | error = rtrequest(RTM_ADD, dst, rt->rt_gateway, NULL, | | 1193 | error = rtrequest(RTM_ADD, dst, rt->rt_gateway, NULL, |
1197 | RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC, &nrt); | | 1194 | RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC, &nrt); |
1198 | if (error) { | | 1195 | if (error) { |
1199 | rt_unref(rt); | | 1196 | rt_unref(rt); |
1200 | return; | | 1197 | return; |
1201 | } | | 1198 | } |
1202 | nrt->rt_rmx = rt->rt_rmx; | | 1199 | nrt->rt_rmx = rt->rt_rmx; |
1203 | rt_unref(rt); | | 1200 | rt_unref(rt); |
1204 | rt = nrt; | | 1201 | rt = nrt; |
1205 | } | | 1202 | } |
1206 | | | 1203 | |
1207 | mutex_enter(&icmp_mtx); | | 1204 | mutex_enter(&icmp_mtx); |
1208 | if (ip_mtudisc_timeout_q == NULL) | | | |
1209 | ip_mtudisc_timeout_q = rt_timer_queue_create(ip_mtudisc_timeout); | | | |
1210 | error = rt_timer_add(rt, icmp_mtudisc_timeout, ip_mtudisc_timeout_q); | | 1205 | error = rt_timer_add(rt, icmp_mtudisc_timeout, ip_mtudisc_timeout_q); |
1211 | mutex_exit(&icmp_mtx); | | 1206 | mutex_exit(&icmp_mtx); |
1212 | if (error) { | | 1207 | if (error) { |
1213 | rt_unref(rt); | | 1208 | rt_unref(rt); |
1214 | return; | | 1209 | return; |
1215 | } | | 1210 | } |
1216 | | | 1211 | |
1217 | if (mtu == 0) { | | 1212 | if (mtu == 0) { |
1218 | int i = 0; | | 1213 | int i = 0; |
1219 | | | 1214 | |
1220 | mtu = ntohs(icp->icmp_ip.ip_len); | | 1215 | mtu = ntohs(icp->icmp_ip.ip_len); |
1221 | /* Some 4.2BSD-based routers incorrectly adjust the ip_len */ | | 1216 | /* Some 4.2BSD-based routers incorrectly adjust the ip_len */ |
1222 | if (mtu > rt->rt_rmx.rmx_mtu && rt->rt_rmx.rmx_mtu != 0) | | 1217 | if (mtu > rt->rt_rmx.rmx_mtu && rt->rt_rmx.rmx_mtu != 0) |