aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/core.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2015-01-09 02:27:08 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-12 16:24:33 -0500
commite05b31f4bf8994d49322e9afb004ad479a129db0 (patch)
tree7d413a68ee6fdc5ca81b2eec93323433e61753a8 /net/tipc/core.c
parent1da465683a93142488a54a9038155f23d6349441 (diff)
tipc: make tipc socket support net namespace
Now tipc socket table is statically allocated as a global variable. Through it, we can look up one socket instance with port ID, insert a new socket instance to the table, and delete a socket from the table. But when tipc supports net namespace, each namespace must own its specific socket table. So the global variable of socket table must be redefined in tipc_net structure. As a concequence, a new socket table will be allocated when a new namespace is created, and a socket table will be deallocated when namespace is destroyed. Signed-off-by: Ying Xue <ying.xue@windriver.com> Tested-by: Tero Aho <Tero.Aho@coriant.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/core.c')
-rw-r--r--net/tipc/core.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 7b8443938caf..23ff3caa1ce6 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -55,17 +55,20 @@ int sysctl_tipc_rmem[3] __read_mostly; /* min/default/max */
55static int __net_init tipc_init_net(struct net *net) 55static int __net_init tipc_init_net(struct net *net)
56{ 56{
57 struct tipc_net *tn = net_generic(net, tipc_net_id); 57 struct tipc_net *tn = net_generic(net, tipc_net_id);
58 int err;
58 59
59 tn->net_id = 4711; 60 tn->net_id = 4711;
60 INIT_LIST_HEAD(&tn->node_list); 61 INIT_LIST_HEAD(&tn->node_list);
61 spin_lock_init(&tn->node_list_lock); 62 spin_lock_init(&tn->node_list_lock);
62 63
63 return 0; 64 err = tipc_sk_rht_init(net);
65 return err;
64} 66}
65 67
66static void __net_exit tipc_exit_net(struct net *net) 68static void __net_exit tipc_exit_net(struct net *net)
67{ 69{
68 tipc_net_stop(net); 70 tipc_net_stop(net);
71 tipc_sk_rht_destroy(net);
69} 72}
70 73
71static struct pernet_operations tipc_net_ops = { 74static struct pernet_operations tipc_net_ops = {
@@ -95,10 +98,6 @@ static int __init tipc_init(void)
95 if (err) 98 if (err)
96 goto out_pernet; 99 goto out_pernet;
97 100
98 err = tipc_sk_rht_init();
99 if (err)
100 goto out_reftbl;
101
102 err = tipc_nametbl_init(); 101 err = tipc_nametbl_init();
103 if (err) 102 if (err)
104 goto out_nametbl; 103 goto out_nametbl;
@@ -136,8 +135,6 @@ out_socket:
136out_netlink: 135out_netlink:
137 tipc_nametbl_stop(); 136 tipc_nametbl_stop();
138out_nametbl: 137out_nametbl:
139 tipc_sk_rht_destroy();
140out_reftbl:
141 unregister_pernet_subsys(&tipc_net_ops); 138 unregister_pernet_subsys(&tipc_net_ops);
142out_pernet: 139out_pernet:
143 pr_err("Unable to start in single node mode\n"); 140 pr_err("Unable to start in single node mode\n");
@@ -153,7 +150,6 @@ static void __exit tipc_exit(void)
153 tipc_nametbl_stop(); 150 tipc_nametbl_stop();
154 tipc_socket_stop(); 151 tipc_socket_stop();
155 tipc_unregister_sysctl(); 152 tipc_unregister_sysctl();
156 tipc_sk_rht_destroy();
157 153
158 pr_info("Deactivated\n"); 154 pr_info("Deactivated\n");
159} 155}