[RFC PATCH 3/5] SUNRPC: move helper xs_init_anyaddr to rpc_init_anyaddr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Kinglong Mee <kinglongmee@xxxxxxxxx>
---
 include/linux/sunrpc/addr.h | 26 ++++++++++++++++++++++++++
 net/sunrpc/xprtsock.c       | 29 +----------------------------
 2 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
index f662798c5d83..134450a9fd38 100644
--- a/include/linux/sunrpc/addr.h
+++ b/include/linux/sunrpc/addr.h
@@ -186,4 +186,30 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
 	return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
 }
 
+static inline int rpc_init_anyaddr(const int family, struct sockaddr *sap)
+{
+	static const struct sockaddr_in sin = {
+		.sin_family		= AF_INET,
+		.sin_addr.s_addr	= htonl(INADDR_ANY),
+	};
+	static const struct sockaddr_in6 sin6 = {
+		.sin6_family		= AF_INET6,
+		.sin6_addr		= IN6ADDR_ANY_INIT,
+	};
+
+	switch (family) {
+	case AF_LOCAL:
+		break;
+	case AF_INET:
+		memcpy(sap, &sin, sizeof(sin));
+		break;
+	case AF_INET6:
+		memcpy(sap, &sin6, sizeof(sin6));
+		break;
+	default:
+		return -EAFNOSUPPORT;
+	}
+	return 0;
+}
+
 #endif /* _LINUX_SUNRPC_ADDR_H */
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 0e1691316f42..c4c002fd7333 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -3125,33 +3125,6 @@ static const struct rpc_xprt_ops bc_tcp_ops = {
 	.inject_disconnect	= xs_inject_disconnect,
 };
 
-static int xs_init_anyaddr(const int family, struct sockaddr *sap)
-{
-	static const struct sockaddr_in sin = {
-		.sin_family		= AF_INET,
-		.sin_addr.s_addr	= htonl(INADDR_ANY),
-	};
-	static const struct sockaddr_in6 sin6 = {
-		.sin6_family		= AF_INET6,
-		.sin6_addr		= IN6ADDR_ANY_INIT,
-	};
-
-	switch (family) {
-	case AF_LOCAL:
-		break;
-	case AF_INET:
-		memcpy(sap, &sin, sizeof(sin));
-		break;
-	case AF_INET6:
-		memcpy(sap, &sin6, sizeof(sin6));
-		break;
-	default:
-		dprintk("RPC:       %s: Bad address family\n", __func__);
-		return -EAFNOSUPPORT;
-	}
-	return 0;
-}
-
 static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args,
 				      unsigned int slot_table_size,
 				      unsigned int max_slot_table_size)
@@ -3180,7 +3153,7 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args,
 		memcpy(&new->srcaddr, args->srcaddr, args->addrlen);
 	else {
 		int err;
-		err = xs_init_anyaddr(args->dstaddr->sa_family,
+		err = rpc_init_anyaddr(args->dstaddr->sa_family,
 					(struct sockaddr *)&new->srcaddr);
 		if (err != 0) {
 			xprt_free(xprt);
-- 
2.47.0





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux