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

Function encap_input

freebsd/netinet/ip_encap.c:291–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291static int
292encap_input(struct encaptab_head *head, struct mbuf *m, int off, int proto)
293{
294 ENCAP_RLOCK_TRACKER;
295 struct encaptab *ep, *match;
296 void *arg;
297 int matchprio, ret;
298
299 match = NULL;
300 matchprio = 0;
301
302 ENCAP_RLOCK();
303 CK_LIST_FOREACH(ep, head, chain) {
304 if (ep->proto >= 0 && ep->proto != proto)
305 continue;
306 if (ep->min_length > m->m_pkthdr.len)
307 continue;
308 if (ep->exact_match == ENCAP_DRV_LOOKUP)
309 ret = (*ep->lookup)(m, off, proto, &arg);
310 else
311 ret = (*ep->check)(m, off, proto, ep->arg);
312 if (ret <= 0)
313 continue;
314 if (ret > matchprio) {
315 match = ep;
316 if (ep->exact_match != ENCAP_DRV_LOOKUP)
317 arg = ep->arg;
318 /*
319 * No need to continue the search, we got the
320 * exact match.
321 */
322 if (ret >= ep->exact_match)
323 break;
324 matchprio = ret;
325 }
326 }
327
328 if (match != NULL) {
329 /* found a match, "match" has the best one */
330 ret = (*match->input)(m, off, proto, arg);
331 ENCAP_RUNLOCK();
332 MPASS(ret == IPPROTO_DONE);
333 return (IPPROTO_DONE);
334 }
335 ENCAP_RUNLOCK();
336 return (0);
337}
338
339#ifdef INET
340const struct srcaddrtab *

Callers 2

encap4_inputFunction · 0.85
encap6_inputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected