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 retrieving revision 1.229.2.3 retrieving revision 1.230 diff -u -p -r1.229.2.3 -r1.230 --- src/sys/netinet/ip_input.c 2007/02/01 08:48:43 1.229.2.3 +++ src/sys/netinet/ip_input.c 2006/09/08 20:58:58 1.230 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.229.2.3 2007/02/01 08:48:43 ad Exp $ */ +/* $NetBSD: ip_input.c,v 1.230 2006/09/08 20:58:58 elad Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -98,7 +98,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.229.2.3 2007/02/01 08:48:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.230 2006/09/08 20:58:58 elad Exp $"); #include "opt_inet.h" #include "opt_gateway.h" @@ -377,8 +377,8 @@ static struct ip_srcrt { static void save_rte(u_char *, struct in_addr); #ifdef MBUFTRACE -struct mowner ip_rx_mowner = MOWNER_INIT("internet", "rx"); -struct mowner ip_tx_mowner = MOWNER_INIT("internet", "tx"); +struct mowner ip_rx_mowner = { "internet", "rx" }; +struct mowner ip_tx_mowner = { "internet", "tx" }; #endif /* @@ -461,7 +461,7 @@ ipintr(void) int s; struct mbuf *m; - while (!IF_IS_EMPTY(&ipintrq)) { + while (1) { s = splnet(); IF_DEQUEUE(&ipintrq, m); splx(s); @@ -488,13 +488,12 @@ ip_input(struct mbuf *m) int downmatch; int checkif; int srcrt = 0; - int s; u_int hash; #ifdef FAST_IPSEC struct m_tag *mtag; struct tdb_ident *tdbi; struct secpolicy *sp; - int error; + int s, error; #endif /* FAST_IPSEC */ MCLAIM(m, &ip_rx_mowner); @@ -943,9 +942,7 @@ found: */ if (mff || ip->ip_off != htons(0)) { ipstat.ips_fragments++; - s = splvm(); ipqe = pool_get(&ipqent_pool, PR_NOWAIT); - splx(s); if (ipqe == NULL) { ipstat.ips_rcvmemdrop++; IPQ_UNLOCK(); @@ -1058,7 +1055,7 @@ ip_reass(struct ipqent *ipqe, struct ipq struct ip *ip; struct mbuf *t; int hlen = ipqe->ipqe_ip->ip_hl << 2; - int i, next, s; + int i, next; IPQ_LOCK_CHECK(); @@ -1163,9 +1160,7 @@ ip_reass(struct ipqent *ipqe, struct ipq nq = TAILQ_NEXT(q, ipqe_q); m_freem(q->ipqe_m); TAILQ_REMOVE(&fp->ipq_fragq, q, ipqe_q); - s = splvm(); pool_put(&ipqent_pool, q); - splx(s); fp->ipq_nfrags--; ip_nfrags--; } @@ -1206,15 +1201,11 @@ insert: m->m_next = 0; m_cat(m, t); nq = TAILQ_NEXT(q, ipqe_q); - s = splvm(); pool_put(&ipqent_pool, q); - splx(s); for (q = nq; q != NULL; q = nq) { t = q->ipqe_m; nq = TAILQ_NEXT(q, ipqe_q); - s = splvm(); pool_put(&ipqent_pool, q); - splx(s); m_cat(m, t); } ip_nfrags -= fp->ipq_nfrags; @@ -1249,9 +1240,7 @@ dropfrag: ip_nfrags--; ipstat.ips_fragdropped++; m_freem(m); - s = splvm(); pool_put(&ipqent_pool, ipqe); - splx(s); return (0); } @@ -1264,7 +1253,6 @@ ip_freef(struct ipq *fp) { struct ipqent *q, *p; u_int nfrags = 0; - int s; IPQ_LOCK_CHECK(); @@ -1273,9 +1261,7 @@ ip_freef(struct ipq *fp) m_freem(q->ipqe_m); nfrags++; TAILQ_REMOVE(&fp->ipq_fragq, q, ipqe_q); - s = splvm(); pool_put(&ipqent_pool, q); - splx(s); } if (nfrags != fp->ipq_nfrags) @@ -1679,20 +1665,20 @@ ip_rtaddr(struct in_addr dst) sin = satosin(&ipforward_rt.ro_dst); - if (!in_hosteq(dst, sin->sin_addr)) - rtcache_free(&ipforward_rt); - else - rtcache_check(&ipforward_rt); - if (ipforward_rt.ro_rt == NULL) { + if (ipforward_rt.ro_rt == 0 || !in_hosteq(dst, sin->sin_addr)) { + if (ipforward_rt.ro_rt) { + RTFREE(ipforward_rt.ro_rt); + ipforward_rt.ro_rt = 0; + } sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); sin->sin_addr = dst; - rtcache_init(&ipforward_rt); - if (ipforward_rt.ro_rt == NULL) - return NULL; + rtalloc(&ipforward_rt); } - return ifatoia(ipforward_rt.ro_rt->rt_ifa); + if (ipforward_rt.ro_rt == 0) + return ((struct in_ifaddr *)0); + return (ifatoia(ipforward_rt.ro_rt->rt_ifa)); } /* @@ -1728,10 +1714,10 @@ ip_srcroute(void) struct mbuf *m; if (ip_nhops == 0) - return NULL; + return ((struct mbuf *)0); m = m_get(M_DONTWAIT, MT_SOOPTS); if (m == 0) - return NULL; + return ((struct mbuf *)0); MCLAIM(m, &inetdomain.dom_mowner); #define OPTSIZ (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt)) @@ -1873,22 +1859,23 @@ ip_forward(struct mbuf *m, int srcrt) } sin = satosin(&ipforward_rt.ro_dst); - if (!in_hosteq(ip->ip_dst, sin->sin_addr)) - rtcache_free(&ipforward_rt); - else - rtcache_check(&ipforward_rt); - if (ipforward_rt.ro_rt == NULL) { + if ((rt = ipforward_rt.ro_rt) == 0 || + !in_hosteq(ip->ip_dst, sin->sin_addr)) { + if (ipforward_rt.ro_rt) { + RTFREE(ipforward_rt.ro_rt); + ipforward_rt.ro_rt = 0; + } sin->sin_family = AF_INET; - sin->sin_len = sizeof(*sin); + sin->sin_len = sizeof(struct sockaddr_in); sin->sin_addr = ip->ip_dst; - rtcache_init(&ipforward_rt); - if (ipforward_rt.ro_rt == NULL) { + rtalloc(&ipforward_rt); + if (ipforward_rt.ro_rt == 0) { icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0); return; } + rt = ipforward_rt.ro_rt; } - rt = ipforward_rt.ro_rt; /* * Save at most 68 bytes of the packet in case @@ -1934,7 +1921,7 @@ ip_forward(struct mbuf *m, int srcrt) } } - error = ip_output(m, NULL, &ipforward_rt, + error = ip_output(m, (struct mbuf *)0, &ipforward_rt, (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), (struct ip_moptions *)NULL, (struct socket *)NULL); @@ -1977,7 +1964,7 @@ ip_forward(struct mbuf *m, int srcrt) type = ICMP_UNREACH; code = ICMP_UNREACH_NEEDFRAG; #if !defined(IPSEC) && !defined(FAST_IPSEC) - if (ipforward_rt.ro_rt != NULL) + if (ipforward_rt.ro_rt) destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu; #else /* @@ -1986,7 +1973,7 @@ ip_forward(struct mbuf *m, int srcrt) * tunnel MTU = if MTU - sizeof(IP) - ESP/AH hdrsiz * XXX quickhack!!! */ - if (ipforward_rt.ro_rt != NULL) { + if (ipforward_rt.ro_rt) { struct secpolicy *sp; int ipsecerror; size_t ipsechdr; @@ -2126,7 +2113,7 @@ sysctl_net_inet_ip_forwsrcrt(SYSCTLFN_AR return (error); if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_FORWSRCRT, - 0, NULL, NULL, NULL)) + NULL, NULL, NULL, NULL) != KAUTH_RESULT_ALLOW) return (EPERM); ip_forwsrcrt = tmp;