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/netinet6/ip6_input.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet6/ip6_input.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.78.2.2 retrieving revision 1.83.4.1 diff -u -p -r1.78.2.2 -r1.83.4.1 --- src/sys/netinet6/ip6_input.c 2006/12/30 20:50:38 1.78.2.2 +++ src/sys/netinet6/ip6_input.c 2006/05/24 15:50:45 1.83.4.1 @@ -1,4 +1,4 @@ -/* $NetBSD: ip6_input.c,v 1.78.2.2 2006/12/30 20:50:38 yamt Exp $ */ +/* $NetBSD: ip6_input.c,v 1.83.4.1 2006/05/24 15:50:45 tron Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.78.2.2 2006/12/30 20:50:38 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.83.4.1 2006/05/24 15:50:45 tron Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -189,7 +189,8 @@ ip6_init() } static void -ip6_init2(void *dummy) +ip6_init2(dummy) + void *dummy; { /* nd6_timer_init */ @@ -409,10 +410,6 @@ ip6_input(m) * dst are the loopback address and the receiving interface * is not loopback. */ - if (__predict_false( - m_makewritable(&m, 0, sizeof(struct ip6_hdr), M_DONTWAIT))) - goto bad; - ip6 = mtod(m, struct ip6_hdr *); if (in6_clearscope(&ip6->ip6_src) || in6_clearscope(&ip6->ip6_dst)) { ip6stat.ip6s_badscope++; /* XXX */ goto bad; @@ -450,18 +447,20 @@ ip6_input(m) /* * Unicast check */ - if (!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, + if (ip6_forward_rt.ro_rt != NULL && + (ip6_forward_rt.ro_rt->rt_flags & RTF_UP) != 0 && + IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &((struct sockaddr_in6 *)(&ip6_forward_rt.ro_dst))->sin6_addr)) - rtcache_free((struct route *)&ip6_forward_rt); - else - rtcache_check((struct route *)&ip6_forward_rt); - if (ip6_forward_rt.ro_rt != NULL) { - /* XXX Revalidated route is accounted wrongly. */ ip6stat.ip6s_forward_cachehit++; - } else { + else { struct sockaddr_in6 *dst6; - ip6stat.ip6s_forward_cachemiss++; + if (ip6_forward_rt.ro_rt) { + /* route is down or destination is different */ + ip6stat.ip6s_forward_cachemiss++; + RTFREE(ip6_forward_rt.ro_rt); + ip6_forward_rt.ro_rt = 0; + } bzero(&ip6_forward_rt.ro_dst, sizeof(struct sockaddr_in6)); dst6 = (struct sockaddr_in6 *)&ip6_forward_rt.ro_dst; @@ -469,7 +468,7 @@ ip6_input(m) dst6->sin6_family = AF_INET6; dst6->sin6_addr = ip6->ip6_dst; - rtcache_init((struct route *)&ip6_forward_rt); + rtalloc((struct route *)&ip6_forward_rt); } #define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key)) @@ -483,7 +482,7 @@ ip6_input(m) * But we think it's even useful in some situations, e.g. when using * a special daemon which wants to intercept the packet. */ - if (ip6_forward_rt.ro_rt != NULL && + if (ip6_forward_rt.ro_rt && (ip6_forward_rt.ro_rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) == RTF_HOST && !(ip6_forward_rt.ro_rt->rt_flags & RTF_CLONED) && @@ -526,8 +525,7 @@ ip6_input(m) */ #if defined(NFAITH) && 0 < NFAITH if (ip6_keepfaith) { - if (ip6_forward_rt.ro_rt != NULL && - ip6_forward_rt.ro_rt->rt_ifp != NULL && + if (ip6_forward_rt.ro_rt && ip6_forward_rt.ro_rt->rt_ifp && ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_FAITH) { /* XXX do we need more sanity checks? */ ours = 1; @@ -545,7 +543,9 @@ ip6_input(m) * working right. */ struct ifaddr *ifa; - TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) { + for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first; + ifa; + ifa = ifa->ifa_list.tqe_next) { if (ifa->ifa_addr == NULL) continue; /* just for safety */ if (ifa->ifa_addr->sa_family != AF_INET6)