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.237 retrieving revision 1.243 diff -u -p -r1.237 -r1.243 --- src/sys/netinet/ip_input.c 2006/12/06 00:38:16 1.237 +++ src/sys/netinet/ip_input.c 2007/02/17 22:34:11 1.243 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.237 2006/12/06 00:38:16 dyoung Exp $ */ +/* $NetBSD: ip_input.c,v 1.243 2007/02/17 22:34:11 dyoung Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -98,7 +98,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.237 2006/12/06 00:38:16 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.243 2007/02/17 22:34:11 dyoung Exp $"); #include "opt_inet.h" #include "opt_gateway.h" @@ -461,7 +461,7 @@ ipintr(void) int s; struct mbuf *m; - while (1) { + while (!IF_IS_EMPTY(&ipintrq)) { s = splnet(); IF_DEQUEUE(&ipintrq, m); splx(s); @@ -1675,24 +1675,23 @@ bad: struct in_ifaddr * ip_rtaddr(struct in_addr dst) { - struct sockaddr_in *sin; + if (!in_hosteq(dst, satocsin(rtcache_getdst(&ipforward_rt))->sin_addr)) + rtcache_free(&ipforward_rt); + else + rtcache_check(&ipforward_rt); - sin = satosin(&ipforward_rt.ro_dst); + if (ipforward_rt.ro_rt == NULL) { + struct sockaddr_in *sin = satosin(&ipforward_rt.ro_dst); - 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; - rtalloc(&ipforward_rt); + rtcache_init(&ipforward_rt); + if (ipforward_rt.ro_rt == NULL) + return NULL; } - if (ipforward_rt.ro_rt == 0) - return ((struct in_ifaddr *)0); - return (ifatoia(ipforward_rt.ro_rt->rt_ifa)); + return ifatoia(ipforward_rt.ro_rt->rt_ifa); } /* @@ -1839,7 +1838,6 @@ void ip_forward(struct mbuf *m, int srcrt) { struct ip *ip = mtod(m, struct ip *); - struct sockaddr_in *sin; struct rtentry *rt; int error, type = 0, code = 0, destmtu = 0; struct mbuf *mcopy; @@ -1872,24 +1870,25 @@ ip_forward(struct mbuf *m, int srcrt) return; } - sin = satosin(&ipforward_rt.ro_dst); - 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; - } + if (!in_hosteq(ip->ip_dst, + satocsin(rtcache_getdst(&ipforward_rt))->sin_addr)) + rtcache_free(&ipforward_rt); + else + rtcache_check(&ipforward_rt); + if (ipforward_rt.ro_rt == NULL) { + struct sockaddr_in *sin = satosin(&ipforward_rt.ro_dst); + sin->sin_family = AF_INET; - sin->sin_len = sizeof(struct sockaddr_in); + sin->sin_len = sizeof(*sin); sin->sin_addr = ip->ip_dst; - rtalloc(&ipforward_rt); - if (ipforward_rt.ro_rt == 0) { + rtcache_init(&ipforward_rt); + if (ipforward_rt.ro_rt == NULL) { 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 @@ -1935,7 +1934,7 @@ ip_forward(struct mbuf *m, int srcrt) } } - error = ip_output(m, (struct mbuf *)0, &ipforward_rt, + error = ip_output(m, NULL, &ipforward_rt, (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), (struct ip_moptions *)NULL, (struct socket *)NULL); @@ -1978,7 +1977,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) + if (ipforward_rt.ro_rt != NULL) destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu; #else /* @@ -1987,7 +1986,7 @@ ip_forward(struct mbuf *m, int srcrt) * tunnel MTU = if MTU - sizeof(IP) - ESP/AH hdrsiz * XXX quickhack!!! */ - if (ipforward_rt.ro_rt) { + if (ipforward_rt.ro_rt != NULL) { struct secpolicy *sp; int ipsecerror; size_t ipsechdr;