Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.271 retrieving revision 1.275.4.1.8.2 diff -u -p -r1.271 -r1.275.4.1.8.2 --- src/sys/netinet/ip_input.c 2008/05/04 07:22:14 1.271 +++ src/sys/netinet/ip_input.c 2011/01/07 03:17:44 1.275.4.1.8.2 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.271 2008/05/04 07:22:14 thorpej Exp $ */ +/* $NetBSD: ip_input.c,v 1.275.4.1.8.2 2011/01/07 03:17:44 matt Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.271 2008/05/04 07:22:14 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.275.4.1.8.2 2011/01/07 03:17:44 matt Exp $"); #include "opt_inet.h" #include "opt_gateway.h" @@ -330,10 +330,8 @@ do { \ #define IPQ_UNLOCK() ipq_unlock() -POOL_INIT(inmulti_pool, sizeof(struct in_multi), 0, 0, 0, "inmltpl", NULL, - IPL_SOFTNET); -POOL_INIT(ipqent_pool, sizeof(struct ipqent), 0, 0, 0, "ipqepl", NULL, - IPL_VM); +struct pool inmulti_pool; +struct pool ipqent_pool; #ifdef INET_CSUM_COUNTERS #include @@ -399,6 +397,11 @@ ip_init(void) const struct protosw *pr; int i; + pool_init(&inmulti_pool, sizeof(struct in_multi), 0, 0, 0, "inmltpl", + NULL, IPL_SOFTNET); + pool_init(&ipqent_pool, sizeof(struct ipqent), 0, 0, 0, "ipqepl", + NULL, IPL_VM); + pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW); if (pr == 0) panic("ip_init"); @@ -420,10 +423,10 @@ ip_init(void) ip_nmbclusters_changed(); TAILQ_INIT(&in_ifaddrhead); - in_ifaddrhashtbl = hashinit(IN_IFADDR_HASH_SIZE, HASH_LIST, M_IFADDR, - M_WAITOK, &in_ifaddrhash); - in_multihashtbl = hashinit(IN_IFADDR_HASH_SIZE, HASH_LIST, M_IPMADDR, - M_WAITOK, &in_multihash); + in_ifaddrhashtbl = hashinit(IN_IFADDR_HASH_SIZE, HASH_LIST, true, + &in_ifaddrhash); + in_multihashtbl = hashinit(IN_IFADDR_HASH_SIZE, HASH_LIST, true, + &in_multihash); ip_mtudisc_timeout_q = rt_timer_queue_create(ip_mtudisc_timeout); #ifdef GATEWAY ipflow_init(ip_hashsize); @@ -928,6 +931,7 @@ ours: */ if (ip->ip_tos != fp->ipq_tos) { IP_STATINC(IP_STAT_BADFRAGS); + IPQ_UNLOCK(); goto bad; } goto found; @@ -1967,9 +1971,11 @@ ip_forward(struct mbuf *m, int srcrt) type = ICMP_UNREACH; code = ICMP_UNREACH_NEEDFRAG; - if ((rt = rtcache_validate(&ipforward_rt)) != NULL) { + if ((rt = rtcache_validate(&ipforward_rt)) != NULL) + destmtu = rt->rt_ifp->if_mtu; #if defined(IPSEC) || defined(FAST_IPSEC) + { /* * If the packet is routed over IPsec tunnel, tell the * originator the tunnel MTU. @@ -1985,10 +1991,7 @@ ip_forward(struct mbuf *m, int srcrt) sp = ipsec4_getpolicybyaddr(mcopy, IPSEC_DIR_OUTBOUND, IP_FORWARDING, &ipsecerror); -#endif - destmtu = rt->rt_ifp->if_mtu; -#if defined(IPSEC) || defined(FAST_IPSEC) if (sp != NULL) { /* count IPsec header size */ ipsechdr = ipsec4_hdrsiz(mcopy, @@ -2003,6 +2006,7 @@ ip_forward(struct mbuf *m, int srcrt) && sp->req->sav != NULL && sp->req->sav->sah != NULL) { ro = &sp->req->sav->sah->sa_route; + rt = rtcache_validate(ro); if (rt && rt->rt_ifp) { destmtu = rt->rt_rmx.rmx_mtu ? @@ -2018,8 +2022,8 @@ ip_forward(struct mbuf *m, int srcrt) KEY_FREESP(&sp); #endif } -#endif /*defined(IPSEC) || defined(FAST_IPSEC)*/ } +#endif /*defined(IPSEC) || defined(FAST_IPSEC)*/ IP_STATINC(IP_STAT_CANTFRAG); break; @@ -2143,9 +2147,13 @@ sysctl_net_inet_ip_pmtudto(SYSCTLFN_ARGS if (tmp < 0) return (EINVAL); + mutex_enter(softnet_lock); + ip_mtudisc_timeout = tmp; rt_timer_queue_change(ip_mtudisc_timeout_q, ip_mtudisc_timeout); + mutex_exit(softnet_lock); + return (0); } @@ -2156,15 +2164,19 @@ sysctl_net_inet_ip_pmtudto(SYSCTLFN_ARGS static int sysctl_net_inet_ip_maxflows(SYSCTLFN_ARGS) { - int s; + int error; - s = sysctl_lookup(SYSCTLFN_CALL(rnode)); - if (s || newp == NULL) - return (s); + error = sysctl_lookup(SYSCTLFN_CALL(rnode)); + if (error || newp == NULL) + return (error); + + mutex_enter(softnet_lock); + KERNEL_LOCK(1, NULL); - s = splsoftnet(); ipflow_prune(); - splx(s); + + KERNEL_UNLOCK_ONE(NULL); + mutex_exit(softnet_lock); return (0); } @@ -2186,16 +2198,22 @@ sysctl_net_inet_ip_hashsize(SYSCTLFN_ARG /* * Can only fail due to malloc() */ - if (ipflow_invalidate_all(tmp)) - return ENOMEM; + mutex_enter(softnet_lock); + KERNEL_LOCK(1, NULL); + + error = ipflow_invalidate_all(tmp); + + KERNEL_UNLOCK_ONE(NULL); + mutex_exit(softnet_lock); + } else { /* * EINVAL if not a power of 2 */ - return EINVAL; + error = EINVAL; } - return (0); + return error; } #endif /* GATEWAY */