Commit 20612005 authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

SUNRPC: Introduce support for setting the port number in IPv6 addresses

We could clone xs_set_port, but this is easier overall.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Cc: Aurelien Charbon <aurelien.charbon@ext.bull.net>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent d5b64430
...@@ -1211,11 +1211,20 @@ static unsigned short xs_get_random_port(void) ...@@ -1211,11 +1211,20 @@ static unsigned short xs_get_random_port(void)
*/ */
static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) static void xs_set_port(struct rpc_xprt *xprt, unsigned short port)
{ {
struct sockaddr_in *sap = (struct sockaddr_in *) &xprt->addr; struct sockaddr *addr = (struct sockaddr *) &xprt->addr;
dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); dprintk("RPC: setting port for xprt %p to %u\n", xprt, port);
sap->sin_port = htons(port); switch (addr->sa_family) {
case AF_INET:
((struct sockaddr_in *)addr)->sin_port = htons(port);
break;
case AF_INET6:
((struct sockaddr_in6 *)addr)->sin6_port = htons(port);
break;
default:
BUG();
}
} }
static int xs_bind(struct sock_xprt *transport, struct socket *sock) static int xs_bind(struct sock_xprt *transport, struct socket *sock)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment