| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ip_input.c,v 1.274 2008/09/05 13:39:12 seanb Exp $ */ | | 1 | /* $NetBSD: ip_input.c,v 1.275 2008/10/04 00:09:34 pooka 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 | * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 | | 90 | * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 |
91 | */ | | 91 | */ |
92 | | | 92 | |
93 | #include <sys/cdefs.h> | | 93 | #include <sys/cdefs.h> |
94 | __KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.274 2008/09/05 13:39:12 seanb Exp $"); | | 94 | __KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.275 2008/10/04 00:09:34 pooka Exp $"); |
95 | | | 95 | |
96 | #include "opt_inet.h" | | 96 | #include "opt_inet.h" |
97 | #include "opt_gateway.h" | | 97 | #include "opt_gateway.h" |
98 | #include "opt_pfil_hooks.h" | | 98 | #include "opt_pfil_hooks.h" |
99 | #include "opt_ipsec.h" | | 99 | #include "opt_ipsec.h" |
100 | #include "opt_mrouting.h" | | 100 | #include "opt_mrouting.h" |
101 | #include "opt_mbuftrace.h" | | 101 | #include "opt_mbuftrace.h" |
102 | #include "opt_inet_csum.h" | | 102 | #include "opt_inet_csum.h" |
103 | | | 103 | |
104 | #include <sys/param.h> | | 104 | #include <sys/param.h> |
105 | #include <sys/systm.h> | | 105 | #include <sys/systm.h> |
106 | #include <sys/malloc.h> | | 106 | #include <sys/malloc.h> |
107 | #include <sys/mbuf.h> | | 107 | #include <sys/mbuf.h> |
| @@ -320,30 +320,28 @@ do { \ | | | @@ -320,30 +320,28 @@ do { \ |
320 | do { \ | | 320 | do { \ |
321 | if (ipq_locked == 0) { \ | | 321 | if (ipq_locked == 0) { \ |
322 | printf("%s:%d: ipq lock not held\n", __FILE__, __LINE__); \ | | 322 | printf("%s:%d: ipq lock not held\n", __FILE__, __LINE__); \ |
323 | panic("ipq lock check"); \ | | 323 | panic("ipq lock check"); \ |
324 | } \ | | 324 | } \ |
325 | } while (/*CONSTCOND*/ 0) | | 325 | } while (/*CONSTCOND*/ 0) |
326 | #else | | 326 | #else |
327 | #define IPQ_LOCK() (void) ipq_lock_try() | | 327 | #define IPQ_LOCK() (void) ipq_lock_try() |
328 | #define IPQ_LOCK_CHECK() /* nothing */ | | 328 | #define IPQ_LOCK_CHECK() /* nothing */ |
329 | #endif | | 329 | #endif |
330 | | | 330 | |
331 | #define IPQ_UNLOCK() ipq_unlock() | | 331 | #define IPQ_UNLOCK() ipq_unlock() |
332 | | | 332 | |
333 | POOL_INIT(inmulti_pool, sizeof(struct in_multi), 0, 0, 0, "inmltpl", NULL, | | 333 | struct pool inmulti_pool; |
334 | IPL_SOFTNET); | | 334 | struct pool ipqent_pool; |
335 | POOL_INIT(ipqent_pool, sizeof(struct ipqent), 0, 0, 0, "ipqepl", NULL, | | | |
336 | IPL_VM); | | | |
337 | | | 335 | |
338 | #ifdef INET_CSUM_COUNTERS | | 336 | #ifdef INET_CSUM_COUNTERS |
339 | #include <sys/device.h> | | 337 | #include <sys/device.h> |
340 | | | 338 | |
341 | struct evcnt ip_hwcsum_bad = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, | | 339 | struct evcnt ip_hwcsum_bad = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
342 | NULL, "inet", "hwcsum bad"); | | 340 | NULL, "inet", "hwcsum bad"); |
343 | struct evcnt ip_hwcsum_ok = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, | | 341 | struct evcnt ip_hwcsum_ok = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
344 | NULL, "inet", "hwcsum ok"); | | 342 | NULL, "inet", "hwcsum ok"); |
345 | struct evcnt ip_swcsum = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, | | 343 | struct evcnt ip_swcsum = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
346 | NULL, "inet", "swcsum"); | | 344 | NULL, "inet", "swcsum"); |
347 | | | 345 | |
348 | #define INET_CSUM_COUNTER_INCR(ev) (ev)->ev_count++ | | 346 | #define INET_CSUM_COUNTER_INCR(ev) (ev)->ev_count++ |
349 | | | 347 | |
| @@ -389,26 +387,31 @@ ip_nmbclusters_changed(void) | | | @@ -389,26 +387,31 @@ ip_nmbclusters_changed(void) |
389 | ip_nmbclusters = nmbclusters; | | 387 | ip_nmbclusters = nmbclusters; |
390 | } | | 388 | } |
391 | | | 389 | |
392 | /* | | 390 | /* |
393 | * IP initialization: fill in IP protocol switch table. | | 391 | * IP initialization: fill in IP protocol switch table. |
394 | * All protocols not implemented in kernel go to raw IP protocol handler. | | 392 | * All protocols not implemented in kernel go to raw IP protocol handler. |
395 | */ | | 393 | */ |
396 | void | | 394 | void |
397 | ip_init(void) | | 395 | ip_init(void) |
398 | { | | 396 | { |
399 | const struct protosw *pr; | | 397 | const struct protosw *pr; |
400 | int i; | | 398 | int i; |
401 | | | 399 | |
| | | 400 | pool_init(&inmulti_pool, sizeof(struct in_multi), 0, 0, 0, "inmltpl", |
| | | 401 | NULL, IPL_SOFTNET); |
| | | 402 | pool_init(&ipqent_pool, sizeof(struct ipqent), 0, 0, 0, "ipqepl", |
| | | 403 | NULL, IPL_VM); |
| | | 404 | |
402 | pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW); | | 405 | pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW); |
403 | if (pr == 0) | | 406 | if (pr == 0) |
404 | panic("ip_init"); | | 407 | panic("ip_init"); |
405 | for (i = 0; i < IPPROTO_MAX; i++) | | 408 | for (i = 0; i < IPPROTO_MAX; i++) |
406 | ip_protox[i] = pr - inetsw; | | 409 | ip_protox[i] = pr - inetsw; |
407 | for (pr = inetdomain.dom_protosw; | | 410 | for (pr = inetdomain.dom_protosw; |
408 | pr < inetdomain.dom_protoswNPROTOSW; pr++) | | 411 | pr < inetdomain.dom_protoswNPROTOSW; pr++) |
409 | if (pr->pr_domain->dom_family == PF_INET && | | 412 | if (pr->pr_domain->dom_family == PF_INET && |
410 | pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) | | 413 | pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) |
411 | ip_protox[pr->pr_protocol] = pr - inetsw; | | 414 | ip_protox[pr->pr_protocol] = pr - inetsw; |
412 | | | 415 | |
413 | for (i = 0; i < IPREASS_NHASH; i++) | | 416 | for (i = 0; i < IPREASS_NHASH; i++) |
414 | LIST_INIT(&ipq[i]); | | 417 | LIST_INIT(&ipq[i]); |