[ICSK]: Introduce inet_csk_ctl_sock_create

Consolidating open coded sequences in tcp and dccp, v4 and v6.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Arnaldo Carvalho de Melo
2006-03-20 22:01:03 -08:00
committed by David S. Miller
parent 7247887357
commit c4d9390941
6 changed files with 31 additions and 71 deletions

View File

@@ -648,3 +648,22 @@ void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr)
}
EXPORT_SYMBOL_GPL(inet_csk_addr2sockaddr);
int inet_csk_ctl_sock_create(struct socket **sock, unsigned short family,
unsigned short type, unsigned char protocol)
{
int rc = sock_create_kern(family, type, protocol, sock);
if (rc == 0) {
(*sock)->sk->sk_allocation = GFP_ATOMIC;
inet_sk((*sock)->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.
*/
(*sock)->sk->sk_prot->unhash((*sock)->sk);
}
return rc;
}
EXPORT_SYMBOL_GPL(inet_csk_ctl_sock_create);

View File

@@ -1828,21 +1828,10 @@ struct proto tcp_prot = {
.rsk_prot = &tcp_request_sock_ops,
};
void __init tcp_v4_init(struct net_proto_family *ops)
{
int err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_TCP, &tcp_socket);
if (err < 0)
if (inet_csk_ctl_sock_create(&tcp_socket, PF_INET, SOCK_RAW, IPPROTO_TCP) < 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);
}
EXPORT_SYMBOL(ipv4_specific);