diff options
-rw-r--r-- | include/net/inet_connection_sock.h | 4 | ||||
-rw-r--r-- | net/dccp/ipv4.c | 26 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 27 | ||||
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 19 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 13 | ||||
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 13 |
6 files changed, 31 insertions, 71 deletions
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 4e5a9ff99fc3..363a067403ee 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h | |||
@@ -321,4 +321,8 @@ extern void inet_csk_listen_stop(struct sock *sk); | |||
321 | 321 | ||
322 | extern void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); | 322 | extern void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); |
323 | 323 | ||
324 | extern int inet_csk_ctl_sock_create(struct socket **sock, | ||
325 | unsigned short family, | ||
326 | unsigned short type, | ||
327 | unsigned char protocol); | ||
324 | #endif /* _INET_CONNECTION_SOCK_H */ | 328 | #endif /* _INET_CONNECTION_SOCK_H */ |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index f53bce590ade..7098f1055f4a 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -1099,29 +1099,6 @@ static struct inet_protosw dccp_v4_protosw = { | |||
1099 | .flags = INET_PROTOSW_ICSK, | 1099 | .flags = INET_PROTOSW_ICSK, |
1100 | }; | 1100 | }; |
1101 | 1101 | ||
1102 | static char dccp_v4_ctl_socket_err_msg[] __initdata = | ||
1103 | KERN_ERR "DCCP: Failed to create the control socket.\n"; | ||
1104 | |||
1105 | static int __init dccp_v4_ctl_sock_init(void) | ||
1106 | { | ||
1107 | int rc = sock_create_kern(PF_INET, SOCK_DCCP, IPPROTO_DCCP, | ||
1108 | &dccp_v4_ctl_socket); | ||
1109 | if (rc < 0) | ||
1110 | printk(dccp_v4_ctl_socket_err_msg); | ||
1111 | else { | ||
1112 | dccp_v4_ctl_socket->sk->sk_allocation = GFP_ATOMIC; | ||
1113 | inet_sk(dccp_v4_ctl_socket->sk)->uc_ttl = -1; | ||
1114 | |||
1115 | /* Unhash it so that IP input processing does not even | ||
1116 | * see it, we do not wish this socket to see incoming | ||
1117 | * packets. | ||
1118 | */ | ||
1119 | dccp_v4_ctl_socket->sk->sk_prot->unhash(dccp_v4_ctl_socket->sk); | ||
1120 | } | ||
1121 | |||
1122 | return rc; | ||
1123 | } | ||
1124 | |||
1125 | static int __init dccp_v4_init(void) | 1102 | static int __init dccp_v4_init(void) |
1126 | { | 1103 | { |
1127 | int err = proto_register(&dccp_v4_prot, 1); | 1104 | int err = proto_register(&dccp_v4_prot, 1); |
@@ -1135,7 +1112,8 @@ static int __init dccp_v4_init(void) | |||
1135 | 1112 | ||
1136 | inet_register_protosw(&dccp_v4_protosw); | 1113 | inet_register_protosw(&dccp_v4_protosw); |
1137 | 1114 | ||
1138 | err = dccp_v4_ctl_sock_init(); | 1115 | err = inet_csk_ctl_sock_create(&dccp_v4_ctl_socket, PF_INET, |
1116 | SOCK_DCCP, IPPROTO_DCCP); | ||
1139 | if (err) | 1117 | if (err) |
1140 | goto out_unregister_protosw; | 1118 | goto out_unregister_protosw; |
1141 | out: | 1119 | out: |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 3c9f0836404f..6bd9979334a2 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -1229,29 +1229,6 @@ static struct inet_protosw dccp_v6_protosw = { | |||
1229 | .flags = INET_PROTOSW_ICSK, | 1229 | .flags = INET_PROTOSW_ICSK, |
1230 | }; | 1230 | }; |
1231 | 1231 | ||
1232 | static char dccp_v6_ctl_socket_err_msg[] __initdata = | ||
1233 | KERN_ERR "DCCP: Failed to create the control socket.\n"; | ||
1234 | |||
1235 | static int __init dccp_v6_ctl_sock_init(void) | ||
1236 | { | ||
1237 | int rc = sock_create_kern(PF_INET6, SOCK_DCCP, IPPROTO_DCCP, | ||
1238 | &dccp_v6_ctl_socket); | ||
1239 | if (rc < 0) | ||
1240 | printk(dccp_v6_ctl_socket_err_msg); | ||
1241 | else { | ||
1242 | dccp_v6_ctl_socket->sk->sk_allocation = GFP_ATOMIC; | ||
1243 | inet_sk(dccp_v6_ctl_socket->sk)->uc_ttl = -1; | ||
1244 | |||
1245 | /* Unhash it so that IP input processing does not even | ||
1246 | * see it, we do not wish this socket to see incoming | ||
1247 | * packets. | ||
1248 | */ | ||
1249 | dccp_v6_ctl_socket->sk->sk_prot->unhash(dccp_v6_ctl_socket->sk); | ||
1250 | } | ||
1251 | |||
1252 | return rc; | ||
1253 | } | ||
1254 | |||
1255 | static int __init dccp_v6_init(void) | 1232 | static int __init dccp_v6_init(void) |
1256 | { | 1233 | { |
1257 | int err = proto_register(&dccp_v6_prot, 1); | 1234 | int err = proto_register(&dccp_v6_prot, 1); |
@@ -1265,7 +1242,9 @@ static int __init dccp_v6_init(void) | |||
1265 | 1242 | ||
1266 | inet6_register_protosw(&dccp_v6_protosw); | 1243 | inet6_register_protosw(&dccp_v6_protosw); |
1267 | 1244 | ||
1268 | if (dccp_v6_ctl_sock_init() != 0) | 1245 | err = inet_csk_ctl_sock_create(&dccp_v6_ctl_socket, PF_INET6, |
1246 | SOCK_DCCP, IPPROTO_DCCP); | ||
1247 | if (err != 0) | ||
1269 | goto out_unregister_protosw; | 1248 | goto out_unregister_protosw; |
1270 | out: | 1249 | out: |
1271 | return err; | 1250 | return err; |
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); |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 14de50380f4e..af6a0c60f903 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -1605,21 +1605,12 @@ static struct inet_protosw tcpv6_protosw = { | |||
1605 | 1605 | ||
1606 | void __init tcpv6_init(void) | 1606 | void __init tcpv6_init(void) |
1607 | { | 1607 | { |
1608 | int err; | ||
1609 | |||
1610 | /* register inet6 protocol */ | 1608 | /* register inet6 protocol */ |
1611 | if (inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP) < 0) | 1609 | if (inet6_add_protocol(&tcpv6_protocol, IPPROTO_TCP) < 0) |
1612 | printk(KERN_ERR "tcpv6_init: Could not register protocol\n"); | 1610 | printk(KERN_ERR "tcpv6_init: Could not register protocol\n"); |
1613 | inet6_register_protosw(&tcpv6_protosw); | 1611 | inet6_register_protosw(&tcpv6_protosw); |
1614 | 1612 | ||
1615 | err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_TCP, &tcp6_socket); | 1613 | if (inet_csk_ctl_sock_create(&tcp6_socket, PF_INET6, SOCK_RAW, |
1616 | if (err < 0) | 1614 | IPPROTO_TCP) < 0) |
1617 | panic("Failed to create the TCPv6 control socket.\n"); | 1615 | panic("Failed to create the TCPv6 control socket.\n"); |
1618 | tcp6_socket->sk->sk_allocation = GFP_ATOMIC; | ||
1619 | |||
1620 | /* Unhash it so that IP input processing does not even | ||
1621 | * see it, we do not wish this socket to see incoming | ||
1622 | * packets. | ||
1623 | */ | ||
1624 | tcp6_socket->sk->sk_prot->unhash(tcp6_socket->sk); | ||
1625 | } | 1616 | } |