Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 251673
b: refs/heads/master
c: 956c920
h: refs/heads/master
i:
  251671: be26084
v: v3
  • Loading branch information
Stephen Rothwell authored and Eric W. Biederman committed May 24, 2011
1 parent 79753c8 commit 45a69d5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 62ca24baf1417e56fd2ae4ff07adfe7f6a2e42fc
refs/heads/master: 956c920786694f51601a0ef7ee12956fd6aa216e
49 changes: 27 additions & 22 deletions trunk/net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,40 @@ void __put_net(struct net *net)
}
EXPORT_SYMBOL_GPL(__put_net);

struct net *get_net_ns_by_fd(int fd)
{
struct proc_inode *ei;
struct file *file;
struct net *net;

net = ERR_PTR(-EINVAL);
file = proc_ns_fget(fd);
if (!file)
goto out;

ei = PROC_I(file->f_dentry->d_inode);
if (ei->ns_ops != &netns_operations)
goto out;

net = get_net(ei->ns);
out:
if (file)
fput(file);
return net;
}

#else
struct net *copy_net_ns(unsigned long flags, struct net *old_net)
{
if (flags & CLONE_NEWNET)
return ERR_PTR(-EINVAL);
return old_net;
}

struct net *get_net_ns_by_fd(int fd)
{
return ERR_PTR(-EINVAL);
}
#endif

struct net *get_net_ns_by_pid(pid_t pid)
Expand All @@ -345,28 +372,6 @@ struct net *get_net_ns_by_pid(pid_t pid)
}
EXPORT_SYMBOL_GPL(get_net_ns_by_pid);

struct net *get_net_ns_by_fd(int fd)
{
struct proc_inode *ei;
struct file *file;
struct net *net;

net = ERR_PTR(-EINVAL);
file = proc_ns_fget(fd);
if (!file)
goto out;

ei = PROC_I(file->f_dentry->d_inode);
if (ei->ns_ops != &netns_operations)
goto out;

net = get_net(ei->ns);
out:
if (file)
fput(file);
return net;
}

static int __init net_ns_init(void)
{
struct net_generic *ng;
Expand Down

0 comments on commit 45a69d5

Please sign in to comment.