[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH RFC 6/8] netns: introduce netns_get_inum()



This allows other parts of the kernel to have access to userspace
visible namespace identification.

Signed-off-by: Aristeu Rozanski <arozansk redhat com>
---
 include/net/net_namespace.h |    1 +
 net/core/net_namespace.c    |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index de644bc..bb24cf4 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -134,6 +134,7 @@ extern struct net init_net;
 #ifdef CONFIG_NET_NS
 extern struct net *copy_net_ns(unsigned long flags,
 	struct user_namespace *user_ns, struct net *old_net);
+extern unsigned int netns_get_inum(struct task_struct *tsk);
 
 #else /* CONFIG_NET_NS */
 #include <linux/sched.h>
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 80e271d..76c89e5 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -664,6 +664,20 @@ static unsigned int netns_inum(void *ns)
 	return net->proc_inum;
 }
 
+unsigned int netns_get_inum(struct task_struct *tsk)
+{
+	struct nsproxy *nsproxy;
+	unsigned int rc = 0;
+
+	rcu_read_lock();
+	nsproxy = task_nsproxy(tsk);
+	if (nsproxy)
+		rc = netns_inum(nsproxy->net_ns);
+	rcu_read_unlock();
+
+	return rc;
+}
+
 const struct proc_ns_operations netns_operations = {
 	.name		= "net",
 	.type		= CLONE_NEWNET,
-- 
1.7.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]