Skip to contentSkip to conversation

cleanup pernet operation without CONFIG_NET_NS

PATCH Applied Denis V. Lunev 3 participants 3 messages Nov 7, 2007 – Nov 15, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 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.

net/core/net_namespace.c renamed from net/core/net_namespace.c.netinitdata +18 -0
@@ -179,6 +180,7 @@ static int __init net_ns_init(void)
 
 pure_initcall(net_ns_init);
 
+#ifdef CONFIG_NET_NS
 static int register_pernet_operations(struct list_head *list,
 				      struct pernet_operations *ops)
 {
@@ -220,6 +222,23 @@ static void unregister_pernet_operations
 			ops->exit(net);
 }
 
+#else
+
+static int register_pernet_operations(struct list_head *list,
+				      struct pernet_operations *ops)
+{
+	if (ops->init == NULL)
+		return 0;
+	return ops->init(&init_net);
+}
+
+static void unregister_pernet_operations(struct pernet_operations *ops)
+{
+	if (ops->exit)
+		ops->exit(&init_net);
+}
+#endif
+
 /**
  *      register_pernet_subsys - register a network namespace subsystem
  *	@ops:  pernet operations structure for the subsystem
maintainer Applied
#1 lore raw

From: "Denis V. Lunev" <[email protected]>
Date: Wed, 7 Nov 2007 15:00:07 +0300

Quoted 11 lines

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.

Applied.

#2 lore raw
In reply to Denis V. Lunev
Quoted 9 lines · Denis V. Lunev

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.

This patch looks sane, and reasonable in the !CONFIG_NET_NS case.

Eric