| 89 | } |
| 90 | |
| 91 | struct mbuf* |
| 92 | ip6_tryforward(struct mbuf *m) |
| 93 | { |
| 94 | struct sockaddr_in6 dst; |
| 95 | struct nhop_object *nh; |
| 96 | struct m_tag *fwd_tag; |
| 97 | struct ip6_hdr *ip6; |
| 98 | struct ifnet *rcvif; |
| 99 | uint32_t plen; |
| 100 | int error; |
| 101 | |
| 102 | /* |
| 103 | * Fallback conditions to ip6_input for slow path processing. |
| 104 | */ |
| 105 | ip6 = mtod(m, struct ip6_hdr *); |
| 106 | if ((m->m_flags & (M_BCAST | M_MCAST)) != 0 || |
| 107 | ip6->ip6_nxt == IPPROTO_HOPOPTS || |
| 108 | IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) || |
| 109 | IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_dst) || |
| 110 | IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src) || |
| 111 | IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) || |
| 112 | in6_localip(&ip6->ip6_dst)) |
| 113 | return (m); |
| 114 | /* |
| 115 | * Check that the amount of data in the buffers |
| 116 | * is as at least much as the IPv6 header would have us expect. |
| 117 | * Trim mbufs if longer than we expect. |
| 118 | * Drop packet if shorter than we expect. |
| 119 | */ |
| 120 | rcvif = m->m_pkthdr.rcvif; |
| 121 | plen = ntohs(ip6->ip6_plen); |
| 122 | if (plen == 0) { |
| 123 | /* |
| 124 | * Jumbograms must have hop-by-hop header and go via |
| 125 | * slow path. |
| 126 | */ |
| 127 | IP6STAT_INC(ip6s_badoptions); |
| 128 | goto dropin; |
| 129 | } |
| 130 | if (m->m_pkthdr.len - sizeof(struct ip6_hdr) < plen) { |
| 131 | IP6STAT_INC(ip6s_tooshort); |
| 132 | in6_ifstat_inc(rcvif, ifs6_in_truncated); |
| 133 | goto dropin; |
| 134 | } |
| 135 | if (m->m_pkthdr.len > sizeof(struct ip6_hdr) + plen) { |
| 136 | if (m->m_len == m->m_pkthdr.len) { |
| 137 | m->m_len = sizeof(struct ip6_hdr) + plen; |
| 138 | m->m_pkthdr.len = sizeof(struct ip6_hdr) + plen; |
| 139 | } else |
| 140 | m_adj(m, sizeof(struct ip6_hdr) + plen - |
| 141 | m->m_pkthdr.len); |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | * Hop limit. |
| 146 | */ |
| 147 | #ifdef IPSTEALTH |
| 148 | if (!V_ip6stealth) |
no test coverage detected