xprtrdma: Support IPv6 in xprt_rdma_set_port

Clean up a harmless oversight. xprtrdma's ->set_port method has
never properly supported IPv6.

This issue has never been a problem because NFS/RDMA mounts have
always required "port=20049", thus so far, rpcbind is not invoked
for these mounts.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Chuck Lever 2017-12-14 20:57:06 -05:00 committed by Anna Schumaker
parent dd229cee4e
commit 20035edf3c
1 changed files with 24 additions and 4 deletions

View File

@ -474,14 +474,34 @@ xprt_rdma_close(struct rpc_xprt *xprt)
rpcrdma_ep_disconnect(ep, ia); rpcrdma_ep_disconnect(ep, ia);
} }
/**
* xprt_rdma_set_port - update server port with rpcbind result
* @xprt: controlling RPC transport
* @port: new port value
*
* Transport connect status is unchanged.
*/
static void static void
xprt_rdma_set_port(struct rpc_xprt *xprt, u16 port) xprt_rdma_set_port(struct rpc_xprt *xprt, u16 port)
{ {
struct sockaddr_in *sap; struct sockaddr *sap = (struct sockaddr *)&xprt->addr;
char buf[8];
sap = (struct sockaddr_in *)&xprt->addr; dprintk("RPC: %s: setting port for xprt %p (%s:%s) to %u\n",
sap->sin_port = htons(port); __func__, xprt,
dprintk("RPC: %s: %u\n", __func__, port); xprt->address_strings[RPC_DISPLAY_ADDR],
xprt->address_strings[RPC_DISPLAY_PORT],
port);
rpc_set_port(sap, port);
kfree(xprt->address_strings[RPC_DISPLAY_PORT]);
snprintf(buf, sizeof(buf), "%u", port);
xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL);
kfree(xprt->address_strings[RPC_DISPLAY_HEX_PORT]);
snprintf(buf, sizeof(buf), "%4hx", port);
xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL);
} }
/** /**