diff options
| author | Denis V. Lunev <den@openvz.org> | 2007-11-13 06:23:21 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2007-11-13 06:23:21 -0500 |
| commit | ed160e839d2e1118529e58b04d52dba703ca629c (patch) | |
| tree | be810664611452c2af170116e8deff2baa8cb916 | |
| parent | 072ee3f9bd26a2f89a79d1eae9052d30b8d745a5 (diff) | |
[NET]: Cleanup pernet operation without CONFIG_NET_NS
If CONFIG_NET_NS is not set, the only namespace is possible.
This patch removes list of pernet_operations and cleanups code a bit.
This list is not needed if there are no namespaces. We should just call
->init method.
Additionally, the ->exit will be called on module unloading only. This
case is safe - the code is not discarded. For the in/kernel code, ->exit
should never be called.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/core/net_namespace.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 3f6d37deac45..383252b50411 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
| @@ -188,6 +188,7 @@ static int __init net_ns_init(void) | |||
| 188 | 188 | ||
| 189 | pure_initcall(net_ns_init); | 189 | pure_initcall(net_ns_init); |
| 190 | 190 | ||
| 191 | #ifdef CONFIG_NET_NS | ||
| 191 | static int register_pernet_operations(struct list_head *list, | 192 | static int register_pernet_operations(struct list_head *list, |
| 192 | struct pernet_operations *ops) | 193 | struct pernet_operations *ops) |
| 193 | { | 194 | { |
| @@ -228,6 +229,23 @@ static void unregister_pernet_operations(struct pernet_operations *ops) | |||
| 228 | ops->exit(net); | 229 | ops->exit(net); |
| 229 | } | 230 | } |
| 230 | 231 | ||
| 232 | #else | ||
| 233 | |||
| 234 | static int register_pernet_operations(struct list_head *list, | ||
| 235 | struct pernet_operations *ops) | ||
| 236 | { | ||
| 237 | if (ops->init == NULL) | ||
| 238 | return 0; | ||
| 239 | return ops->init(&init_net); | ||
| 240 | } | ||
| 241 | |||
| 242 | static void unregister_pernet_operations(struct pernet_operations *ops) | ||
| 243 | { | ||
| 244 | if (ops->exit) | ||
| 245 | ops->exit(&init_net); | ||
| 246 | } | ||
| 247 | #endif | ||
| 248 | |||
| 231 | /** | 249 | /** |
| 232 | * register_pernet_subsys - register a network namespace subsystem | 250 | * register_pernet_subsys - register a network namespace subsystem |
| 233 | * @ops: pernet operations structure for the subsystem | 251 | * @ops: pernet operations structure for the subsystem |
