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 retrieving revision 1.82.2.3 retrieving revision 1.83 diff -u -p -r1.82.2.3 -r1.83 --- src/sys/netinet6/ip6_input.c 2006/09/09 02:58:55 1.82.2.3 +++ src/sys/netinet6/ip6_input.c 2006/03/05 23:47:08 1.83 @@ -1,4 +1,4 @@ -/* $NetBSD: ip6_input.c,v 1.82.2.3 2006/09/09 02:58:55 rpaulo Exp $ */ +/* $NetBSD: ip6_input.c,v 1.83 2006/03/05 23:47:08 rpaulo Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -62,10 +62,9 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.82.2.3 2006/09/09 02:58:55 rpaulo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.83 2006/03/05 23:47:08 rpaulo Exp $"); #include "opt_inet.h" -#include "opt_inet6.h" #include "opt_ipsec.h" #include "opt_pfil_hooks.h" @@ -95,7 +94,6 @@ __KERNEL_RCSID(0, "$NetBSD: ip6_input.c, #include #include -#include #ifdef INET #include #include @@ -103,6 +101,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip6_input.c, #include #include #include +#include #include #include #include @@ -410,10 +409,6 @@ ip6_input(m) * dst are the loopback address and the receiving interface * 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)) { ip6stat.ip6s_badscope++; /* XXX */ goto bad; @@ -1029,20 +1024,15 @@ ip6_unknown_opt(optp, m, off) * you are using IP6_EXTHDR_CHECK() not m_pulldown()) */ void -ip6_savecontrol(inp, mp, ip6, m) - struct inpcb *inp; +ip6_savecontrol(in6p, mp, ip6, m) + struct in6pcb *in6p; struct mbuf **mp; struct ip6_hdr *ip6; 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 - if (inp->inp_socket->so_options & SO_TIMESTAMP) { + if (in6p->in6p_socket->so_options & SO_TIMESTAMP) { struct timeval tv; microtime(&tv); @@ -1052,57 +1042,52 @@ ip6_savecontrol(inp, mp, ip6, m) mp = &(*mp)->m_next; } #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; + } - /* some OSes call this logic with IPv4 packet, for SO_TIMESTAMP */ - if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) - return; +#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 */ - if ((inp->inp_flags & IN6P_PKTINFO) != 0) { + if ((in6p->in6p_flags & IN6P_PKTINFO) != 0) { struct in6_pktinfo pi6; - bcopy(&ip6->ip6_dst, &pi6.ipi6_addr, sizeof(struct in6_addr)); in6_clearscope(&pi6.ipi6_addr); /* XXX */ - pi6.ipi6_ifindex = m->m_pkthdr.rcvif ? - m->m_pkthdr.rcvif->if_index : 0; + pi6.ipi6_ifindex = (m && m->m_pkthdr.rcvif) + ? m->m_pkthdr.rcvif->if_index + : 0; *mp = sbcreatecontrol((caddr_t) &pi6, - sizeof(struct in6_pktinfo), - IS2292(IPV6_2292PKTINFO, IPV6_PKTINFO), IPPROTO_IPV6); + sizeof(struct in6_pktinfo), IPV6_PKTINFO, IPPROTO_IPV6); if (*mp) mp = &(*mp)->m_next; } - if (inp->inp_flags & IN6P_HOPLIMIT) { + if (in6p->in6p_flags & IN6P_HOPLIMIT) { int hlim = ip6->ip6_hlim & 0xff; - *mp = sbcreatecontrol((caddr_t) &hlim, sizeof(int), - 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); - + IPV6_HOPLIMIT, IPPROTO_IPV6); if (*mp) mp = &(*mp)->m_next; } + /* IN6P_NEXTHOP - for outgoing packet only */ /* * IPV6_HOPOPTS socket option. Recall that we required super-user * 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 * returned to normal user. - * See also RFC3542 section 8 (or RFC2292 section 6). + * See also RFC 2292 section 6. */ - if ((inp->inp_flags & IN6P_HOPOPTS) != 0) { + if ((in6p->in6p_flags & IN6P_HOPOPTS) != 0) { /* * Check if a hop-by-hop options header is contatined in the * received packet, and if so, store the options as ancillary @@ -1134,11 +1119,10 @@ ip6_savecontrol(inp, mp, ip6, m) * XXX: We copy whole the header even if a jumbo * payload option is included, which option is to * be removed before returning in the RFC 2292. - * Note: this constraint is removed in RFC3542. + * But it's too painful operation... */ *mp = sbcreatecontrol((caddr_t)hbh, hbhlen, - IS2292(IPV6_2292HOPOPTS, IPV6_HOPOPTS), - IPPROTO_IPV6); + IPV6_HOPOPTS, IPPROTO_IPV6); if (*mp) mp = &(*mp)->m_next; m_freem(ext); @@ -1146,7 +1130,7 @@ ip6_savecontrol(inp, mp, ip6, m) } /* IPV6_DSTOPTS and IPV6_RTHDR socket options */ - if (inp->inp_flags & (IN6P_DSTOPTS | IN6P_RTHDR)) { + if (in6p->in6p_flags & (IN6P_DSTOPTS | IN6P_RTHDR)) { struct ip6_hdr *xip6 = mtod(m, struct ip6_hdr *); int nxt = xip6->ip6_nxt, off = sizeof(struct ip6_hdr); @@ -1157,7 +1141,7 @@ ip6_savecontrol(inp, mp, ip6, m) * Note that the order of the headers remains in * the chain of ancillary data. */ - for (;;) { /* is explicit loop prevention necessary? */ + while (1) { /* is explicit loop prevention necessary? */ struct ip6_ext *ip6e = NULL; int elen; struct mbuf *ext = NULL; @@ -1195,23 +1179,21 @@ ip6_savecontrol(inp, mp, ip6, m) switch (nxt) { case IPPROTO_DSTOPTS: - if (!inp->inp_flags & IN6P_DSTOPTS) + if (!in6p->in6p_flags & IN6P_DSTOPTS) break; *mp = sbcreatecontrol((caddr_t)ip6e, elen, - IS2292(IPV6_2292DSTOPTS, IPV6_DSTOPTS), - IPPROTO_IPV6); + IPV6_DSTOPTS, IPPROTO_IPV6); if (*mp) mp = &(*mp)->m_next; break; case IPPROTO_ROUTING: - if (!inp->inp_flags & IN6P_RTHDR) + if (!in6p->in6p_flags & IN6P_RTHDR) break; *mp = sbcreatecontrol((caddr_t)ip6e, elen, - IS2292(IPV6_2292RTHDR, IPV6_RTHDR), - IPPROTO_IPV6); + IPV6_RTHDR, IPPROTO_IPV6); if (*mp) mp = &(*mp)->m_next; break; @@ -1243,45 +1225,6 @@ ip6_savecontrol(inp, 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 @@ -1487,7 +1430,7 @@ ip6_lasthdr(m, off, proto, nxtp) nxt = -1; nxtp = &nxt; } - for (;;) { + while (1) { newoff = ip6_nexthdr(m, off, proto, nxtp); if (newoff < 0) return off; @@ -1555,11 +1498,6 @@ u_char inet6ctlerrmap[PRC_NCMDS] = { 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, CTLFLAG_PERMANENT,