Skip to content

Commit ed160e8

Browse files
dlunevdavem330
authored andcommitted
[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>
1 parent 072ee3f commit ed160e8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

net/core/net_namespace.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ static int __init net_ns_init(void)
188188

189189
pure_initcall(net_ns_init);
190190

191+
#ifdef CONFIG_NET_NS
191192
static int register_pernet_operations(struct list_head *list,
192193
struct pernet_operations *ops)
193194
{
@@ -228,6 +229,23 @@ static void unregister_pernet_operations(struct pernet_operations *ops)
228229
ops->exit(net);
229230
}
230231

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+
231249
/**
232250
* register_pernet_subsys - register a network namespace subsystem
233251
* @ops: pernet operations structure for the subsystem

0 commit comments

Comments
 (0)