version 1.86, 2006/05/07 16:02:40 |
version 1.88.8.3, 2006/12/18 11:42:23 |
|
|
} |
} |
|
|
static void |
static void |
ip6_init2(dummy) |
ip6_init2(void *dummy) |
void *dummy; |
|
{ |
{ |
|
|
/* nd6_timer_init */ |
/* nd6_timer_init */ |
|
|
* dst are the loopback address and the receiving interface |
* dst are the loopback address and the receiving interface |
* is not loopback. |
* 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)) { |
if (in6_clearscope(&ip6->ip6_src) || in6_clearscope(&ip6->ip6_dst)) { |
ip6stat.ip6s_badscope++; /* XXX */ |
ip6stat.ip6s_badscope++; /* XXX */ |
goto bad; |
goto bad; |
|
|
/* |
/* |
* Unicast check |
* Unicast check |
*/ |
*/ |
if (ip6_forward_rt.ro_rt != NULL && |
if (!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, |
(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)) |
&((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++; |
ip6stat.ip6s_forward_cachehit++; |
else { |
} else { |
struct sockaddr_in6 *dst6; |
struct sockaddr_in6 *dst6; |
|
|
if (ip6_forward_rt.ro_rt) { |
ip6stat.ip6s_forward_cachemiss++; |
/* 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)); |
bzero(&ip6_forward_rt.ro_dst, sizeof(struct sockaddr_in6)); |
dst6 = (struct sockaddr_in6 *)&ip6_forward_rt.ro_dst; |
dst6 = (struct sockaddr_in6 *)&ip6_forward_rt.ro_dst; |
|
|
dst6->sin6_family = AF_INET6; |
dst6->sin6_family = AF_INET6; |
dst6->sin6_addr = ip6->ip6_dst; |
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)) |
#define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key)) |
|
|
* 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 && |
if (ip6_forward_rt.ro_rt != NULL && |
(ip6_forward_rt.ro_rt->rt_flags & |
(ip6_forward_rt.ro_rt->rt_flags & |
(RTF_HOST|RTF_GATEWAY)) == RTF_HOST && |
(RTF_HOST|RTF_GATEWAY)) == RTF_HOST && |
!(ip6_forward_rt.ro_rt->rt_flags & RTF_CLONED) && |
!(ip6_forward_rt.ro_rt->rt_flags & RTF_CLONED) && |
|
|
*/ |
*/ |
#if defined(NFAITH) && 0 < NFAITH |
#if defined(NFAITH) && 0 < NFAITH |
if (ip6_keepfaith) { |
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) { |
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; |
|
|
* working right. |
* working right. |
*/ |
*/ |
struct ifaddr *ifa; |
struct ifaddr *ifa; |
for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first; |
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) { |
ifa; |
|
ifa = ifa->ifa_list.tqe_next) { |
|
if (ifa->ifa_addr == NULL) |
if (ifa->ifa_addr == NULL) |
continue; /* just for safety */ |
continue; /* just for safety */ |
if (ifa->ifa_addr->sa_family != AF_INET6) |
if (ifa->ifa_addr->sa_family != AF_INET6) |
Line 1048 ip6_savecontrol(in6p, mp, ip6, m) |
|
Line 1048 ip6_savecontrol(in6p, mp, ip6, m) |
|
mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
} |
} |
#endif |
#endif |
|
|
|
/* some OSes call this logic with IPv4 packet, for SO_TIMESTAMP */ |
|
if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) |
|
return; |
|
|
/* RFC 2292 sec. 5 */ |
/* RFC 2292 sec. 5 */ |
if ((in6p->in6p_flags & IN6P_PKTINFO) != 0) { |
if ((in6p->in6p_flags & IN6P_PKTINFO) != 0) { |
struct in6_pktinfo pi6; |
struct in6_pktinfo pi6; |