Merge branch 'oprofile-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[platform/kernel/linux-rpi.git] / net / core / net_namespace.c
index f1d07b5..55cffad 100644 (file)
@@ -47,7 +47,6 @@ static __net_init int setup_net(struct net *net)
                goto out;
 
        ng->len = INITIAL_NET_GEN_PTRS;
-       INIT_RCU_HEAD(&ng->rcu);
        rcu_assign_pointer(net->gen, ng);
 
        error = 0;
@@ -325,6 +324,38 @@ void unregister_pernet_subsys(struct pernet_operations *module)
 }
 EXPORT_SYMBOL_GPL(unregister_pernet_subsys);
 
+int register_pernet_gen_subsys(int *id, struct pernet_operations *ops)
+{
+       int rv;
+
+       mutex_lock(&net_mutex);
+again:
+       rv = ida_get_new_above(&net_generic_ids, 1, id);
+       if (rv < 0) {
+               if (rv == -EAGAIN) {
+                       ida_pre_get(&net_generic_ids, GFP_KERNEL);
+                       goto again;
+               }
+               goto out;
+       }
+       rv = register_pernet_operations(first_device, ops);
+       if (rv < 0)
+               ida_remove(&net_generic_ids, *id);
+       mutex_unlock(&net_mutex);
+out:
+       return rv;
+}
+EXPORT_SYMBOL_GPL(register_pernet_gen_subsys);
+
+void unregister_pernet_gen_subsys(int id, struct pernet_operations *ops)
+{
+       mutex_lock(&net_mutex);
+       unregister_pernet_operations(ops);
+       ida_remove(&net_generic_ids, id);
+       mutex_unlock(&net_mutex);
+}
+EXPORT_SYMBOL_GPL(unregister_pernet_gen_subsys);
+
 /**
  *      register_pernet_device - register a network namespace device
  *     @ops:  pernet operations structure for the subsystem
@@ -446,7 +477,6 @@ int net_assign_generic(struct net *net, int id, void *data)
         */
 
        ng->len = id;
-       INIT_RCU_HEAD(&ng->rcu);
        memcpy(&ng->ptr, &old_ng->ptr, old_ng->len);
 
        rcu_assign_pointer(net->gen, ng);