aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2010-10-04 08:54:55 -0400
committerJ. Bruce Fields <bfields@redhat.com>2010-10-19 10:48:15 -0400
commit22d44a7d8a03456aa6d0a047c051aa28728e6ecd (patch)
tree63ab8ec64240e7273a7628c64e9f4b728a5b5d6b /net/sunrpc/xprtsock.c
parent22f793268de3b4dff8abfcd873ba7afc1f34224f (diff)
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/xprtsock.c')
-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 b73a605c0847..96128d0fd8d2 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1655,6 +1655,30 @@ out:
1655 return ERR_PTR(err); 1655 return ERR_PTR(err);
1656} 1656}
1657 1657
1658static struct socket *xs_create_sock6(struct rpc_xprt *xprt,
1659 struct sock_xprt *transport, int type, int protocol)
1660{
1661 struct socket *sock;
1662 int err;
1663
1664 err = __sock_create(xprt->xprt_net, PF_INET6, type, protocol, &sock, 1);
1665 if (err < 0) {
1666 dprintk("RPC: can't create %d transport socket (%d).\n",
1667 protocol, -err);
1668 goto out;
1669 }
1670 xs_reclassify_socket6(sock);
1671
1672 if (xs_bind6(transport, sock)) {
1673 sock_release(sock);
1674 goto out;
1675 }
1676
1677 return sock;
1678out:
1679 return ERR_PTR(err);
1680}
1681
1658static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) 1682static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
1659{ 1683{
1660 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); 1684 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)
1745static struct socket *xs_create_udp_sock6(struct rpc_xprt *xprt, 1769static struct socket *xs_create_udp_sock6(struct rpc_xprt *xprt,
1746 struct sock_xprt *transport) 1770 struct sock_xprt *transport)
1747{ 1771{
1748 struct socket *sock; 1772 return xs_create_sock6(xprt, transport, SOCK_DGRAM, IPPROTO_UDP);
1749 int err;
1750
1751 err = __sock_create(xprt->xprt_net, PF_INET6, SOCK_DGRAM, IPPROTO_UDP, &sock, 1);
1752 if (err < 0) {
1753 dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
1754 goto out;
1755 }
1756 xs_reclassify_socket6(sock);
1757
1758 if (xs_bind6(transport, sock) < 0) {
1759 sock_release(sock);
1760 goto out;
1761 }
1762
1763 return sock;
1764out:
1765 return ERR_PTR(err);
1766} 1773}
1767 1774
1768static void xs_udp_connect_worker6(struct work_struct *work) 1775static void xs_udp_connect_worker6(struct work_struct *work)
@@ -1970,25 +1977,7 @@ static void xs_tcp_connect_worker4(struct work_struct *work)
1970static struct socket *xs_create_tcp_sock6(struct rpc_xprt *xprt, 1977static struct socket *xs_create_tcp_sock6(struct rpc_xprt *xprt,
1971 struct sock_xprt *transport) 1978 struct sock_xprt *transport)
1972{ 1979{
1973 struct socket *sock; 1980 return xs_create_sock6(xprt, transport, SOCK_STREAM, IPPROTO_TCP);
1974 int err;
1975
1976 /* start from scratch */
1977 err = __sock_create(xprt->xprt_net, PF_INET6, SOCK_STREAM, IPPROTO_TCP, &sock, 1);
1978 if (err < 0) {
1979 dprintk("RPC: can't create TCP transport socket (%d).\n",
1980 -err);
1981 goto out_err;
1982 }
1983 xs_reclassify_socket6(sock);
1984
1985 if (xs_bind6(transport, sock) < 0) {
1986 sock_release(sock);
1987 goto out_err;
1988 }
1989 return sock;
1990out_err:
1991 return ERR_PTR(-EIO);
1992} 1981}
1993 1982
1994/** 1983/**