aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-03 17:28:30 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-03 17:28:30 -0400
commit5677242f432102dea9e6eceec1dc089e2f709ca4 (patch)
tree73036437b91f2e8cd5427be48a588bff3af587eb
parenteee4fe4ded6e9c196168aee8f9787771f4df9c90 (diff)
[NETNS]: Inet control socket should not hold a namespace.
This is a generic requirement, so make inet_ctl_sock_create namespace aware and create a inet_ctl_sock_destroy wrapper around sk_release_kernel. Signed-off-by: Denis V. Lunev <den@openvz.org> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/inet_common.h8
-rw-r--r--net/dccp/ipv4.c4
-rw-r--r--net/dccp/ipv6.c4
-rw-r--r--net/ipv4/af_inet.c5
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv6/tcp_ipv6.c14
-rw-r--r--net/sctp/protocol.c6
7 files changed, 22 insertions, 21 deletions
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index 4bfcf3f3555f..18c773286b91 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -42,7 +42,13 @@ extern int inet_ioctl(struct socket *sock,
42extern int inet_ctl_sock_create(struct sock **sk, 42extern int inet_ctl_sock_create(struct sock **sk,
43 unsigned short family, 43 unsigned short family,
44 unsigned short type, 44 unsigned short type,
45 unsigned char protocol); 45 unsigned char protocol,
46 struct net *net);
47
48static inline void inet_ctl_sock_destroy(struct sock *sk)
49{
50 sk_release_kernel(sk);
51}
46 52
47#endif 53#endif
48 54
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 5669c895c873..b12803bcba56 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -1003,7 +1003,7 @@ static int __init dccp_v4_init(void)
1003 inet_register_protosw(&dccp_v4_protosw); 1003 inet_register_protosw(&dccp_v4_protosw);
1004 1004
1005 err = inet_ctl_sock_create(&dccp_v4_ctl_sk, PF_INET, 1005 err = inet_ctl_sock_create(&dccp_v4_ctl_sk, PF_INET,
1006 SOCK_DCCP, IPPROTO_DCCP); 1006 SOCK_DCCP, IPPROTO_DCCP, &init_net);
1007 if (err) 1007 if (err)
1008 goto out_unregister_protosw; 1008 goto out_unregister_protosw;
1009out: 1009out:
@@ -1018,7 +1018,7 @@ out_proto_unregister:
1018 1018
1019static void __exit dccp_v4_exit(void) 1019static void __exit dccp_v4_exit(void)
1020{ 1020{
1021 sock_release(dccp_v4_ctl_sk->sk_socket); 1021 inet_ctl_sock_destroy(dccp_v4_ctl_sk);
1022 inet_unregister_protosw(&dccp_v4_protosw); 1022 inet_unregister_protosw(&dccp_v4_protosw);
1023 inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP); 1023 inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
1024 proto_unregister(&dccp_v4_prot); 1024 proto_unregister(&dccp_v4_prot);
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index cf598bfc6a18..94d749e6d494 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1185,7 +1185,7 @@ static int __init dccp_v6_init(void)
1185 inet6_register_protosw(&dccp_v6_protosw); 1185 inet6_register_protosw(&dccp_v6_protosw);
1186 1186
1187 err = inet_ctl_sock_create(&dccp_v6_ctl_sk, PF_INET6, 1187 err = inet_ctl_sock_create(&dccp_v6_ctl_sk, PF_INET6,
1188 SOCK_DCCP, IPPROTO_DCCP); 1188 SOCK_DCCP, IPPROTO_DCCP, &init_net);
1189 if (err != 0) 1189 if (err != 0)
1190 goto out_unregister_protosw; 1190 goto out_unregister_protosw;
1191out: 1191out:
@@ -1200,7 +1200,7 @@ out_unregister_proto:
1200 1200
1201static void __exit dccp_v6_exit(void) 1201static void __exit dccp_v6_exit(void)
1202{ 1202{
1203 sock_release(dccp_v6_ctl_sk->sk_socket); 1203 inet_ctl_sock_destroy(dccp_v6_ctl_sk);
1204 inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP); 1204 inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
1205 inet6_unregister_protosw(&dccp_v6_protosw); 1205 inet6_unregister_protosw(&dccp_v6_protosw);
1206 proto_unregister(&dccp_v6_prot); 1206 proto_unregister(&dccp_v6_prot);
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index cad664bf3f2e..cf766ad15776 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1251,7 +1251,8 @@ out:
1251} 1251}
1252 1252
1253int inet_ctl_sock_create(struct sock **sk, unsigned short family, 1253int inet_ctl_sock_create(struct sock **sk, unsigned short family,
1254 unsigned short type, unsigned char protocol) 1254 unsigned short type, unsigned char protocol,
1255 struct net *net)
1255{ 1256{
1256 struct socket *sock; 1257 struct socket *sock;
1257 int rc = sock_create_kern(family, type, protocol, &sock); 1258 int rc = sock_create_kern(family, type, protocol, &sock);
@@ -1265,6 +1266,8 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
1265 * we do not wish this socket to see incoming packets. 1266 * we do not wish this socket to see incoming packets.
1266 */ 1267 */
1267 (*sk)->sk_prot->unhash(*sk); 1268 (*sk)->sk_prot->unhash(*sk);
1269
1270 sk_change_net(*sk, net);
1268 } 1271 }
1269 return rc; 1272 return rc;
1270} 1273}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index cfe5df76e14b..dc8c3dc75fe5 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2491,7 +2491,7 @@ struct proto tcp_prot = {
2491void __init tcp_v4_init(void) 2491void __init tcp_v4_init(void)
2492{ 2492{
2493 if (inet_ctl_sock_create(&tcp_sock, PF_INET, SOCK_RAW, 2493 if (inet_ctl_sock_create(&tcp_sock, PF_INET, SOCK_RAW,
2494 IPPROTO_TCP) < 0) 2494 IPPROTO_TCP, &init_net) < 0)
2495 panic("Failed to create the TCP control socket.\n"); 2495 panic("Failed to create the TCP control socket.\n");
2496} 2496}
2497 2497
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 2882cc51669e..378cc4002a76 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2199,21 +2199,13 @@ static struct inet_protosw tcpv6_protosw = {
2199 2199
2200static int tcpv6_net_init(struct net *net) 2200static int tcpv6_net_init(struct net *net)
2201{ 2201{
2202 int err; 2202 return inet_ctl_sock_create(&net->ipv6.tcp_sk, PF_INET6,
2203 struct sock *sk; 2203 SOCK_RAW, IPPROTO_TCP, net);
2204
2205 err = inet_ctl_sock_create(&sk, PF_INET6, SOCK_RAW, IPPROTO_TCP);
2206 if (err)
2207 return err;
2208
2209 net->ipv6.tcp_sk = sk;
2210 sk_change_net(sk, net);
2211 return err;
2212} 2204}
2213 2205
2214static void tcpv6_net_exit(struct net *net) 2206static void tcpv6_net_exit(struct net *net)
2215{ 2207{
2216 sk_release_kernel(net->ipv6.tcp_sk); 2208 inet_ctl_sock_destroy(net->ipv6.tcp_sk);
2217} 2209}
2218 2210
2219static struct pernet_operations tcpv6_net_ops = { 2211static struct pernet_operations tcpv6_net_ops = {
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 3c08d334d4a8..067c8a1658d6 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -681,7 +681,7 @@ static int sctp_ctl_sock_init(void)
681 family = PF_INET; 681 family = PF_INET;
682 682
683 err = inet_ctl_sock_create(&sctp_ctl_sock, family, 683 err = inet_ctl_sock_create(&sctp_ctl_sock, family,
684 SOCK_SEQPACKET, IPPROTO_SCTP); 684 SOCK_SEQPACKET, IPPROTO_SCTP, &init_net);
685 if (err < 0) { 685 if (err < 0) {
686 printk(KERN_ERR 686 printk(KERN_ERR
687 "SCTP: Failed to create the SCTP control socket.\n"); 687 "SCTP: Failed to create the SCTP control socket.\n");
@@ -1284,7 +1284,7 @@ err_v6_add_protocol:
1284 sctp_v6_del_protocol(); 1284 sctp_v6_del_protocol();
1285err_add_protocol: 1285err_add_protocol:
1286 sctp_v4_del_protocol(); 1286 sctp_v4_del_protocol();
1287 sock_release(sctp_ctl_sock->sk_socket); 1287 inet_ctl_sock_destroy(sctp_ctl_sock);
1288err_ctl_sock_init: 1288err_ctl_sock_init:
1289 sctp_v6_protosw_exit(); 1289 sctp_v6_protosw_exit();
1290err_v6_protosw_init: 1290err_v6_protosw_init:
@@ -1328,7 +1328,7 @@ SCTP_STATIC __exit void sctp_exit(void)
1328 sctp_v4_del_protocol(); 1328 sctp_v4_del_protocol();
1329 1329
1330 /* Free the control endpoint. */ 1330 /* Free the control endpoint. */
1331 sock_release(sctp_ctl_sock->sk_socket); 1331 inet_ctl_sock_destroy(sctp_ctl_sock);
1332 1332
1333 /* Free protosw registrations */ 1333 /* Free protosw registrations */
1334 sctp_v6_protosw_exit(); 1334 sctp_v6_protosw_exit();