diff options
-rw-r--r-- | net/sunrpc/xprtsock.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 23e5865d984c..a2dddec5325e 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -1211,11 +1211,20 @@ static unsigned short xs_get_random_port(void) | |||
1211 | */ | 1211 | */ |
1212 | static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) | 1212 | static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) |
1213 | { | 1213 | { |
1214 | struct sockaddr_in *sap = (struct sockaddr_in *) &xprt->addr; | 1214 | struct sockaddr *addr = (struct sockaddr *) &xprt->addr; |
1215 | 1215 | ||
1216 | dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); | 1216 | dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); |
1217 | 1217 | ||
1218 | sap->sin_port = htons(port); | 1218 | switch (addr->sa_family) { |
1219 | case AF_INET: | ||
1220 | ((struct sockaddr_in *)addr)->sin_port = htons(port); | ||
1221 | break; | ||
1222 | case AF_INET6: | ||
1223 | ((struct sockaddr_in6 *)addr)->sin6_port = htons(port); | ||
1224 | break; | ||
1225 | default: | ||
1226 | BUG(); | ||
1227 | } | ||
1219 | } | 1228 | } |
1220 | 1229 | ||
1221 | static int xs_bind(struct sock_xprt *transport, struct socket *sock) | 1230 | static int xs_bind(struct sock_xprt *transport, struct socket *sock) |