summaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2010-10-04 16:54:55 +0400
committerJ. Bruce Fields <bfields@redhat.com>2010-10-19 10:48:15 -0400
commit22d44a7d8a03456aa6d0a047c051aa28728e6ecd (patch)
tree63ab8ec64240e7273a7628c64e9f4b728a5b5d6b /net/sunrpc
parent22f793268de3b4dff8abfcd873ba7afc1f34224f (diff)
downloadop-kernel-dev-22d44a7d8a03456aa6d0a047c051aa28728e6ecd.zip
op-kernel-dev-22d44a7d8a03456aa6d0a047c051aa28728e6ecd.tar.gz
sunrpc: Factor out v6 sockets creation
Same patch for v6 protocols. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/xprtsock.c63
1 files changed, 26 insertions, 37 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index b73a605..96128d0 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1655,6 +1655,30 @@ out:
return ERR_PTR(err);
}
+static struct socket *xs_create_sock6(struct rpc_xprt *xprt,
+ struct sock_xprt *transport, int type, int protocol)
+{
+ struct socket *sock;
+ int err;
+
+ err = __sock_create(xprt->xprt_net, PF_INET6, type, protocol, &sock, 1);
+ if (err < 0) {
+ dprintk("RPC: can't create %d transport socket (%d).\n",
+ protocol, -err);
+ goto out;
+ }
+ xs_reclassify_socket6(sock);
+
+ if (xs_bind6(transport, sock)) {
+ sock_release(sock);
+ goto out;
+ }
+
+ return sock;
+out:
+ return ERR_PTR(err);
+}
+
static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
{
struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
@@ -1745,24 +1769,7 @@ static void xs_udp_connect_worker4(struct work_struct *work)
static struct socket *xs_create_udp_sock6(struct rpc_xprt *xprt,
struct sock_xprt *transport)
{
- struct socket *sock;
- int err;
-
- err = __sock_create(xprt->xprt_net, PF_INET6, SOCK_DGRAM, IPPROTO_UDP, &sock, 1);
- if (err < 0) {
- dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
- goto out;
- }
- xs_reclassify_socket6(sock);
-
- if (xs_bind6(transport, sock) < 0) {
- sock_release(sock);
- goto out;
- }
-
- return sock;
-out:
- return ERR_PTR(err);
+ return xs_create_sock6(xprt, transport, SOCK_DGRAM, IPPROTO_UDP);
}
static void xs_udp_connect_worker6(struct work_struct *work)
@@ -1970,25 +1977,7 @@ static void xs_tcp_connect_worker4(struct work_struct *work)
static struct socket *xs_create_tcp_sock6(struct rpc_xprt *xprt,
struct sock_xprt *transport)
{
- struct socket *sock;
- int err;
-
- /* start from scratch */
- err = __sock_create(xprt->xprt_net, PF_INET6, SOCK_STREAM, IPPROTO_TCP, &sock, 1);
- if (err < 0) {
- dprintk("RPC: can't create TCP transport socket (%d).\n",
- -err);
- goto out_err;
- }
- xs_reclassify_socket6(sock);
-
- if (xs_bind6(transport, sock) < 0) {
- sock_release(sock);
- goto out_err;
- }
- return sock;
-out_err:
- return ERR_PTR(-EIO);
+ return xs_create_sock6(xprt, transport, SOCK_STREAM, IPPROTO_TCP);
}
/**
OpenPOWER on IntegriCloud