| 154 | |
| 155 | |
| 156 | static int |
| 157 | ip_findroute(struct nhop_object **pnh, struct in_addr dest, struct mbuf *m) |
| 158 | { |
| 159 | struct nhop_object *nh; |
| 160 | |
| 161 | nh = fib4_lookup(M_GETFIB(m), dest, 0, NHR_NONE, |
| 162 | m->m_pkthdr.flowid); |
| 163 | if (nh == NULL) { |
| 164 | IPSTAT_INC(ips_noroute); |
| 165 | IPSTAT_INC(ips_cantforward); |
| 166 | icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0); |
| 167 | return (EHOSTUNREACH); |
| 168 | } |
| 169 | /* |
| 170 | * Drop blackholed traffic and directed broadcasts. |
| 171 | */ |
| 172 | if ((nh->nh_flags & (NHF_BLACKHOLE | NHF_BROADCAST)) != 0) { |
| 173 | IPSTAT_INC(ips_cantforward); |
| 174 | m_freem(m); |
| 175 | return (EHOSTUNREACH); |
| 176 | } |
| 177 | |
| 178 | if (nh->nh_flags & NHF_REJECT) { |
| 179 | IPSTAT_INC(ips_cantforward); |
| 180 | icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0); |
| 181 | return (EHOSTUNREACH); |
| 182 | } |
| 183 | |
| 184 | *pnh = nh; |
| 185 | |
| 186 | return (0); |
| 187 | } |
| 188 | |
| 189 | /* |
| 190 | * Try to forward a packet based on the destination address. |
no test coverage detected