[NETNS]: Create tcp control socket in the each namespace.
authorDenis V. Lunev <den@openvz.org>
Thu, 3 Apr 2008 21:31:33 +0000 (14:31 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Apr 2008 21:31:33 +0000 (14:31 -0700)
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netns/ipv4.h
net/ipv4/tcp_ipv4.c

index af685f71f4b5bc3a5ed91740caecc252d5c5b312..34ee348a2cf207e9b1522706fa2e7a3b216d1b55 100644 (file)
@@ -28,6 +28,7 @@ struct netns_ipv4 {
        struct sock             *fibnl;
 
        struct sock             **icmp_sk;
+       struct sock             *tcp_sock;
 
        struct netns_frags      frags;
 #ifdef CONFIG_NETFILTER
index dc8c3dc75fe5e3cac006c87331ea819b475cfe93..1d4a77acdc0bd405fd5ae5604412975e799ce155 100644 (file)
@@ -2488,11 +2488,28 @@ struct proto tcp_prot = {
 #endif
 };
 
+
+static int __net_init tcp_sk_init(struct net *net)
+{
+       return inet_ctl_sock_create(&net->ipv4.tcp_sock,
+                                   PF_INET, SOCK_RAW, IPPROTO_TCP, net);
+}
+
+static void __net_exit tcp_sk_exit(struct net *net)
+{
+       inet_ctl_sock_destroy(net->ipv4.tcp_sock);
+}
+
+static struct pernet_operations __net_initdata tcp_sk_ops = {
+       .init = tcp_sk_init,
+       .exit = tcp_sk_exit,
+};
+
 void __init tcp_v4_init(void)
 {
-       if (inet_ctl_sock_create(&tcp_sock, PF_INET, SOCK_RAW,
-                                IPPROTO_TCP, &init_net) < 0)
+       if (register_pernet_device(&tcp_sk_ops))
                panic("Failed to create the TCP control socket.\n");
+       tcp_sock = init_net.ipv4.tcp_sock;
 }
 
 EXPORT_SYMBOL(ipv4_specific);