aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/xprtsock.c49
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
1595static 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
1595static inline void xs_reclassify_socket4(struct socket *sock) 1603static inline void xs_reclassify_socket4(struct socket *sock)
1596{ 1604{
@@ -1599,22 +1607,26 @@ static inline void xs_reclassify_socket4(struct socket *sock)
1599static inline void xs_reclassify_socket6(struct socket *sock) 1607static inline void xs_reclassify_socket6(struct socket *sock)
1600{ 1608{
1601} 1609}
1610
1611static inline void xs_reclassify_socket(int family, struct socket *sock)
1612{
1613}
1602#endif 1614#endif
1603 1615
1604static struct socket *xs_create_sock4(struct rpc_xprt *xprt, 1616static 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
1629static struct socket *xs_create_sock6(struct rpc_xprt *xprt, 1641static 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; 1647static struct socket *xs_create_sock6(struct rpc_xprt *xprt,
1650out: 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
1654static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) 1653static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)