diff options
author | Ying Xue <ying.xue@windriver.com> | 2015-01-09 02:27:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-12 16:24:32 -0500 |
commit | c93d3baa24095887005647984cff5de8c63d3611 (patch) | |
tree | 1c7917d92605991696960243fe97dfef9d14913a /net/tipc/core.c | |
parent | 54fef04ad05f15984082c225fe47ce6af8ea1c5c (diff) |
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.c | 28 |
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; | |||
52 | int tipc_net_id __read_mostly; | 52 | int tipc_net_id __read_mostly; |
53 | int sysctl_tipc_rmem[3] __read_mostly; /* min/default/max */ | 53 | int sysctl_tipc_rmem[3] __read_mostly; /* min/default/max */ |
54 | 54 | ||
55 | static int __net_init tipc_init_net(struct net *net) | ||
56 | { | ||
57 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
58 | |||
59 | tn->net_id = 4711; | ||
60 | |||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static void __net_exit tipc_exit_net(struct net *net) | ||
65 | { | ||
66 | } | ||
67 | |||
68 | static struct pernet_operations tipc_net_ops = { | ||
69 | .init = tipc_init_net, | ||
70 | .exit = tipc_exit_net, | ||
71 | .id = &tipc_net_id, | ||
72 | .size = sizeof(struct tipc_net), | ||
73 | }; | ||
74 | |||
55 | static int __init tipc_init(void) | 75 | static int __init tipc_init(void) |
56 | { | 76 | { |
57 | int err; | 77 | int err; |
@@ -59,7 +79,6 @@ static int __init tipc_init(void) | |||
59 | pr_info("Activated (version " TIPC_MOD_VER ")\n"); | 79 | pr_info("Activated (version " TIPC_MOD_VER ")\n"); |
60 | 80 | ||
61 | tipc_own_addr = 0; | 81 | tipc_own_addr = 0; |
62 | tipc_net_id = 4711; | ||
63 | 82 | ||
64 | sysctl_tipc_rmem[0] = TIPC_CONN_OVERLOAD_LIMIT >> 4 << | 83 | sysctl_tipc_rmem[0] = TIPC_CONN_OVERLOAD_LIMIT >> 4 << |
65 | TIPC_LOW_IMPORTANCE; | 84 | TIPC_LOW_IMPORTANCE; |
@@ -69,6 +88,10 @@ static int __init tipc_init(void) | |||
69 | 88 | ||
70 | get_random_bytes(&tipc_random, sizeof(tipc_random)); | 89 | get_random_bytes(&tipc_random, sizeof(tipc_random)); |
71 | 90 | ||
91 | err = register_pernet_subsys(&tipc_net_ops); | ||
92 | if (err) | ||
93 | goto out_pernet; | ||
94 | |||
72 | err = tipc_sk_rht_init(); | 95 | err = tipc_sk_rht_init(); |
73 | if (err) | 96 | if (err) |
74 | goto out_reftbl; | 97 | goto out_reftbl; |
@@ -112,12 +135,15 @@ out_netlink: | |||
112 | out_nametbl: | 135 | out_nametbl: |
113 | tipc_sk_rht_destroy(); | 136 | tipc_sk_rht_destroy(); |
114 | out_reftbl: | 137 | out_reftbl: |
138 | unregister_pernet_subsys(&tipc_net_ops); | ||
139 | out_pernet: | ||
115 | pr_err("Unable to start in single node mode\n"); | 140 | pr_err("Unable to start in single node mode\n"); |
116 | return err; | 141 | return err; |
117 | } | 142 | } |
118 | 143 | ||
119 | static void __exit tipc_exit(void) | 144 | static void __exit tipc_exit(void) |
120 | { | 145 | { |
146 | unregister_pernet_subsys(&tipc_net_ops); | ||
121 | tipc_net_stop(); | 147 | tipc_net_stop(); |
122 | tipc_bearer_cleanup(); | 148 | tipc_bearer_cleanup(); |
123 | tipc_netlink_stop(); | 149 | tipc_netlink_stop(); |