]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[NETNS]: Inet control socket should not hold a namespace.
authorDenis V. Lunev <den@openvz.org>
Thu, 3 Apr 2008 21:28:30 +0000 (14:28 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Apr 2008 21:28:30 +0000 (14:28 -0700)
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>
include/net/inet_common.h
net/dccp/ipv4.c
net/dccp/ipv6.c
net/ipv4/af_inet.c
net/ipv4/tcp_ipv4.c
net/ipv6/tcp_ipv6.c
net/sctp/protocol.c

index 4bfcf3f3555f6c8573fcf9e5be2cbff6e0d29727..18c773286b91744ccf0447b60597db3acc353f9a 100644 (file)
@@ -42,7 +42,13 @@ extern int                   inet_ioctl(struct socket *sock,
 extern int                     inet_ctl_sock_create(struct sock **sk,
                                                     unsigned short family,
                                                     unsigned short type,
-                                                    unsigned char protocol);
+                                                    unsigned char protocol,
+                                                    struct net *net);
+
+static inline void inet_ctl_sock_destroy(struct sock *sk)
+{
+       sk_release_kernel(sk);
+}
 
 #endif
 
index 5669c895c8736f4e943bbb81107f992b93d4cd15..b12803bcba56509fa082affba55ae6ba3ae328c2 100644 (file)
@@ -1003,7 +1003,7 @@ static int __init dccp_v4_init(void)
        inet_register_protosw(&dccp_v4_protosw);
 
        err = inet_ctl_sock_create(&dccp_v4_ctl_sk, PF_INET,
-                                  SOCK_DCCP, IPPROTO_DCCP);
+                                  SOCK_DCCP, IPPROTO_DCCP, &init_net);
        if (err)
                goto out_unregister_protosw;
 out:
@@ -1018,7 +1018,7 @@ out_proto_unregister:
 
 static void __exit dccp_v4_exit(void)
 {
-       sock_release(dccp_v4_ctl_sk->sk_socket);
+       inet_ctl_sock_destroy(dccp_v4_ctl_sk);
        inet_unregister_protosw(&dccp_v4_protosw);
        inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
        proto_unregister(&dccp_v4_prot);
index cf598bfc6a18ed01a9d93aa4b00931496b4d0099..94d749e6d49439e77b4593a770abc9020699ef18 100644 (file)
@@ -1185,7 +1185,7 @@ static int __init dccp_v6_init(void)
        inet6_register_protosw(&dccp_v6_protosw);
 
        err = inet_ctl_sock_create(&dccp_v6_ctl_sk, PF_INET6,
-                                  SOCK_DCCP, IPPROTO_DCCP);
+                                  SOCK_DCCP, IPPROTO_DCCP, &init_net);
        if (err != 0)
                goto out_unregister_protosw;
 out:
@@ -1200,7 +1200,7 @@ out_unregister_proto:
 
 static void __exit dccp_v6_exit(void)
 {
-       sock_release(dccp_v6_ctl_sk->sk_socket);
+       inet_ctl_sock_destroy(dccp_v6_ctl_sk);
        inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
        inet6_unregister_protosw(&dccp_v6_protosw);
        proto_unregister(&dccp_v6_prot);
index cad664bf3f2e53311aa74147c33c98f22e09e303..cf766ad15776afa2e4b86d9842b0c0506fdc507c 100644 (file)
@@ -1251,7 +1251,8 @@ out:
 }
 
 int inet_ctl_sock_create(struct sock **sk, unsigned short family,
-                        unsigned short type, unsigned char protocol)
+                        unsigned short type, unsigned char protocol,
+                        struct net *net)
 {
        struct socket *sock;
        int rc = sock_create_kern(family, type, protocol, &sock);
@@ -1265,6 +1266,8 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
                 * we do not wish this socket to see incoming packets.
                 */
                (*sk)->sk_prot->unhash(*sk);
+
+               sk_change_net(*sk, net);
        }
        return rc;
 }
index cfe5df76e14b1ad356369802190171967ad767d0..dc8c3dc75fe5e3cac006c87331ea819b475cfe93 100644 (file)
@@ -2491,7 +2491,7 @@ struct proto tcp_prot = {
 void __init tcp_v4_init(void)
 {
        if (inet_ctl_sock_create(&tcp_sock, PF_INET, SOCK_RAW,
-                                IPPROTO_TCP) < 0)
+                                IPPROTO_TCP, &init_net) < 0)
                panic("Failed to create the TCP control socket.\n");
 }
 
index 2882cc51669e146f2fef29da816a1b112ac19ce2..378cc4002a76c3d2f8226af7698a625fe76bfbec 100644 (file)
@@ -2199,21 +2199,13 @@ static struct inet_protosw tcpv6_protosw = {
 
 static int tcpv6_net_init(struct net *net)
 {
-       int err;
-       struct sock *sk;
-
-       err = inet_ctl_sock_create(&sk, PF_INET6, SOCK_RAW, IPPROTO_TCP);
-       if (err)
-               return err;
-
-       net->ipv6.tcp_sk = sk;
-       sk_change_net(sk, net);
-       return err;
+       return inet_ctl_sock_create(&net->ipv6.tcp_sk, PF_INET6,
+                                   SOCK_RAW, IPPROTO_TCP, net);
 }
 
 static void tcpv6_net_exit(struct net *net)
 {
-       sk_release_kernel(net->ipv6.tcp_sk);
+       inet_ctl_sock_destroy(net->ipv6.tcp_sk);
 }
 
 static struct pernet_operations tcpv6_net_ops = {
index 3c08d334d4a8a97fa33d0472f3aa4f17f672b4c0..067c8a1658d6fbf0872129baeb07ba0f0d7656d6 100644 (file)
@@ -681,7 +681,7 @@ static int sctp_ctl_sock_init(void)
                family = PF_INET;
 
        err = inet_ctl_sock_create(&sctp_ctl_sock, family,
-                                  SOCK_SEQPACKET, IPPROTO_SCTP);
+                                  SOCK_SEQPACKET, IPPROTO_SCTP, &init_net);
        if (err < 0) {
                printk(KERN_ERR
                       "SCTP: Failed to create the SCTP control socket.\n");
@@ -1284,7 +1284,7 @@ err_v6_add_protocol:
        sctp_v6_del_protocol();
 err_add_protocol:
        sctp_v4_del_protocol();
-       sock_release(sctp_ctl_sock->sk_socket);
+       inet_ctl_sock_destroy(sctp_ctl_sock);
 err_ctl_sock_init:
        sctp_v6_protosw_exit();
 err_v6_protosw_init:
@@ -1328,7 +1328,7 @@ SCTP_STATIC __exit void sctp_exit(void)
        sctp_v4_del_protocol();
 
        /* Free the control endpoint.  */
-       sock_release(sctp_ctl_sock->sk_socket);
+       inet_ctl_sock_destroy(sctp_ctl_sock);
 
        /* Free protosw registrations */
        sctp_v6_protosw_exit();