Exemplo n.º 1
0
/*
 * 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 ip6protosw *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);

	/* Initialize packet filter hooks. */
	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);

	scope6_init();
	addrsel_policy_init();
	nd6_init();
	frag6_init();

	V_ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR;

	/* Skip global initialization stuff for non-default instances. */
	if (!IS_DEFAULT_VNET(curvnet))
		return;

#ifdef DIAGNOSTIC
	if (sizeof(struct protosw) != sizeof(struct ip6protosw))
		panic("sizeof(protosw) != sizeof(ip6protosw)");
#endif
	pr = (struct ip6protosw *)pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
	if (pr == NULL)
		panic("ip6_init");

	/* Initialize the entire ip6_protox[] array to IPPROTO_RAW. */
	for (i = 0; i < IPPROTO_MAX; i++)
		ip6_protox[i] = pr - inet6sw;
	/*
	 * Cycle through IP protocols and put them into the appropriate place
	 * in ip6_protox[].
	 */
	for (pr = (struct ip6protosw *)inet6domain.dom_protosw;
	    pr < (struct ip6protosw *)inet6domain.dom_protoswNPROTOSW; pr++)
		if (pr->pr_domain->dom_family == PF_INET6 &&
		    pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) {
			/* Be careful to only index valid IP protocols. */
			if (pr->pr_protocol < IPPROTO_MAX)
				ip6_protox[pr->pr_protocol] = pr - inet6sw;
		}

	netisr_register(&ip6_nh);
}
Exemplo n.º 2
0
/*
 * 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;
	struct timeval tv;

	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)
			ip6_protox[pr->pr_protocol] = pr - inet6sw;

	inet6_pfil_hook.ph_type = PFIL_TYPE_AF;
	inet6_pfil_hook.ph_af = AF_INET6;
	if ((i = pfil_head_register(&inet6_pfil_hook)) != 0) {
		kprintf("%s: WARNING: unable to register pfil hook, "
			"error %d\n", __func__, i);
	}

	netisr_register(NETISR_IPV6, ip6_input, NULL); /* XXX cpufn */
	scope6_init();
	addrsel_policy_init();
	nd6_init();
	frag6_init();
	/*
	 * in many cases, random() here does NOT return random number
	 * as initialization during bootstrap time occur in fixed order.
	 */
	microtime(&tv);
	ip6_flow_seq = krandom() ^ tv.tv_usec;
	microtime(&tv);
	ip6_desync_factor = (krandom() ^ tv.tv_usec) % MAX_TEMP_DESYNC_FACTOR;
}
Exemplo n.º 3
0
/*
 * IP initialization: fill in IP protocol switch table.
 * All protocols not implemented in kernel go to raw IP protocol handler.
 */
void
ip_init()
{
    register struct protosw *pr;
    register int i;

    pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
    if (pr == 0)
        panic("ip_init");
    for (i = 0; i < IPPROTO_MAX; i++)
        ip_protox[i] = pr - inetsw;
    for (pr = inetdomain.dom_protosw;
            pr < inetdomain.dom_protoswNPROTOSW; pr++)
        if (pr->pr_domain->dom_family == PF_INET &&
                pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
            ip_protox[pr->pr_protocol] = pr - inetsw;
    ipq.next = ipq.prev = &ipq;
    /*	ip_id = time.tv_sec & 0xffff; */
    ipintrq.ifq_maxlen = ipqmaxlen;
#ifdef GATEWAY
    i = (if_index + 1) * (if_index + 1) * sizeof (u_long);
    ip_ifmatrix = (u_long *) malloc(i);  /*  M_RTABLE, M_WAITOK); */
    bzero((char *)ip_ifmatrix, i);
#endif


#ifdef PFIL_HOOKS
    /* Register our Packet Filter hook. */
    inet_pfil_hook.ph_type = PFIL_TYPE_AF;
    inet_pfil_hook.ph_af   = AF_INET;
    i = pfil_head_register(&inet_pfil_hook);
    if (i != 0)
        printf("ip_init: WARNING: unable to register pfil hook, "
               "error %d\n", i);
#endif /* PFIL_HOOKS */


}
Exemplo n.º 4
0
/*
 * IP6 initialization: fill in IP6 protocol switch table.
 * All protocols not implemented in kernel go to raw IP6 protocol handler.
 */
void
ip6_init()
{
    struct ip6protosw *pr;
    int i;

#ifdef DIAGNOSTIC
    if (sizeof(struct protosw) != sizeof(struct ip6protosw))
        panic("sizeof(protosw) != sizeof(ip6protosw)");
#endif
    pr = (struct ip6protosw *)pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
    if (pr == 0)
        panic("ip6_init");
    for (i = 0; i < IPPROTO_MAX; i++)
        ip6_protox[i] = pr - inet6sw;
    for (pr = (struct ip6protosw *)inet6domain.dom_protosw;
            pr < (struct ip6protosw *)inet6domain.dom_protoswNPROTOSW; pr++)
        if (pr->pr_domain->dom_family == PF_INET6 &&
                pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
            ip6_protox[pr->pr_protocol] = pr - inet6sw;

    /* Initialize packet filter hooks. */
    inet6_pfil_hook.ph_type = PFIL_TYPE_AF;
    inet6_pfil_hook.ph_af = AF_INET6;
    if ((i = pfil_head_register(&inet6_pfil_hook)) != 0)
        printf("%s: WARNING: unable to register pfil hook, "
               "error %d\n", __func__, i);

    ip6intrq.ifq_maxlen = ip6qmaxlen;
    mtx_init(&ip6intrq.ifq_mtx, "ip6_inq", NULL, MTX_DEF);
    netisr_register(NETISR_IPV6, ip6_input, &ip6intrq, 0);
    scope6_init();
    addrsel_policy_init();
    nd6_init();
    frag6_init();
    ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR;
}
Exemplo n.º 5
0
/*
 * 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 ip6protosw *pr;
	int i;

	TUNABLE_INT_FETCH("net.inet6.ip6.auto_linklocal",
	    &V_ip6_auto_linklocal);

	TAILQ_INIT(&V_in6_ifaddrhead);

	/* Initialize packet filter hooks. */
	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);

	scope6_init();
	addrsel_policy_init();
	nd6_init();
	frag6_init();

#ifdef FLOWTABLE
	if (TUNABLE_INT_FETCH("net.inet6.ip6.output_flowtable_size",
		&V_ip6_output_flowtable_size)) {
		if (V_ip6_output_flowtable_size < 256)
			V_ip6_output_flowtable_size = 256;
		if (!powerof2(V_ip6_output_flowtable_size)) {
			printf("flowtable must be power of 2 size\n");
			V_ip6_output_flowtable_size = 2048;
		}
	} else {
		/*
		 * round up to the next power of 2
		 */
		V_ip6_output_flowtable_size = 1 << fls((1024 + maxusers * 64)-1);
	}
	V_ip6_ft = flowtable_alloc("ipv6", V_ip6_output_flowtable_size, FL_IPV6|FL_PCPU);
#endif	
	
	V_ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR;

	/* Skip global initialization stuff for non-default instances. */
	if (!IS_DEFAULT_VNET(curvnet))
		return;

#ifdef DIAGNOSTIC
	if (sizeof(struct protosw) != sizeof(struct ip6protosw))
		panic("sizeof(protosw) != sizeof(ip6protosw)");
#endif
	pr = (struct ip6protosw *)pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
	if (pr == NULL)
		panic("ip6_init");

	/* Initialize the entire ip6_protox[] array to IPPROTO_RAW. */
	for (i = 0; i < IPPROTO_MAX; i++)
		ip6_protox[i] = pr - inet6sw;
	/*
	 * Cycle through IP protocols and put them into the appropriate place
	 * in ip6_protox[].
	 */
	for (pr = (struct ip6protosw *)inet6domain.dom_protosw;
	    pr < (struct ip6protosw *)inet6domain.dom_protoswNPROTOSW; pr++)
		if (pr->pr_domain->dom_family == PF_INET6 &&
		    pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) {
			/* Be careful to only index valid IP protocols. */
			if (pr->pr_protocol < IPPROTO_MAX)
				ip6_protox[pr->pr_protocol] = pr - inet6sw;
		}

	netisr_register(&ip6_nh);
}