diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2006-03-21 01:01:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 01:01:03 -0500 |
commit | c4d9390941aee136fd35bb38eb1d6de4e3b1487d (patch) | |
tree | fcaf0032ba5971145b5f527b8635cd7aa3a39d8c /net/ipv4 | |
parent | 72478873571d869906f7a250b09e12fa5b65e321 (diff) |
[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>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 19 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 13 |
2 files changed, 20 insertions, 12 deletions
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index ae20281d8deb..359f48cec99a 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -648,3 +648,22 @@ void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr) | |||
648 | } | 648 | } |
649 | 649 | ||
650 | EXPORT_SYMBOL_GPL(inet_csk_addr2sockaddr); | 650 | EXPORT_SYMBOL_GPL(inet_csk_addr2sockaddr); |
651 | |||
652 | int inet_csk_ctl_sock_create(struct socket **sock, unsigned short family, | ||
653 | unsigned short type, unsigned char protocol) | ||
654 | { | ||
655 | int rc = sock_create_kern(family, type, protocol, sock); | ||
656 | |||
657 | if (rc == 0) { | ||
658 | (*sock)->sk->sk_allocation = GFP_ATOMIC; | ||
659 | inet_sk((*sock)->sk)->uc_ttl = -1; | ||
660 | /* | ||
661 | * Unhash it so that IP input processing does not even see it, | ||
662 | * we do not wish this socket to see incoming packets. | ||
663 | */ | ||
664 | (*sock)->sk->sk_prot->unhash((*sock)->sk); | ||
665 | } | ||
666 | return rc; | ||
667 | } | ||
668 | |||
669 | EXPORT_SYMBOL_GPL(inet_csk_ctl_sock_create); | ||
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 57e7a26e8213..4eb903db1b12 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -1828,21 +1828,10 @@ struct proto tcp_prot = { | |||
1828 | .rsk_prot = &tcp_request_sock_ops, | 1828 | .rsk_prot = &tcp_request_sock_ops, |
1829 | }; | 1829 | }; |
1830 | 1830 | ||
1831 | |||
1832 | |||
1833 | void __init tcp_v4_init(struct net_proto_family *ops) | 1831 | void __init tcp_v4_init(struct net_proto_family *ops) |
1834 | { | 1832 | { |
1835 | int err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_TCP, &tcp_socket); | 1833 | if (inet_csk_ctl_sock_create(&tcp_socket, PF_INET, SOCK_RAW, IPPROTO_TCP) < 0) |
1836 | if (err < 0) | ||
1837 | panic("Failed to create the TCP control socket.\n"); | 1834 | panic("Failed to create the TCP control socket.\n"); |
1838 | tcp_socket->sk->sk_allocation = GFP_ATOMIC; | ||
1839 | inet_sk(tcp_socket->sk)->uc_ttl = -1; | ||
1840 | |||
1841 | /* Unhash it so that IP input processing does not even | ||
1842 | * see it, we do not wish this socket to see incoming | ||
1843 | * packets. | ||
1844 | */ | ||
1845 | tcp_socket->sk->sk_prot->unhash(tcp_socket->sk); | ||
1846 | } | 1835 | } |
1847 | 1836 | ||
1848 | EXPORT_SYMBOL(ipv4_specific); | 1837 | EXPORT_SYMBOL(ipv4_specific); |