[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m1bp7oq1u8.fsf@fess.ebiederm.org>
Date: Thu, 23 Sep 2010 01:51:59 -0700
From: ebiederm@...ssion.com (Eric W. Biederman)
To: <linux-kernel@...r.kernel.org>
Cc: Linux Containers <containers@...ts.osdl.org>,
<netdev@...r.kernel.org>, netfilter-devel@...r.kernel.org,
<linux-fsdevel@...r.kernel.org>, jamal <hadi@...erus.ca>,
Daniel Lezcano <daniel.lezcano@...e.fr>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Michael Kerrisk <mtk.manpages@...il.com>,
Ulrich Drepper <drepper@...il.com>,
Al Viro <viro@...IV.linux.org.uk>,
David Miller <davem@...emloft.net>,
"Serge E. Hallyn" <serge@...lyn.com>,
Pavel Emelyanov <xemul@...nvz.org>,
Pavel Emelyanov <xemul@...allels.com>,
Ben Greear <greearb@...delatech.com>,
Matt Helsley <matthltc@...ibm.com>,
Jonathan Corbet <corbet@....net>,
Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>,
Jan Engelhardt <jengelh@...ozas.de>,
Patrick McHardy <kaber@...sh.net>
Subject: [PATCH 8/8] net: Implement socketat.
Add a system call for creating sockets in a specified network namespace.
Signed-off-by: Eric W. Biederman <ebiederm@...ssion.com>
---
net/socket.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index 2270b94..1116f3c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1269,7 +1269,7 @@ int sock_create_kern(int family, int type, int protocol, struct socket **res)
}
EXPORT_SYMBOL(sock_create_kern);
-SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
+static int do_socket(struct net *net, int family, int type, int protocol)
{
int retval;
struct socket *sock;
@@ -1289,7 +1289,7 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
- retval = sock_create(family, type, protocol, &sock);
+ retval = __sock_create(net, family, type, protocol, &sock, 0);
if (retval < 0)
goto out;
@@ -1306,6 +1306,28 @@ out_release:
return retval;
}
+SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
+{
+ return do_socket(current->nsproxy->net_ns, family, type, protocol);
+}
+
+SYSCALL_DEFINE4(socketat, int, fd, int, family, int, type, int, protocol)
+{
+ struct net *net;
+ int retval;
+
+ if (fd == -1) {
+ net = get_net(current->nsproxy->net_ns);
+ } else {
+ net = get_net_ns_by_fd(fd);
+ if (IS_ERR(net))
+ return PTR_ERR(net);
+ }
+ retval = do_socket(net, family, type, protocol);
+ put_net(net);
+ return retval;
+}
+
/*
* Create a pair of connected sockets.
*/
--
1.6.5.2.143.g8cc62
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists