From 33c96e422ede544c9a6ea1af62eb330011845913 Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Sun, 7 Mar 2010 18:14:23 -0800 Subject: [PATCH] --- yaml --- r: 251667 b: refs/heads/master c: 13b6f57623bc485e116344fe91fbcb29f149242b h: refs/heads/master i: 251665: c35331f40b379dd7eb747b6ab6341f2dfb8f6887 251663: 415b85847839cbbb56024573bd89c6451ec5932d v: v3 --- [refs] | 2 +- trunk/fs/proc/namespaces.c | 3 +++ trunk/include/linux/proc_fs.h | 1 + trunk/net/core/net_namespace.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 46cf82135588..391f4050c718 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0663c6f8fa37d777ede74ff991a0cba3a42fcbd7 +refs/heads/master: 13b6f57623bc485e116344fe91fbcb29f149242b diff --git a/trunk/fs/proc/namespaces.c b/trunk/fs/proc/namespaces.c index 6ae9f07d59ee..dcbd483e9915 100644 --- a/trunk/fs/proc/namespaces.c +++ b/trunk/fs/proc/namespaces.c @@ -16,6 +16,9 @@ static const struct proc_ns_operations *ns_entries[] = { +#ifdef CONFIG_NET_NS + &netns_operations, +#endif }; static const struct file_operations ns_file_operations = { diff --git a/trunk/include/linux/proc_fs.h b/trunk/include/linux/proc_fs.h index a6d2c6da5e5a..62126ec6ede9 100644 --- a/trunk/include/linux/proc_fs.h +++ b/trunk/include/linux/proc_fs.h @@ -265,6 +265,7 @@ struct proc_ns_operations { void (*put)(void *ns); int (*install)(struct nsproxy *nsproxy, void *ns); }; +extern const struct proc_ns_operations netns_operations; union proc_op { int (*proc_get_link)(struct inode *, struct path *); diff --git a/trunk/net/core/net_namespace.c b/trunk/net/core/net_namespace.c index 3f860261c5ee..bf7707e09a80 100644 --- a/trunk/net/core/net_namespace.c +++ b/trunk/net/core/net_namespace.c @@ -573,3 +573,34 @@ void unregister_pernet_device(struct pernet_operations *ops) mutex_unlock(&net_mutex); } EXPORT_SYMBOL_GPL(unregister_pernet_device); + +#ifdef CONFIG_NET_NS +static void *netns_get(struct task_struct *task) +{ + struct net *net; + rcu_read_lock(); + net = get_net(task->nsproxy->net_ns); + rcu_read_unlock(); + return net; +} + +static void netns_put(void *ns) +{ + put_net(ns); +} + +static int netns_install(struct nsproxy *nsproxy, void *ns) +{ + put_net(nsproxy->net_ns); + nsproxy->net_ns = get_net(ns); + return 0; +} + +const struct proc_ns_operations netns_operations = { + .name = "net", + .type = CLONE_NEWNET, + .get = netns_get, + .put = netns_put, + .install = netns_install, +}; +#endif