aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 441bd53f5eca..123ac1e5ba15 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1016,7 +1016,7 @@ static void xs_udp_connect_worker(void *args)
1016 struct socket *sock = xprt->sock; 1016 struct socket *sock = xprt->sock;
1017 int err, status = -EIO; 1017 int err, status = -EIO;
1018 1018
1019 if (xprt->shutdown || xprt->addr.sin_port == 0) 1019 if (xprt->shutdown || !xprt_bound(xprt))
1020 goto out; 1020 goto out;
1021 1021
1022 dprintk("RPC: xs_udp_connect_worker for xprt %p\n", xprt); 1022 dprintk("RPC: xs_udp_connect_worker for xprt %p\n", xprt);
@@ -1099,7 +1099,7 @@ static void xs_tcp_connect_worker(void *args)
1099 struct socket *sock = xprt->sock; 1099 struct socket *sock = xprt->sock;
1100 int err, status = -EIO; 1100 int err, status = -EIO;
1101 1101
1102 if (xprt->shutdown || xprt->addr.sin_port == 0) 1102 if (xprt->shutdown || !xprt_bound(xprt))
1103 goto out; 1103 goto out;
1104 1104
1105 dprintk("RPC: xs_tcp_connect_worker for xprt %p\n", xprt); 1105 dprintk("RPC: xs_tcp_connect_worker for xprt %p\n", xprt);
@@ -1307,8 +1307,11 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1307 if (xprt->slot == NULL) 1307 if (xprt->slot == NULL)
1308 return -ENOMEM; 1308 return -ENOMEM;
1309 1309
1310 xprt->prot = IPPROTO_UDP; 1310 if (ntohs(xprt->addr.sin_port) != 0)
1311 xprt_set_bound(xprt);
1311 xprt->port = xs_get_random_port(); 1312 xprt->port = xs_get_random_port();
1313
1314 xprt->prot = IPPROTO_UDP;
1312 xprt->tsh_size = 0; 1315 xprt->tsh_size = 0;
1313 xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0; 1316 xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0;
1314 /* XXX: header size can vary due to auth type, IPv6, etc. */ 1317 /* XXX: header size can vary due to auth type, IPv6, etc. */
@@ -1348,8 +1351,11 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1348 if (xprt->slot == NULL) 1351 if (xprt->slot == NULL)
1349 return -ENOMEM; 1352 return -ENOMEM;
1350 1353
1351 xprt->prot = IPPROTO_TCP; 1354 if (ntohs(xprt->addr.sin_port) != 0)
1355 xprt_set_bound(xprt);
1352 xprt->port = xs_get_random_port(); 1356 xprt->port = xs_get_random_port();
1357
1358 xprt->prot = IPPROTO_TCP;
1353 xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); 1359 xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32);
1354 xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0; 1360 xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0;
1355 xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; 1361 xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;