SUNRPC: Introduce support for setting the port number in IPv6 addresses
authorChuck Lever <chuck.lever@oracle.com>
Mon, 6 Aug 2007 15:57:23 +0000 (11:57 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 9 Oct 2007 21:16:05 +0000 (17:16 -0400)
We could clone xs_set_port, but this is easier overall.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: Aurelien Charbon <aurelien.charbon@ext.bull.net>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/xprtsock.c

index 23e5865d984cccc03a97cf18c5cf5b09c7908cf7..a2dddec5325e6ec84a4e130a270c21a34863d90c 100644 (file)
@@ -1211,11 +1211,20 @@ static unsigned short xs_get_random_port(void)
  */
 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);
 
-       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)