| version 1.94.2.1, 2007/02/27 16:55:03 |
version 1.94.2.2, 2007/03/12 05:59:57 |
|
|
| ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR; |
ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR; |
| |
|
| ip6_init2((void *)0); |
ip6_init2((void *)0); |
| |
#ifdef GATEWAY |
| |
ip6flow_init(); |
| |
#endif |
| |
|
| #ifdef PFIL_HOOKS |
#ifdef PFIL_HOOKS |
| /* Register our Packet Filter hook. */ |
/* Register our Packet Filter hook. */ |
| Line 298 ip6_input(struct mbuf *m) |
|
| Line 301 ip6_input(struct mbuf *m) |
|
| * it. Otherwise, if it is aligned, make sure the entire base |
* it. Otherwise, if it is aligned, make sure the entire base |
| * IPv6 header is in the first mbuf of the chain. |
* IPv6 header is in the first mbuf of the chain. |
| */ |
*/ |
| if (IP6_HDR_ALIGNED_P(mtod(m, caddr_t)) == 0) { |
if (IP6_HDR_ALIGNED_P(mtod(m, void *)) == 0) { |
| struct ifnet *inifp = m->m_pkthdr.rcvif; |
struct ifnet *inifp = m->m_pkthdr.rcvif; |
| if ((m = m_copyup(m, sizeof(struct ip6_hdr), |
if ((m = m_copyup(m, sizeof(struct ip6_hdr), |
| (max_linkhdr + 3) & ~3)) == NULL) { |
(max_linkhdr + 3) & ~3)) == NULL) { |
| Line 324 ip6_input(struct mbuf *m) |
|
| Line 327 ip6_input(struct mbuf *m) |
|
| goto bad; |
goto bad; |
| } |
} |
| |
|
| |
#if defined(IPSEC) |
| |
/* IPv6 fast forwarding is not compatible with IPsec. */ |
| |
m->m_flags &= ~M_CANFASTFWD; |
| |
#else |
| |
/* |
| |
* Assume that we can create a fast-forward IP flow entry |
| |
* based on this packet. |
| |
*/ |
| |
m->m_flags |= M_CANFASTFWD; |
| |
#endif |
| |
|
| #ifdef PFIL_HOOKS |
#ifdef PFIL_HOOKS |
| /* |
/* |
| * Run through list of hooks for input packets. If there are any |
* Run through list of hooks for input packets. If there are any |
| Line 639 ip6_input(struct mbuf *m) |
|
| Line 653 ip6_input(struct mbuf *m) |
|
| in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr); |
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr); |
| icmp6_error(m, ICMP6_PARAM_PROB, |
icmp6_error(m, ICMP6_PARAM_PROB, |
| ICMP6_PARAMPROB_HEADER, |
ICMP6_PARAMPROB_HEADER, |
| (caddr_t)&ip6->ip6_plen - (caddr_t)ip6); |
(char *)&ip6->ip6_plen - (char *)ip6); |
| return; |
return; |
| } |
} |
| IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr), |
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr), |
| Line 936 ip6_process_hopopts(m, opthead, hbhlen, |
|
| Line 950 ip6_process_hopopts(m, opthead, hbhlen, |
|
| return (-1); |
return (-1); |
| } |
} |
| optlen = IP6OPT_RTALERT_LEN; |
optlen = IP6OPT_RTALERT_LEN; |
| bcopy((caddr_t)(opt + 2), (caddr_t)&rtalert_val, 2); |
bcopy((void *)(opt + 2), (void *)&rtalert_val, 2); |
| *rtalertp = ntohs(rtalert_val); |
*rtalertp = ntohs(rtalert_val); |
| break; |
break; |
| case IP6OPT_JUMBO: |
case IP6OPT_JUMBO: |
| Line 1095 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1109 ip6_savecontrol(in6p, mp, ip6, m) |
|
| struct timeval tv; |
struct timeval tv; |
| |
|
| microtime(&tv); |
microtime(&tv); |
| *mp = sbcreatecontrol((caddr_t) &tv, sizeof(tv), |
*mp = sbcreatecontrol((void *) &tv, sizeof(tv), |
| SCM_TIMESTAMP, SOL_SOCKET); |
SCM_TIMESTAMP, SOL_SOCKET); |
| if (*mp) |
if (*mp) |
| mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
| Line 1114 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1128 ip6_savecontrol(in6p, mp, ip6, m) |
|
| in6_clearscope(&pi6.ipi6_addr); /* XXX */ |
in6_clearscope(&pi6.ipi6_addr); /* XXX */ |
| pi6.ipi6_ifindex = m->m_pkthdr.rcvif ? |
pi6.ipi6_ifindex = m->m_pkthdr.rcvif ? |
| m->m_pkthdr.rcvif->if_index : 0; |
m->m_pkthdr.rcvif->if_index : 0; |
| *mp = sbcreatecontrol((caddr_t) &pi6, |
*mp = sbcreatecontrol((void *) &pi6, |
| sizeof(struct in6_pktinfo), |
sizeof(struct in6_pktinfo), |
| IS2292(IPV6_2292PKTINFO, IPV6_PKTINFO), IPPROTO_IPV6); |
IS2292(IPV6_2292PKTINFO, IPV6_PKTINFO), IPPROTO_IPV6); |
| if (*mp) |
if (*mp) |
| Line 1124 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1138 ip6_savecontrol(in6p, mp, ip6, m) |
|
| if (in6p->in6p_flags & IN6P_HOPLIMIT) { |
if (in6p->in6p_flags & IN6P_HOPLIMIT) { |
| int hlim = ip6->ip6_hlim & 0xff; |
int hlim = ip6->ip6_hlim & 0xff; |
| |
|
| *mp = sbcreatecontrol((caddr_t) &hlim, sizeof(int), |
*mp = sbcreatecontrol((void *) &hlim, sizeof(int), |
| IS2292(IPV6_2292HOPLIMIT, IPV6_HOPLIMIT), IPPROTO_IPV6); |
IS2292(IPV6_2292HOPLIMIT, IPV6_HOPLIMIT), IPPROTO_IPV6); |
| if (*mp) |
if (*mp) |
| mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
| Line 1138 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1152 ip6_savecontrol(in6p, mp, ip6, m) |
|
| flowinfo >>= 20; |
flowinfo >>= 20; |
| |
|
| tclass = flowinfo & 0xff; |
tclass = flowinfo & 0xff; |
| *mp = sbcreatecontrol((caddr_t)&tclass, sizeof(tclass), |
*mp = sbcreatecontrol((void *)&tclass, sizeof(tclass), |
| IPV6_TCLASS, IPPROTO_IPV6); |
IPV6_TCLASS, IPPROTO_IPV6); |
| |
|
| if (*mp) |
if (*mp) |
| Line 1186 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1200 ip6_savecontrol(in6p, mp, ip6, m) |
|
| * be removed before returning in the RFC 2292. |
* be removed before returning in the RFC 2292. |
| * Note: this constraint is removed in RFC3542. |
* Note: this constraint is removed in RFC3542. |
| */ |
*/ |
| *mp = sbcreatecontrol((caddr_t)hbh, hbhlen, |
*mp = sbcreatecontrol((void *)hbh, hbhlen, |
| IS2292(IPV6_2292HOPOPTS, IPV6_HOPOPTS), |
IS2292(IPV6_2292HOPOPTS, IPV6_HOPOPTS), |
| IPPROTO_IPV6); |
IPPROTO_IPV6); |
| if (*mp) |
if (*mp) |
| Line 1248 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1262 ip6_savecontrol(in6p, mp, ip6, m) |
|
| if (!in6p->in6p_flags & IN6P_DSTOPTS) |
if (!in6p->in6p_flags & IN6P_DSTOPTS) |
| break; |
break; |
| |
|
| *mp = sbcreatecontrol((caddr_t)ip6e, elen, |
*mp = sbcreatecontrol((void *)ip6e, elen, |
| IS2292(IPV6_2292DSTOPTS, IPV6_DSTOPTS), |
IS2292(IPV6_2292DSTOPTS, IPV6_DSTOPTS), |
| IPPROTO_IPV6); |
IPPROTO_IPV6); |
| if (*mp) |
if (*mp) |
| Line 1259 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1273 ip6_savecontrol(in6p, mp, ip6, m) |
|
| if (!in6p->in6p_flags & IN6P_RTHDR) |
if (!in6p->in6p_flags & IN6P_RTHDR) |
| break; |
break; |
| |
|
| *mp = sbcreatecontrol((caddr_t)ip6e, elen, |
*mp = sbcreatecontrol((void *)ip6e, elen, |
| IS2292(IPV6_2292RTHDR, IPV6_RTHDR), |
IS2292(IPV6_2292RTHDR, IPV6_RTHDR), |
| IPPROTO_IPV6); |
IPPROTO_IPV6); |
| if (*mp) |
if (*mp) |
| Line 1320 ip6_notify_pmtu(struct in6pcb *in6p, con |
|
| Line 1334 ip6_notify_pmtu(struct in6pcb *in6p, con |
|
| if (sa6_recoverscope(&mtuctl.ip6m_addr)) |
if (sa6_recoverscope(&mtuctl.ip6m_addr)) |
| return; |
return; |
| |
|
| if ((m_mtu = sbcreatecontrol((caddr_t)&mtuctl, sizeof(mtuctl), |
if ((m_mtu = sbcreatecontrol((void *)&mtuctl, sizeof(mtuctl), |
| IPV6_PATHMTU, IPPROTO_IPV6)) == NULL) |
IPV6_PATHMTU, IPPROTO_IPV6)) == NULL) |
| return; |
return; |
| |
|
| Line 1360 ip6_pullexthdr(m, off, nxt) |
|
| Line 1374 ip6_pullexthdr(m, off, nxt) |
|
| } |
} |
| #endif |
#endif |
| |
|
| m_copydata(m, off, sizeof(ip6e), (caddr_t)&ip6e); |
m_copydata(m, off, sizeof(ip6e), (void *)&ip6e); |
| if (nxt == IPPROTO_AH) |
if (nxt == IPPROTO_AH) |
| elen = (ip6e.ip6e_len + 2) << 2; |
elen = (ip6e.ip6e_len + 2) << 2; |
| else |
else |
| Line 1383 ip6_pullexthdr(m, off, nxt) |
|
| Line 1397 ip6_pullexthdr(m, off, nxt) |
|
| return NULL; |
return NULL; |
| } |
} |
| |
|
| m_copydata(m, off, elen, mtod(n, caddr_t)); |
m_copydata(m, off, elen, mtod(n, void *)); |
| n->m_len = elen; |
n->m_len = elen; |
| return n; |
return n; |
| } |
} |
| Line 1416 ip6_get_prevhdr(m, off) |
|
| Line 1430 ip6_get_prevhdr(m, off) |
|
| nxt = ip6->ip6_nxt; |
nxt = ip6->ip6_nxt; |
| len = sizeof(struct ip6_hdr); |
len = sizeof(struct ip6_hdr); |
| while (len < off) { |
while (len < off) { |
| ip6e = (struct ip6_ext *)(mtod(m, caddr_t) + len); |
ip6e = (struct ip6_ext *)(mtod(m, char *) + len); |
| |
|
| switch (nxt) { |
switch (nxt) { |
| case IPPROTO_FRAGMENT: |
case IPPROTO_FRAGMENT: |
| Line 1465 ip6_nexthdr(m, off, proto, nxtp) |
|
| Line 1479 ip6_nexthdr(m, off, proto, nxtp) |
|
| return -1; |
return -1; |
| if (m->m_pkthdr.len < off + sizeof(ip6)) |
if (m->m_pkthdr.len < off + sizeof(ip6)) |
| return -1; |
return -1; |
| m_copydata(m, off, sizeof(ip6), (caddr_t)&ip6); |
m_copydata(m, off, sizeof(ip6), (void *)&ip6); |
| if (nxtp) |
if (nxtp) |
| *nxtp = ip6.ip6_nxt; |
*nxtp = ip6.ip6_nxt; |
| off += sizeof(ip6); |
off += sizeof(ip6); |
| Line 1478 ip6_nexthdr(m, off, proto, nxtp) |
|
| Line 1492 ip6_nexthdr(m, off, proto, nxtp) |
|
| */ |
*/ |
| if (m->m_pkthdr.len < off + sizeof(fh)) |
if (m->m_pkthdr.len < off + sizeof(fh)) |
| return -1; |
return -1; |
| m_copydata(m, off, sizeof(fh), (caddr_t)&fh); |
m_copydata(m, off, sizeof(fh), (void *)&fh); |
| if ((fh.ip6f_offlg & IP6F_OFF_MASK) != 0) |
if ((fh.ip6f_offlg & IP6F_OFF_MASK) != 0) |
| return -1; |
return -1; |
| if (nxtp) |
if (nxtp) |
| Line 1489 ip6_nexthdr(m, off, proto, nxtp) |
|
| Line 1503 ip6_nexthdr(m, off, proto, nxtp) |
|
| case IPPROTO_AH: |
case IPPROTO_AH: |
| if (m->m_pkthdr.len < off + sizeof(ip6e)) |
if (m->m_pkthdr.len < off + sizeof(ip6e)) |
| return -1; |
return -1; |
| m_copydata(m, off, sizeof(ip6e), (caddr_t)&ip6e); |
m_copydata(m, off, sizeof(ip6e), (void *)&ip6e); |
| if (nxtp) |
if (nxtp) |
| *nxtp = ip6e.ip6e_nxt; |
*nxtp = ip6e.ip6e_nxt; |
| off += (ip6e.ip6e_len + 2) << 2; |
off += (ip6e.ip6e_len + 2) << 2; |
| Line 1502 ip6_nexthdr(m, off, proto, nxtp) |
|
| Line 1516 ip6_nexthdr(m, off, proto, nxtp) |
|
| case IPPROTO_DSTOPTS: |
case IPPROTO_DSTOPTS: |
| if (m->m_pkthdr.len < off + sizeof(ip6e)) |
if (m->m_pkthdr.len < off + sizeof(ip6e)) |
| return -1; |
return -1; |
| m_copydata(m, off, sizeof(ip6e), (caddr_t)&ip6e); |
m_copydata(m, off, sizeof(ip6e), (void *)&ip6e); |
| if (nxtp) |
if (nxtp) |
| *nxtp = ip6e.ip6e_nxt; |
*nxtp = ip6e.ip6e_nxt; |
| off += (ip6e.ip6e_len + 1) << 3; |
off += (ip6e.ip6e_len + 1) << 3; |
|
|
| m_tag_delete(m, mtag); |
m_tag_delete(m, mtag); |
| } |
} |
| |
|
| |
#ifdef GATEWAY |
| |
/* |
| |
* sysctl helper routine for net.inet.ip6.maxflows. Since |
| |
* we could reduce this value, call ip6flow_reap(); |
| |
*/ |
| |
static int |
| |
sysctl_net_inet_ip6_maxflows(SYSCTLFN_ARGS) |
| |
{ |
| |
int s; |
| |
|
| |
s = sysctl_lookup(SYSCTLFN_CALL(rnode)); |
| |
if (s) |
| |
return (s); |
| |
|
| |
s = splsoftnet(); |
| |
ip6flow_reap(0); |
| |
splx(s); |
| |
|
| |
return (0); |
| |
} |
| |
#endif /* GATEWAY */ |
| |
|
| /* |
/* |
| * System control for IP6 |
* System control for IP6 |
| */ |
*/ |
| Line 1874 SYSCTL_SETUP(sysctl_net_inet6_ip6_setup, |
|
| Line 1910 SYSCTL_SETUP(sysctl_net_inet6_ip6_setup, |
|
| NULL, 0, &ip6_mcast_pmtu, 0, |
NULL, 0, &ip6_mcast_pmtu, 0, |
| CTL_NET, PF_INET6, IPPROTO_IPV6, |
CTL_NET, PF_INET6, IPPROTO_IPV6, |
| CTL_CREATE, CTL_EOL); |
CTL_CREATE, CTL_EOL); |
| |
#ifdef GATEWAY |
| |
sysctl_createv(clog, 0, NULL, NULL, |
| |
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
| |
CTLTYPE_INT, "maxflows", |
| |
SYSCTL_DESCR("Number of flows for fast forwarding (IPv6)"), |
| |
sysctl_net_inet_ip6_maxflows, 0, &ip6_maxflows, 0, |
| |
CTL_NET, PF_INET6, IPPROTO_IPV6, |
| |
CTL_CREATE, CTL_EOL); |
| |
#endif |
| } |
} |