diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-01 00:10:50 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-04 14:34:04 -0500 |
commit | ff24870f46d51d79fc74a241fd7c12ccb933c69f (patch) | |
tree | b299fc2763544955adb7d286a4bfc3a4f9a3f526 /net | |
parent | 58be28256d98a6b996b20f49130ea11afb8de75a (diff) |
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')
-rw-r--r-- | net/core/net_namespace.c | 16 |
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) | |||
347 | 347 | ||
348 | ei = get_proc_ns(file_inode(file)); | 348 | ei = get_proc_ns(file_inode(file)); |
349 | if (ei->ns_ops == &netns_operations) | 349 | if (ei->ns_ops == &netns_operations) |
350 | net = get_net(ei->ns); | 350 | net = get_net(container_of(ei->ns, struct net, ns)); |
351 | else | 351 | else |
352 | net = ERR_PTR(-EINVAL); | 352 | net = ERR_PTR(-EINVAL); |
353 | 353 | ||
@@ -640,17 +640,22 @@ static void *netns_get(struct task_struct *task) | |||
640 | net = get_net(nsproxy->net_ns); | 640 | net = get_net(nsproxy->net_ns); |
641 | task_unlock(task); | 641 | task_unlock(task); |
642 | 642 | ||
643 | return net; | 643 | return net ? &net->ns : NULL; |
644 | } | ||
645 | |||
646 | static inline struct net *to_net_ns(struct ns_common *ns) | ||
647 | { | ||
648 | return container_of(ns, struct net, ns); | ||
644 | } | 649 | } |
645 | 650 | ||
646 | static void netns_put(void *ns) | 651 | static void netns_put(void *ns) |
647 | { | 652 | { |
648 | put_net(ns); | 653 | put_net(to_net_ns(ns)); |
649 | } | 654 | } |
650 | 655 | ||
651 | static int netns_install(struct nsproxy *nsproxy, void *ns) | 656 | static int netns_install(struct nsproxy *nsproxy, void *ns) |
652 | { | 657 | { |
653 | struct net *net = ns; | 658 | struct net *net = to_net_ns(ns); |
654 | 659 | ||
655 | if (!ns_capable(net->user_ns, CAP_SYS_ADMIN) || | 660 | if (!ns_capable(net->user_ns, CAP_SYS_ADMIN) || |
656 | !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) | 661 | !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) |
@@ -663,8 +668,7 @@ static int netns_install(struct nsproxy *nsproxy, void *ns) | |||
663 | 668 | ||
664 | static unsigned int netns_inum(void *ns) | 669 | static unsigned int netns_inum(void *ns) |
665 | { | 670 | { |
666 | struct net *net = ns; | 671 | return ((struct ns_common *)ns)->inum; |
667 | return net->ns.inum; | ||
668 | } | 672 | } |
669 | 673 | ||
670 | const struct proc_ns_operations netns_operations = { | 674 | const struct proc_ns_operations netns_operations = { |