summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2011-05-12 13:51:13 +1000
committerEric W. Biederman <ebiederm@xmission.com>2011-05-24 15:30:51 -0700
commit956c920786694f51601a0ef7ee12956fd6aa216e (patch)
tree3d90cca04df011fbe01bdffb589e941b168ea550 /net
parent62ca24baf1417e56fd2ae4ff07adfe7f6a2e42fc (diff)
downloadlinux-3.10-956c920786694f51601a0ef7ee12956fd6aa216e.tar.gz
linux-3.10-956c920786694f51601a0ef7ee12956fd6aa216e.tar.bz2
linux-3.10-956c920786694f51601a0ef7ee12956fd6aa216e.zip
net: fix get_net_ns_by_fd for !CONFIG_NET_NS
After merging the final tree, today's linux-next build (powerpc ppc44x_defconfig) failed like this: net/built-in.o: In function `get_net_ns_by_fd': (.text+0x11976): undefined reference to `netns_operations' net/built-in.o: In function `get_net_ns_by_fd': (.text+0x1197a): undefined reference to `netns_operations' netns_operations is only available if CONFIG_NET_NS is set ... Caused by commit f063052947f7 ("net: Allow setting the network namespace by fd"). Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'net')
-rw-r--r--net/core/net_namespace.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index b7403ff4d6c..d4cf178bdfc 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -316,6 +316,28 @@ 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)
{
@@ -323,6 +345,11 @@ struct net *copy_net_ns(unsigned long flags, struct net *old_net)
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)
@@ -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;