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

Function ip_init

freebsd/netinet/ip_input.c:310–376  ·  view source on GitHub ↗

* IP initialization: fill in IP protocol switch table. * All protocols not implemented in kernel go to raw IP protocol handler. */

Source from the content-addressed store, hash-verified

308 * All protocols not implemented in kernel go to raw IP protocol handler.
309 */
310void
311ip_init(void)
312{
313 struct pfil_head_args args;
314 struct protosw *pr;
315 int i;
316
317 CK_STAILQ_INIT(&V_in_ifaddrhead);
318 V_in_ifaddrhashtbl = hashinit(INADDR_NHASH, M_IFADDR, &V_in_ifaddrhmask);
319
320 /* Initialize IP reassembly queue. */
321 ipreass_init();
322
323 /* Initialize packet filter hooks. */
324 args.pa_version = PFIL_VERSION;
325 args.pa_flags = PFIL_IN | PFIL_OUT;
326 args.pa_type = PFIL_TYPE_IP4;
327 args.pa_headname = PFIL_INET_NAME;
328 V_inet_pfil_head = pfil_head_register(&args);
329
330 if (hhook_head_register(HHOOK_TYPE_IPSEC_IN, AF_INET,
331 &V_ipsec_hhh_in[HHOOK_IPSEC_INET],
332 HHOOK_WAITOK | HHOOK_HEADISINVNET) != 0)
333 printf("%s: WARNING: unable to register input helper hook\n",
334 __func__);
335 if (hhook_head_register(HHOOK_TYPE_IPSEC_OUT, AF_INET,
336 &V_ipsec_hhh_out[HHOOK_IPSEC_INET],
337 HHOOK_WAITOK | HHOOK_HEADISINVNET) != 0)
338 printf("%s: WARNING: unable to register output helper hook\n",
339 __func__);
340
341 /* Skip initialization of globals for non-default instances. */
342#ifdef VIMAGE
343 if (!IS_DEFAULT_VNET(curvnet)) {
344 netisr_register_vnet(&ip_nh);
345#ifdef RSS
346 netisr_register_vnet(&ip_direct_nh);
347#endif
348 return;
349 }
350#endif
351
352 pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
353 if (pr == NULL)
354 panic("ip_init: PF_INET not found");
355
356 /* Initialize the entire ip_protox[] array to IPPROTO_RAW. */
357 for (i = 0; i < IPPROTO_MAX; i++)
358 ip_protox[i] = pr - inetsw;
359 /*
360 * Cycle through IP protocols and put them into the appropriate place
361 * in ip_protox[].
362 */
363 for (pr = inetdomain.dom_protosw;
364 pr < inetdomain.dom_protoswNPROTOSW; pr++)
365 if (pr->pr_domain->dom_family == PF_INET &&
366 pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) {
367 /* Be careful to only index valid IP protocols. */

Callers

nothing calls this directly

Calls 9

ipreass_initFunction · 0.85
pfil_head_registerFunction · 0.85
hhook_head_registerFunction · 0.85
netisr_register_vnetFunction · 0.85
pffindprotoFunction · 0.85
netisr_registerFunction · 0.85
hashinitFunction · 0.50
printfFunction · 0.50
panicFunction · 0.50

Tested by

no test coverage detected