tcp_v4_init & icmp_init

阅读更多

 

 

void __init tcp_v4_init(struct net_proto_family *ops)
{
	int err = sock_create(PF_INET, SOCK_RAW, IPPROTO_TCP, &tcp_socket);
	if (err < 0)
		panic("Failed to create the TCP control socket.\n");
	tcp_socket->sk->sk_allocation   = GFP_ATOMIC;
	inet_sk(tcp_socket->sk)->uc_ttl = -1;

	/* Unhash it so that IP input processing does not even
	 * see it, we do not wish this socket to see incoming
	 * packets.
	 */
	tcp_socket->sk->sk_prot->unhash(tcp_socket->sk);
}

  

 

 

 

void __init icmp_init(struct net_proto_family *ops)
{
	struct inet_opt *inet;
	int i;

	for (i = 0; i < NR_CPUS; i++) {
		int err;

		if (!cpu_possible(i))
			continue;

		err = sock_create(PF_INET, SOCK_RAW, IPPROTO_ICMP,
				  &per_cpu(__icmp_socket, i));

		if (err < 0)
			panic("Failed to create the ICMP control socket.\n");

		per_cpu(__icmp_socket, i)->sk->sk_allocation = GFP_ATOMIC;
		per_cpu(__icmp_socket, i)->sk->sk_sndbuf = SK_WMEM_MAX * 2;
		inet = inet_sk(per_cpu(__icmp_socket, i)->sk);
		inet->uc_ttl = -1;
		inet->pmtudisc = IP_PMTUDISC_DONT;

		/* Unhash it so that IP input processing does not even
		 * see it, we do not wish this socket to see incoming
		 * packets.
		 */
		per_cpu(__icmp_socket, i)->sk->sk_prot->unhash(per_cpu(__icmp_socket, i)->sk);
	}
}

 

你可能感兴趣的:(tcp_v4_init & icmp_init)