From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aristeu Rozanski Subject: [PATCH RFC 6/8] netns: introduce netns_get_inum() Date: Mon, 18 Mar 2013 11:45:45 -0400 Message-ID: <1363621547-25239-7-git-send-email-arozansk@redhat.com> References: <1363621547-25239-1-git-send-email-arozansk@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1363621547-25239-1-git-send-email-arozansk@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: linux-audit@redhat.com List-Id: linux-audit@redhat.com This allows other parts of the kernel to have access to userspace visible namespace identification. Signed-off-by: Aristeu Rozanski --- 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 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