* Setup generic address and protocol structures for raw_input routine, then * pass them along with mbuf chain. */
| 158 | * pass them along with mbuf chain. |
| 159 | */ |
| 160 | int |
| 161 | rip6_input(struct mbuf **mp, int *offp, int proto) |
| 162 | { |
| 163 | struct ifnet *ifp; |
| 164 | struct mbuf *m = *mp; |
| 165 | struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); |
| 166 | struct inpcb *inp; |
| 167 | struct inpcb *last = NULL; |
| 168 | struct mbuf *opts = NULL; |
| 169 | struct sockaddr_in6 fromsa; |
| 170 | |
| 171 | NET_EPOCH_ASSERT(); |
| 172 | |
| 173 | RIP6STAT_INC(rip6s_ipackets); |
| 174 | |
| 175 | init_sin6(&fromsa, m, 0); /* general init */ |
| 176 | |
| 177 | ifp = m->m_pkthdr.rcvif; |
| 178 | |
| 179 | CK_LIST_FOREACH(inp, &V_ripcb, inp_list) { |
| 180 | /* XXX inp locking */ |
| 181 | if ((inp->inp_vflag & INP_IPV6) == 0) |
| 182 | continue; |
| 183 | if (inp->inp_ip_p && |
| 184 | inp->inp_ip_p != proto) |
| 185 | continue; |
| 186 | if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr) && |
| 187 | !IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, &ip6->ip6_dst)) |
| 188 | continue; |
| 189 | if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr) && |
| 190 | !IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr, &ip6->ip6_src)) |
| 191 | continue; |
| 192 | if (last != NULL) { |
| 193 | struct mbuf *n = m_copym(m, 0, M_COPYALL, M_NOWAIT); |
| 194 | |
| 195 | #if defined(IPSEC) || defined(IPSEC_SUPPORT) |
| 196 | /* |
| 197 | * Check AH/ESP integrity. |
| 198 | */ |
| 199 | if (IPSEC_ENABLED(ipv6)) { |
| 200 | if (n != NULL && |
| 201 | IPSEC_CHECK_POLICY(ipv6, n, last) != 0) { |
| 202 | m_freem(n); |
| 203 | /* Do not inject data into pcb. */ |
| 204 | n = NULL; |
| 205 | } |
| 206 | } |
| 207 | #endif /* IPSEC */ |
| 208 | if (n) { |
| 209 | if (last->inp_flags & INP_CONTROLOPTS || |
| 210 | last->inp_socket->so_options & SO_TIMESTAMP) |
| 211 | ip6_savecontrol(last, n, &opts); |
| 212 | /* strip intermediate headers */ |
| 213 | m_adj(n, *offp); |
| 214 | if (sbappendaddr(&last->inp_socket->so_rcv, |
| 215 | (struct sockaddr *)&fromsa, |
| 216 | n, opts) == 0) { |
| 217 | m_freem(n); |
no test coverage detected