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.90.2.1.2.2 retrieving revision 1.95 diff -u -p -r1.90.2.1.2.2 -r1.95 --- src/sys/netinet6/ip6_input.c 2007/09/23 21:36:35 1.90.2.1.2.2 +++ src/sys/netinet6/ip6_input.c 2007/02/17 22:34:13 1.95 @@ -1,4 +1,4 @@ -/* $NetBSD: ip6_input.c,v 1.90.2.1.2.2 2007/09/23 21:36:35 wrstuden Exp $ */ +/* $NetBSD: ip6_input.c,v 1.95 2007/02/17 22:34:13 dyoung 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.90.2.1.2.2 2007/09/23 21:36:35 wrstuden Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.95 2007/02/17 22:34:13 dyoung Exp $"); #include "opt_inet.h" #include "opt_inet6.h" @@ -464,28 +464,26 @@ ip6_input(m) /* * Unicast check */ - 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)) + if (!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, + &((const struct sockaddr_in6 *)rtcache_getdst((const struct route *)&ip6_forward_rt))->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; - 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; - } + ip6stat.ip6s_forward_cachemiss++; - bzero(&ip6_forward_rt.ro_dst, sizeof(struct sockaddr_in6)); - dst6 = (struct sockaddr_in6 *)&ip6_forward_rt.ro_dst; + dst6 = &ip6_forward_rt.ro_dst; + memset(dst6, 0, sizeof(*dst6)); dst6->sin6_len = sizeof(struct sockaddr_in6); dst6->sin6_family = AF_INET6; dst6->sin6_addr = ip6->ip6_dst; - rtalloc((struct route *)&ip6_forward_rt); + rtcache_init((struct route *)&ip6_forward_rt); } #define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key)) @@ -499,7 +497,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 && + if (ip6_forward_rt.ro_rt != NULL && (ip6_forward_rt.ro_rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) == RTF_HOST && !(ip6_forward_rt.ro_rt->rt_flags & RTF_CLONED) && @@ -542,7 +540,8 @@ ip6_input(m) */ #if defined(NFAITH) && 0 < NFAITH if (ip6_keepfaith) { - if (ip6_forward_rt.ro_rt && ip6_forward_rt.ro_rt->rt_ifp && + if (ip6_forward_rt.ro_rt != NULL && + ip6_forward_rt.ro_rt->rt_ifp != NULL && ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_FAITH) { /* XXX do we need more sanity checks? */ ours = 1; @@ -560,9 +559,7 @@ ip6_input(m) * working right. */ struct ifaddr *ifa; - for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) continue; /* just for safety */ if (ifa->ifa_addr->sa_family != AF_INET6) @@ -802,6 +799,7 @@ ip6_input(m) /* XXX error stat??? */ error = EINVAL; DPRINTF(("ip6_input: no SP, packet discarded\n"));/*XXX*/ + goto bad; } splx(s); if (error) @@ -1300,7 +1298,8 @@ ip6_savecontrol(in6p, mp, ip6, m) void -ip6_notify_pmtu(struct in6pcb *in6p, struct sockaddr_in6 *dst, uint32_t *mtu) +ip6_notify_pmtu(struct in6pcb *in6p, const struct sockaddr_in6 *dst, + uint32_t *mtu) { struct socket *so; struct mbuf *m_mtu; @@ -1326,7 +1325,7 @@ ip6_notify_pmtu(struct in6pcb *in6p, str IPV6_PATHMTU, IPPROTO_IPV6)) == NULL) return; - if (sbappendaddr(&so->so_rcv, (struct sockaddr *)dst, NULL, m_mtu) + if (sbappendaddr(&so->so_rcv, (const struct sockaddr *)dst, NULL, m_mtu) == 0) { m_freem(m_mtu); /* XXX: should count statistics */ @@ -1593,31 +1592,6 @@ ip6_delaux(m) m_tag_delete(m, mtag); } -static int -sysctl_net_inet6_ip6_rht0(SYSCTLFN_ARGS) -{ - int error, tmp; - struct sysctlnode node; - - node = *rnode; - tmp = ip6_rht0; - node.sysctl_data = &tmp; - error = sysctl_lookup(SYSCTLFN_CALL(&node)); - if (error || newp == NULL) - return error; - - switch (tmp) { - case -1: /* disable processing */ - case 0: /* disable for host, enable for router */ - case 1: /* enable for all */ - break; - default: - return EINVAL; - } - ip6_rht0 = tmp; - return 0; -} - /* * System control for IP6 */ @@ -1901,11 +1875,4 @@ SYSCTL_SETUP(sysctl_net_inet6_ip6_setup, NULL, 0, &ip6_mcast_pmtu, 0, CTL_NET, PF_INET6, IPPROTO_IPV6, CTL_CREATE, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, - CTLTYPE_INT, "rht0", - SYSCTL_DESCR("Processing of routing header type 0 (IPv6)"), - sysctl_net_inet6_ip6_rht0, 0, &ip6_rht0, 0, - CTL_NET, PF_INET6, IPPROTO_IPV6, - CTL_CREATE, CTL_EOL); }