diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2010-10-04 08:56:38 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2010-10-19 10:48:15 -0400 |
commit | 6bc9638ab495516f8a34d2ae48f2f43f145e186f (patch) | |
tree | 1a6b139e954b56e6fb24892a832b43c5eb6ad8ed /net | |
parent | beb59b68280d9779cc16591115547678d1c74a66 (diff) |
sunrpc: Merge xs_create_sock code
After xs_bind is merged it's easy to merge its callers.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
[bfields@redhat.com: fix address family initialization]
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/xprtsock.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index fc1e76788120..324d97ae71ab 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -1591,6 +1591,14 @@ static inline void xs_reclassify_socket6(struct socket *sock) | |||
1591 | sock_lock_init_class_and_name(sk, "slock-AF_INET6-RPC", | 1591 | sock_lock_init_class_and_name(sk, "slock-AF_INET6-RPC", |
1592 | &xs_slock_key[1], "sk_lock-AF_INET6-RPC", &xs_key[1]); | 1592 | &xs_slock_key[1], "sk_lock-AF_INET6-RPC", &xs_key[1]); |
1593 | } | 1593 | } |
1594 | |||
1595 | static inline void xs_reclassify_socket(int family, struct socket *sock) | ||
1596 | { | ||
1597 | if (family == PF_INET) | ||
1598 | xs_reclassify_socket4(sock); | ||
1599 | else | ||
1600 | xs_reclassify_socket6(sock); | ||
1601 | } | ||
1594 | #else | 1602 | #else |
1595 | static inline void xs_reclassify_socket4(struct socket *sock) | 1603 | static inline void xs_reclassify_socket4(struct socket *sock) |
1596 | { | 1604 | { |
@@ -1599,22 +1607,26 @@ static inline void xs_reclassify_socket4(struct socket *sock) | |||
1599 | static inline void xs_reclassify_socket6(struct socket *sock) | 1607 | static inline void xs_reclassify_socket6(struct socket *sock) |
1600 | { | 1608 | { |
1601 | } | 1609 | } |
1610 | |||
1611 | static inline void xs_reclassify_socket(int family, struct socket *sock) | ||
1612 | { | ||
1613 | } | ||
1602 | #endif | 1614 | #endif |
1603 | 1615 | ||
1604 | static struct socket *xs_create_sock4(struct rpc_xprt *xprt, | 1616 | static struct socket *xs_create_sock(struct rpc_xprt *xprt, |
1605 | struct sock_xprt *transport, int type, int protocol) | 1617 | struct sock_xprt *transport, int family, int type, int protocol) |
1606 | { | 1618 | { |
1607 | struct socket *sock; | 1619 | struct socket *sock; |
1608 | int err; | 1620 | int err; |
1609 | 1621 | ||
1610 | err = __sock_create(xprt->xprt_net, PF_INET, type, protocol, &sock, 1); | 1622 | err = __sock_create(xprt->xprt_net, family, type, protocol, &sock, 1); |
1611 | if (err < 0) { | 1623 | if (err < 0) { |
1612 | dprintk("RPC: can't create %d transport socket (%d).\n", | 1624 | dprintk("RPC: can't create %d transport socket (%d).\n", |
1613 | protocol, -err); | 1625 | protocol, -err); |
1614 | goto out; | 1626 | goto out; |
1615 | } | 1627 | } |
1616 | transport->srcaddr.ss_family = AF_INET; | 1628 | transport->srcaddr.ss_family = family; |
1617 | xs_reclassify_socket4(sock); | 1629 | xs_reclassify_socket(family, sock); |
1618 | 1630 | ||
1619 | if (xs_bind(transport, sock)) { | 1631 | if (xs_bind(transport, sock)) { |
1620 | sock_release(sock); | 1632 | sock_release(sock); |
@@ -1626,29 +1638,16 @@ out: | |||
1626 | return ERR_PTR(err); | 1638 | return ERR_PTR(err); |
1627 | } | 1639 | } |
1628 | 1640 | ||
1629 | static struct socket *xs_create_sock6(struct rpc_xprt *xprt, | 1641 | static struct socket *xs_create_sock4(struct rpc_xprt *xprt, |
1630 | struct sock_xprt *transport, int type, int protocol) | 1642 | struct sock_xprt *transport, int type, int protocol) |
1631 | { | 1643 | { |
1632 | struct socket *sock; | 1644 | return xs_create_sock(xprt, transport, PF_INET, type, protocol); |
1633 | int err; | 1645 | } |
1634 | |||
1635 | err = __sock_create(xprt->xprt_net, PF_INET6, type, protocol, &sock, 1); | ||
1636 | if (err < 0) { | ||
1637 | dprintk("RPC: can't create %d transport socket (%d).\n", | ||
1638 | protocol, -err); | ||
1639 | goto out; | ||
1640 | } | ||
1641 | transport->srcaddr.ss_family = AF_INET6; | ||
1642 | xs_reclassify_socket6(sock); | ||
1643 | |||
1644 | if (xs_bind(transport, sock)) { | ||
1645 | sock_release(sock); | ||
1646 | goto out; | ||
1647 | } | ||
1648 | 1646 | ||
1649 | return sock; | 1647 | static struct socket *xs_create_sock6(struct rpc_xprt *xprt, |
1650 | out: | 1648 | struct sock_xprt *transport, int type, int protocol) |
1651 | return ERR_PTR(err); | 1649 | { |
1650 | return xs_create_sock(xprt, transport, PF_INET6, type, protocol); | ||
1652 | } | 1651 | } |
1653 | 1652 | ||
1654 | static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) | 1653 | static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) |