summaryrefslogtreecommitdiffstats
path: root/net/tipc/core.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2015-01-09 15:27:04 +0800
committerDavid S. Miller <davem@davemloft.net>2015-01-12 16:24:32 -0500
commitc93d3baa24095887005647984cff5de8c63d3611 (patch)
tree1c7917d92605991696960243fe97dfef9d14913a /net/tipc/core.c
parent54fef04ad05f15984082c225fe47ce6af8ea1c5c (diff)
downloadlinux-stable-c93d3baa24095887005647984cff5de8c63d3611.tar.gz
linux-stable-c93d3baa24095887005647984cff5de8c63d3611.tar.bz2
linux-stable-c93d3baa24095887005647984cff5de8c63d3611.zip
tipc: involve namespace infrastructure
Involve namespace infrastructure, make the "tipc_net_id" global variable aware of per namespace, and rename it to "net_id". In order that the conversion can be successfully done, an instance of networking namespace must be passed to relevant functions, allowing them to access the "net_id" variable of per namespace. 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.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/net/tipc/core.c b/net/tipc/core.c
index b6ec3d7c5f51..a2302480d8cf 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -52,6 +52,26 @@ u32 tipc_own_addr __read_mostly;
int tipc_net_id __read_mostly;
int sysctl_tipc_rmem[3] __read_mostly; /* min/default/max */
+static int __net_init tipc_init_net(struct net *net)
+{
+ struct tipc_net *tn = net_generic(net, tipc_net_id);
+
+ tn->net_id = 4711;
+
+ return 0;
+}
+
+static void __net_exit tipc_exit_net(struct net *net)
+{
+}
+
+static struct pernet_operations tipc_net_ops = {
+ .init = tipc_init_net,
+ .exit = tipc_exit_net,
+ .id = &tipc_net_id,
+ .size = sizeof(struct tipc_net),
+};
+
static int __init tipc_init(void)
{
int err;
@@ -59,7 +79,6 @@ static int __init tipc_init(void)
pr_info("Activated (version " TIPC_MOD_VER ")\n");
tipc_own_addr = 0;
- tipc_net_id = 4711;
sysctl_tipc_rmem[0] = TIPC_CONN_OVERLOAD_LIMIT >> 4 <<
TIPC_LOW_IMPORTANCE;
@@ -69,6 +88,10 @@ static int __init tipc_init(void)
get_random_bytes(&tipc_random, sizeof(tipc_random));
+ err = register_pernet_subsys(&tipc_net_ops);
+ if (err)
+ goto out_pernet;
+
err = tipc_sk_rht_init();
if (err)
goto out_reftbl;
@@ -112,12 +135,15 @@ out_netlink:
out_nametbl:
tipc_sk_rht_destroy();
out_reftbl:
+ unregister_pernet_subsys(&tipc_net_ops);
+out_pernet:
pr_err("Unable to start in single node mode\n");
return err;
}
static void __exit tipc_exit(void)
{
+ unregister_pernet_subsys(&tipc_net_ops);
tipc_net_stop();
tipc_bearer_cleanup();
tipc_netlink_stop();