| version 1.83, 2006/03/05 23:47:08 |
version 1.83.2.2, 2006/05/11 23:31:35 |
|
|
| __KERNEL_RCSID(0, "$NetBSD$"); |
__KERNEL_RCSID(0, "$NetBSD$"); |
| |
|
| #include "opt_inet.h" |
#include "opt_inet.h" |
| |
#include "opt_inet6.h" |
| #include "opt_ipsec.h" |
#include "opt_ipsec.h" |
| #include "opt_pfil_hooks.h" |
#include "opt_pfil_hooks.h" |
| |
|
| Line 1030 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1031 ip6_savecontrol(in6p, mp, ip6, m) |
|
| struct ip6_hdr *ip6; |
struct ip6_hdr *ip6; |
| struct mbuf *m; |
struct mbuf *m; |
| { |
{ |
| |
#ifdef RFC2292 |
| |
#define IS2292(x, y) ((in6p->in6p_flags & IN6P_RFC2292) ? (x) : (y)) |
| |
#else |
| |
#define IS2292(x, y) (y) |
| |
#endif |
| |
|
| #ifdef SO_TIMESTAMP |
#ifdef SO_TIMESTAMP |
| if (in6p->in6p_socket->so_options & SO_TIMESTAMP) { |
if (in6p->in6p_socket->so_options & SO_TIMESTAMP) { |
| Line 1042 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1048 ip6_savecontrol(in6p, mp, ip6, m) |
|
| mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
| } |
} |
| #endif |
#endif |
| if (in6p->in6p_flags & IN6P_RECVDSTADDR) { |
|
| *mp = sbcreatecontrol((caddr_t) &ip6->ip6_dst, |
|
| sizeof(struct in6_addr), IPV6_RECVDSTADDR, IPPROTO_IPV6); |
|
| if (*mp) |
|
| mp = &(*mp)->m_next; |
|
| } |
|
| |
|
| #ifdef noyet |
|
| /* options were tossed above */ |
|
| if (in6p->in6p_flags & IN6P_RECVOPTS) |
|
| /* broken */ |
|
| /* ip6_srcroute doesn't do what we want here, need to fix */ |
|
| if (in6p->in6p_flags & IPV6P_RECVRETOPTS) |
|
| /* broken */ |
|
| #endif |
|
| |
|
| /* 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; |
| |
|
| bcopy(&ip6->ip6_dst, &pi6.ipi6_addr, sizeof(struct in6_addr)); |
bcopy(&ip6->ip6_dst, &pi6.ipi6_addr, sizeof(struct in6_addr)); |
| in6_clearscope(&pi6.ipi6_addr); /* XXX */ |
in6_clearscope(&pi6.ipi6_addr); /* XXX */ |
| pi6.ipi6_ifindex = (m && m->m_pkthdr.rcvif) |
pi6.ipi6_ifindex = m->m_pkthdr.rcvif ? |
| ? m->m_pkthdr.rcvif->if_index |
m->m_pkthdr.rcvif->if_index : 0; |
| : 0; |
|
| *mp = sbcreatecontrol((caddr_t) &pi6, |
*mp = sbcreatecontrol((caddr_t) &pi6, |
| sizeof(struct in6_pktinfo), IPV6_PKTINFO, IPPROTO_IPV6); |
sizeof(struct in6_pktinfo), |
| |
IS2292(IPV6_2292PKTINFO, IPV6_PKTINFO), IPPROTO_IPV6); |
| if (*mp) |
if (*mp) |
| mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
| } |
} |
| |
|
| 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((caddr_t) &hlim, sizeof(int), |
| IPV6_HOPLIMIT, IPPROTO_IPV6); |
IS2292(IPV6_2292HOPLIMIT, IPV6_HOPLIMIT), IPPROTO_IPV6); |
| |
if (*mp) |
| |
mp = &(*mp)->m_next; |
| |
} |
| |
|
| |
if ((in6p->in6p_flags & IN6P_TCLASS) != 0) { |
| |
u_int32_t flowinfo; |
| |
int tclass; |
| |
|
| |
flowinfo = (u_int32_t)ntohl(ip6->ip6_flow & IPV6_FLOWINFO_MASK); |
| |
flowinfo >>= 20; |
| |
|
| |
tclass = flowinfo & 0xff; |
| |
*mp = sbcreatecontrol((caddr_t)&tclass, sizeof(tclass), |
| |
IPV6_TCLASS, IPPROTO_IPV6); |
| |
|
| if (*mp) |
if (*mp) |
| mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
| } |
} |
| /* IN6P_NEXTHOP - for outgoing packet only */ |
|
| |
|
| /* |
/* |
| * IPV6_HOPOPTS socket option. Recall that we required super-user |
* IPV6_HOPOPTS socket option. Recall that we required super-user |
| * privilege for the option (see ip6_ctloutput), but it might be too |
* privilege for the option (see ip6_ctloutput), but it might be too |
| * strict, since there might be some hop-by-hop options which can be |
* strict, since there might be some hop-by-hop options which can be |
| * returned to normal user. |
* returned to normal user. |
| * See also RFC 2292 section 6. |
* See also RFC3542 section 8 (or RFC2292 section 6). |
| */ |
*/ |
| if ((in6p->in6p_flags & IN6P_HOPOPTS) != 0) { |
if ((in6p->in6p_flags & IN6P_HOPOPTS) != 0) { |
| /* |
/* |
| Line 1119 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1126 ip6_savecontrol(in6p, mp, ip6, m) |
|
| * XXX: We copy whole the header even if a jumbo |
* XXX: We copy whole the header even if a jumbo |
| * payload option is included, which option is to |
* payload option is included, which option is to |
| * be removed before returning in the RFC 2292. |
* be removed before returning in the RFC 2292. |
| * But it's too painful operation... |
* Note: this constraint is removed in RFC3542. |
| */ |
*/ |
| *mp = sbcreatecontrol((caddr_t)hbh, hbhlen, |
*mp = sbcreatecontrol((caddr_t)hbh, hbhlen, |
| IPV6_HOPOPTS, IPPROTO_IPV6); |
IS2292(IPV6_2292HOPOPTS, IPV6_HOPOPTS), |
| |
IPPROTO_IPV6); |
| if (*mp) |
if (*mp) |
| mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
| m_freem(ext); |
m_freem(ext); |
| Line 1141 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1149 ip6_savecontrol(in6p, mp, ip6, m) |
|
| * Note that the order of the headers remains in |
* Note that the order of the headers remains in |
| * the chain of ancillary data. |
* the chain of ancillary data. |
| */ |
*/ |
| while (1) { /* is explicit loop prevention necessary? */ |
for (;;) { /* is explicit loop prevention necessary? */ |
| struct ip6_ext *ip6e = NULL; |
struct ip6_ext *ip6e = NULL; |
| int elen; |
int elen; |
| struct mbuf *ext = NULL; |
struct mbuf *ext = NULL; |
| Line 1183 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1191 ip6_savecontrol(in6p, mp, ip6, m) |
|
| break; |
break; |
| |
|
| *mp = sbcreatecontrol((caddr_t)ip6e, elen, |
*mp = sbcreatecontrol((caddr_t)ip6e, elen, |
| IPV6_DSTOPTS, IPPROTO_IPV6); |
IS2292(IPV6_2292DSTOPTS, IPV6_DSTOPTS), |
| |
IPPROTO_IPV6); |
| if (*mp) |
if (*mp) |
| mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
| break; |
break; |
| Line 1193 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1202 ip6_savecontrol(in6p, mp, ip6, m) |
|
| break; |
break; |
| |
|
| *mp = sbcreatecontrol((caddr_t)ip6e, elen, |
*mp = sbcreatecontrol((caddr_t)ip6e, elen, |
| IPV6_RTHDR, IPPROTO_IPV6); |
IS2292(IPV6_2292RTHDR, IPV6_RTHDR), |
| |
IPPROTO_IPV6); |
| if (*mp) |
if (*mp) |
| mp = &(*mp)->m_next; |
mp = &(*mp)->m_next; |
| break; |
break; |
| Line 1225 ip6_savecontrol(in6p, mp, ip6, m) |
|
| Line 1235 ip6_savecontrol(in6p, mp, ip6, m) |
|
| ; |
; |
| } |
} |
| } |
} |
| |
#undef IS2292 |
| |
|
| |
|
| |
void |
| |
ip6_notify_pmtu(struct in6pcb *in6p, struct sockaddr_in6 *dst, uint32_t *mtu) |
| |
{ |
| |
struct socket *so; |
| |
struct mbuf *m_mtu; |
| |
struct ip6_mtuinfo mtuctl; |
| |
|
| |
so = in6p->in6p_socket; |
| |
|
| |
if (mtu == NULL) |
| |
return; |
| |
|
| |
#ifdef DIAGNOSTIC |
| |
if (so == NULL) /* I believe this is impossible */ |
| |
panic("ip6_notify_pmtu: socket is NULL"); |
| |
#endif |
| |
|
| |
memset(&mtuctl, 0, sizeof(mtuctl)); /* zero-clear for safety */ |
| |
mtuctl.ip6m_mtu = *mtu; |
| |
mtuctl.ip6m_addr = *dst; |
| |
if (sa6_recoverscope(&mtuctl.ip6m_addr)) |
| |
return; |
| |
|
| |
if ((m_mtu = sbcreatecontrol((caddr_t)&mtuctl, sizeof(mtuctl), |
| |
IPV6_PATHMTU, IPPROTO_IPV6)) == NULL) |
| |
return; |
| |
|
| |
if (sbappendaddr(&so->so_rcv, (struct sockaddr *)dst, NULL, m_mtu) |
| |
== 0) { |
| |
m_freem(m_mtu); |
| |
/* XXX: should count statistics */ |
| |
} else |
| |
sorwakeup(so); |
| |
|
| |
return; |
| |
} |
| |
|
| /* |
/* |
| * pull single extension header from mbuf chain. returns single mbuf that |
* pull single extension header from mbuf chain. returns single mbuf that |
| Line 1430 ip6_lasthdr(m, off, proto, nxtp) |
|
| Line 1479 ip6_lasthdr(m, off, proto, nxtp) |
|
| nxt = -1; |
nxt = -1; |
| nxtp = &nxt; |
nxtp = &nxt; |
| } |
} |
| while (1) { |
for (;;) { |
| newoff = ip6_nexthdr(m, off, proto, nxtp); |
newoff = ip6_nexthdr(m, off, proto, nxtp); |
| if (newoff < 0) |
if (newoff < 0) |
| return off; |
return off; |
| Line 1498 u_char inet6ctlerrmap[PRC_NCMDS] = { |
|
| Line 1547 u_char inet6ctlerrmap[PRC_NCMDS] = { |
|
| |
|
| SYSCTL_SETUP(sysctl_net_inet6_ip6_setup, "sysctl net.inet6.ip6 subtree setup") |
SYSCTL_SETUP(sysctl_net_inet6_ip6_setup, "sysctl net.inet6.ip6 subtree setup") |
| { |
{ |
| |
#ifdef RFC2292 |
| |
#define IS2292(x, y) ((in6p->in6p_flags & IN6P_RFC2292) ? (x) : (y)) |
| |
#else |
| |
#define IS2292(x, y) (y) |
| |
#endif |
| |
|
| sysctl_createv(clog, 0, NULL, NULL, |
sysctl_createv(clog, 0, NULL, NULL, |
| CTLFLAG_PERMANENT, |
CTLFLAG_PERMANENT, |