version 1.104, 2007/05/05 21:23:50 |
version 1.105, 2007/05/06 02:29:33 |
|
|
ip6_input(struct mbuf *m) |
ip6_input(struct mbuf *m) |
{ |
{ |
struct ip6_hdr *ip6; |
struct ip6_hdr *ip6; |
int off = sizeof(struct ip6_hdr), nest; |
int hit, off = sizeof(struct ip6_hdr), nest; |
u_int32_t plen; |
u_int32_t plen; |
u_int32_t rtalert = ~0; |
u_int32_t rtalert = ~0; |
int nxt, ours = 0, rh_present = 0; |
int nxt, ours = 0, rh_present = 0; |
struct ifnet *deliverifp = NULL; |
struct ifnet *deliverifp = NULL; |
int srcrt = 0; |
int srcrt = 0; |
const struct sockaddr_in6 *cdst; |
const struct rtentry *rt; |
|
union { |
|
struct sockaddr dst; |
|
struct sockaddr_in6 dst6; |
|
} u; |
#ifdef FAST_IPSEC |
#ifdef FAST_IPSEC |
struct m_tag *mtag; |
struct m_tag *mtag; |
struct tdb_ident *tdbi; |
struct tdb_ident *tdbi; |
Line 475 ip6_input(struct mbuf *m) |
|
Line 479 ip6_input(struct mbuf *m) |
|
goto hbhcheck; |
goto hbhcheck; |
} |
} |
|
|
cdst = satocsin6(rtcache_getdst(&ip6_forward_rt)); |
sockaddr_in6_init(&u.dst6, &ip6->ip6_dst, 0, 0, 0); |
|
|
/* |
/* |
* Unicast check |
* Unicast check |
*/ |
*/ |
if (cdst == NULL) |
rt = rtcache_lookup2(&ip6_forward_rt, &u.dst, 1, &hit); |
; |
if (hit) |
else if (!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &cdst->sin6_addr)) |
|
rtcache_free(&ip6_forward_rt); |
|
else |
|
rtcache_check(&ip6_forward_rt); |
|
if (ip6_forward_rt.ro_rt != NULL) { |
|
/* XXX Revalidated route is accounted wrongly. */ |
|
ip6stat.ip6s_forward_cachehit++; |
ip6stat.ip6s_forward_cachehit++; |
} else { |
else |
union { |
|
struct sockaddr dst; |
|
struct sockaddr_in6 dst6; |
|
} u; |
|
|
|
ip6stat.ip6s_forward_cachemiss++; |
ip6stat.ip6s_forward_cachemiss++; |
|
|
sockaddr_in6_init(&u.dst6, &ip6->ip6_dst, 0, 0, 0); |
|
rtcache_setdst(&ip6_forward_rt, &u.dst); |
|
|
|
rtcache_init(&ip6_forward_rt); |
|
} |
|
|
|
#define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key)) |
#define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key)) |
|
|
/* |
/* |
Line 513 ip6_input(struct mbuf *m) |
|
Line 501 ip6_input(struct mbuf *m) |
|
* But we think it's even useful in some situations, e.g. when using |
* But we think it's even useful in some situations, e.g. when using |
* a special daemon which wants to intercept the packet. |
* a special daemon which wants to intercept the packet. |
*/ |
*/ |
if (ip6_forward_rt.ro_rt != NULL && |
if (rt != NULL && |
(ip6_forward_rt.ro_rt->rt_flags & |
(rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) == RTF_HOST && |
(RTF_HOST|RTF_GATEWAY)) == RTF_HOST && |
!(rt->rt_flags & RTF_CLONED) && |
!(ip6_forward_rt.ro_rt->rt_flags & RTF_CLONED) && |
|
#if 0 |
#if 0 |
/* |
/* |
* The check below is redundant since the comparison of |
* The check below is redundant since the comparison of |
* the destination and the key of the rtentry has |
* the destination and the key of the rtentry has |
* already done through looking up the routing table. |
* already done through looking up the routing table. |
*/ |
*/ |
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, |
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &rt6_key(rt)->sin6_addr) && |
&rt6_key(ip6_forward_rt.ro_rt)->sin6_addr) && |
|
#endif |
#endif |
ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_LOOP) { |
rt->rt_ifp->if_type == IFT_LOOP) { |
struct in6_ifaddr *ia6 = |
struct in6_ifaddr *ia6 = (struct in6_ifaddr *)rt->rt_ifa; |
(struct in6_ifaddr *)ip6_forward_rt.ro_rt->rt_ifa; |
|
if (ia6->ia6_flags & IN6_IFF_ANYCAST) |
if (ia6->ia6_flags & IN6_IFF_ANYCAST) |
m->m_flags |= M_ANYCAST6; |
m->m_flags |= M_ANYCAST6; |
/* |
/* |
Line 556 ip6_input(struct mbuf *m) |
|
Line 541 ip6_input(struct mbuf *m) |
|
*/ |
*/ |
#if defined(NFAITH) && 0 < NFAITH |
#if defined(NFAITH) && 0 < NFAITH |
if (ip6_keepfaith) { |
if (ip6_keepfaith) { |
if (ip6_forward_rt.ro_rt != NULL && |
if (rt != NULL && rt->rt_ifp != NULL && |
ip6_forward_rt.ro_rt->rt_ifp != NULL && |
rt->rt_ifp->if_type == IFT_FAITH) { |
ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_FAITH) { |
|
/* XXX do we need more sanity checks? */ |
/* XXX do we need more sanity checks? */ |
ours = 1; |
ours = 1; |
deliverifp = ip6_forward_rt.ro_rt->rt_ifp; /* faith */ |
deliverifp = rt->rt_ifp; /* faith */ |
goto hbhcheck; |
goto hbhcheck; |
} |
} |
} |
} |