]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - net/core/net_namespace.c
netns: add and use net_ns_barrier
[mirror_ubuntu-artful-kernel.git] / net / core / net_namespace.c
index 1934efd4a9d4986f3497abc40968fd08c91896b3..1f15abb1d733c702d8dfaf62898db3712bdd90e5 100644 (file)
@@ -482,6 +482,23 @@ static void cleanup_net(struct work_struct *work)
                net_drop_ns(net);
        }
 }
+
+/**
+ * net_ns_barrier - wait until concurrent net_cleanup_work is done
+ *
+ * cleanup_net runs from work queue and will first remove namespaces
+ * from the global list, then run net exit functions.
+ *
+ * Call this in module exit path to make sure that all netns
+ * ->exit ops have been invoked before the function is removed.
+ */
+void net_ns_barrier(void)
+{
+       mutex_lock(&net_mutex);
+       mutex_unlock(&net_mutex);
+}
+EXPORT_SYMBOL(net_ns_barrier);
+
 static DECLARE_WORK(net_cleanup_work, cleanup_net);
 
 void __put_net(struct net *net)