summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-11-01 00:10:50 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-12-04 14:34:04 -0500
commitff24870f46d51d79fc74a241fd7c12ccb933c69f (patch)
treeb299fc2763544955adb7d286a4bfc3a4f9a3f526 /net/core
parent58be28256d98a6b996b20f49130ea11afb8de75a (diff)
downloadlinux-ff24870f46d51d79fc74a241fd7c12ccb933c69f.tar.gz
linux-ff24870f46d51d79fc74a241fd7c12ccb933c69f.tar.bz2
linux-ff24870f46d51d79fc74a241fd7c12ccb933c69f.zip
netns: switch ->get()/->put()/->install()/->inum() to working with &net->ns
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/net_namespace.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index f2f756ce99d7..97f4dc2132ad 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -347,7 +347,7 @@ struct net *get_net_ns_by_fd(int fd)
ei = get_proc_ns(file_inode(file));
if (ei->ns_ops == &netns_operations)
- net = get_net(ei->ns);
+ net = get_net(container_of(ei->ns, struct net, ns));
else
net = ERR_PTR(-EINVAL);
@@ -640,17 +640,22 @@ static void *netns_get(struct task_struct *task)
net = get_net(nsproxy->net_ns);
task_unlock(task);
- return net;
+ return net ? &net->ns : NULL;
+}
+
+static inline struct net *to_net_ns(struct ns_common *ns)
+{
+ return container_of(ns, struct net, ns);
}
static void netns_put(void *ns)
{
- put_net(ns);
+ put_net(to_net_ns(ns));
}
static int netns_install(struct nsproxy *nsproxy, void *ns)
{
- struct net *net = ns;
+ struct net *net = to_net_ns(ns);
if (!ns_capable(net->user_ns, CAP_SYS_ADMIN) ||
!ns_capable(current_user_ns(), CAP_SYS_ADMIN))
@@ -663,8 +668,7 @@ static int netns_install(struct nsproxy *nsproxy, void *ns)
static unsigned int netns_inum(void *ns)
{
- struct net *net = ns;
- return net->ns.inum;
+ return ((struct ns_common *)ns)->inum;
}
const struct proc_ns_operations netns_operations = {