diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2010-10-04 16:54:26 +0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2010-10-19 10:48:14 -0400 |
commit | 22f793268de3b4dff8abfcd873ba7afc1f34224f (patch) | |
tree | 0e67fb80ab92a83a07cfe2b21648e80e44a281ed /net/sunrpc | |
parent | b65c0310611af73569f94c526a1e2323d99b380a (diff) | |
download | op-kernel-dev-22f793268de3b4dff8abfcd873ba7afc1f34224f.zip op-kernel-dev-22f793268de3b4dff8abfcd873ba7afc1f34224f.tar.gz |
sunrpc: Factor out v4 sockets creation
The UDPv4 and TCPv4 socket creation callbacks now look very similar.
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.c | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index df53dc5..b73a605 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -1631,6 +1631,30 @@ static inline void xs_reclassify_socket6(struct socket *sock) } #endif +static struct socket *xs_create_sock4(struct rpc_xprt *xprt, + struct sock_xprt *transport, int type, int protocol) +{ + struct socket *sock; + int err; + + err = __sock_create(xprt->xprt_net, PF_INET, type, protocol, &sock, 1); + if (err < 0) { + dprintk("RPC: can't create %d transport socket (%d).\n", + protocol, -err); + goto out; + } + xs_reclassify_socket4(sock); + + if (xs_bind4(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); @@ -1700,24 +1724,7 @@ out: static struct socket *xs_create_udp_sock4(struct rpc_xprt *xprt, struct sock_xprt *transport) { - struct socket *sock; - int err; - - err = __sock_create(xprt->xprt_net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock, 1); - if (err < 0) { - dprintk("RPC: can't create UDP transport socket (%d).\n", -err); - goto out; - } - xs_reclassify_socket4(sock); - - if (xs_bind4(transport, sock)) { - sock_release(sock); - goto out; - } - - return sock; -out: - return ERR_PTR(err); + return xs_create_sock4(xprt, transport, SOCK_DGRAM, IPPROTO_UDP); } static void xs_udp_connect_worker4(struct work_struct *work) @@ -1943,25 +1950,7 @@ out: static struct socket *xs_create_tcp_sock4(struct rpc_xprt *xprt, struct sock_xprt *transport) { - struct socket *sock; - int err; - - /* start from scratch */ - err = __sock_create(xprt->xprt_net, PF_INET, 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_socket4(sock); - - if (xs_bind4(transport, sock) < 0) { - sock_release(sock); - goto out_err; - } - return sock; -out_err: - return ERR_PTR(-EIO); + return xs_create_sock4(xprt, transport, SOCK_STREAM, IPPROTO_TCP); } /** |