MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ip_findroute

Function ip_findroute

freebsd/netinet/ip_fastfwd.c:156–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154
155
156static int
157ip_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.

Callers 1

ip_fastfwd.cFile · 0.85

Calls 3

fib4_lookupFunction · 0.85
icmp_errorFunction · 0.85
m_freemFunction · 0.50

Tested by

no test coverage detected