FreeBSD/sys/netinet6/ip6_input.c
/*
 * IP6 initialization: fill in IP6 protocol switch table.
 * All protocols not implemented in kernel go to raw IP6 protocol handler.
 */
IP6 initialization: fill in IP6 protocol switch table.
All protocols not implemented in kernel go to raw IP6 protocol handler.
IP6 initialization : fill in IP6 protocol switch table . All protocols not implemented in kernel go to raw IP6 protocol handler .
void
ip6_init(void)
{
	struct protosw *pr;
	int i;
	TUNABLE_INT_FETCH("net.inet6.ip6.auto_linklocal",
	    &V_ip6_auto_linklocal);
	TUNABLE_INT_FETCH("net.inet6.ip6.accept_rtadv", &V_ip6_accept_rtadv);
	TUNABLE_INT_FETCH("net.inet6.ip6.no_radr", &V_ip6_no_radr);
	TAILQ_INIT(&V_in6_ifaddrhead);
	V_in6_ifaddrhashtbl = hashinit(IN6ADDR_NHASH, M_IFADDR,
	    &V_in6_ifaddrhmask);
	V_inet6_pfil_hook.ph_type = PFIL_TYPE_AF;
	V_inet6_pfil_hook.ph_af = AF_INET6;
	if ((i = pfil_head_register(&V_inet6_pfil_hook)) != 0)
		printf("%s: WARNING: unable to register pfil hook, "
			"error %d\n", __func__, i);
	if (hhook_head_register(HHOOK_TYPE_IPSEC_IN, AF_INET6,
	    &V_ipsec_hhh_in[HHOOK_IPSEC_INET6],
	    HHOOK_WAITOK | HHOOK_HEADISINVNET) != 0)
		printf("%s: WARNING: unable to register input helper hook\n",
		    __func__);
	if (hhook_head_register(HHOOK_TYPE_IPSEC_OUT, AF_INET6,
	    &V_ipsec_hhh_out[HHOOK_IPSEC_INET6],
	    HHOOK_WAITOK | HHOOK_HEADISINVNET) != 0)
		printf("%s: WARNING: unable to register output helper hook\n",
		    __func__);
	scope6_init();
	addrsel_policy_init();
	nd6_init();
	frag6_init();
	V_ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR;
#ifdef VIMAGE
	if (!IS_DEFAULT_VNET(curvnet)) {
		netisr_register_vnet(&ip6_nh);
#ifdef RSS
		netisr_register_vnet(&ip6_direct_nh);
#endif
		return;
	}
#endif
	pr = pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
	if (pr == NULL)
		panic("ip6_init");
	for (i = 0; i < IPPROTO_MAX; i++)
		ip6_protox[i] = pr - inet6sw;
	for (pr = inet6domain.dom_protosw;
	    pr < inet6domain.dom_protoswNPROTOSW; pr++)
		if (pr->pr_domain->dom_family == PF_INET6 &&
		    pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) {
			if (pr->pr_protocol < IPPROTO_MAX)
				ip6_protox[pr->pr_protocol] = pr - inet6sw;
		}
	netisr_register(&ip6_nh);
#ifdef RSS
	netisr_register(&ip6_direct_nh);
#endif
}
void ip6_init ( void ) { struct protosw * pr ; int i ; TUNABLE_INT_FETCH ( " " , & V_ip6_auto_linklocal ) ; TUNABLE_INT_FETCH ( " " , & V_ip6_accept_rtadv ) ; TUNABLE_INT_FETCH ( " " , & V_ip6_no_radr ) ; TAILQ_INIT ( & V_in6_ifaddrhead ) ; V_in6_ifaddrhashtbl = hashinit ( IN6ADDR_NHASH , M_IFADDR , & V_in6_ifaddrhmask ) ; V_inet6_pfil_hook . ph_type = PFIL_TYPE_AF ; V_inet6_pfil_hook . ph_af = AF_INET6 ; if ( ( i = pfil_head_register ( & V_inet6_pfil_hook ) ) != 0 ) printf ( " " " \n " , __func__ , i ) ; if ( hhook_head_register ( HHOOK_TYPE_IPSEC_IN , AF_INET6 , & V_ipsec_hhh_in [ HHOOK_IPSEC_INET6 ] , HHOOK_WAITOK | HHOOK_HEADISINVNET ) != 0 ) printf ( " \n " , __func__ ) ; if ( hhook_head_register ( HHOOK_TYPE_IPSEC_OUT , AF_INET6 , & V_ipsec_hhh_out [ HHOOK_IPSEC_INET6 ] , HHOOK_WAITOK | HHOOK_HEADISINVNET ) != 0 ) printf ( " \n " , __func__ ) ; scope6_init ( ) ; addrsel_policy_init ( ) ; nd6_init ( ) ; frag6_init ( ) ; V_ip6_desync_factor = arc4random ( ) % MAX_TEMP_DESYNC_FACTOR ; #ifdef VIMAGE if ( ! IS_DEFAULT_VNET ( curvnet ) ) { netisr_register_vnet ( & ip6_nh ) ; #ifdef RSS netisr_register_vnet ( & ip6_direct_nh ) ; #endif return ; } #endif pr = pffindproto ( PF_INET6 , IPPROTO_RAW , SOCK_RAW ) ; if ( pr == NULL ) panic ( " " ) ; for ( i = 0 ; i < IPPROTO_MAX ; i ++ ) ip6_protox [ i ] = pr - inet6sw ; for ( pr = inet6domain . dom_protosw ; pr < inet6domain . dom_protoswNPROTOSW ; pr ++ ) if ( pr -> pr_domain -> dom_family == PF_INET6 && pr -> pr_protocol && pr -> pr_protocol != IPPROTO_RAW ) { if ( pr -> pr_protocol < IPPROTO_MAX ) ip6_protox [ pr -> pr_protocol ] = pr - inet6sw ; } netisr_register ( & ip6_nh ) ; #ifdef RSS netisr_register ( & ip6_direct_nh ) ; #endif }
IP6 initialization: fill in IP6 protocol switch table.
IP6 initialization : fill in IP6 protocol switch table .
/* Initialize packet filter hooks. */ /* Skip global initialization stuff for non-default instances. */ /* Initialize the entire ip6_protox[] array to IPPROTO_RAW. */ /*
	 * Cycle through IP protocols and put them into the appropriate place
	 * in ip6_protox[].
	 */ /* Be careful to only index valid IP protocols. */