diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2006-08-22 20:06:15 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-09-22 23:24:39 -0400 |
commit | ec739ef03dc926d05051c8c5838971445504470a (patch) | |
tree | 940d3dafd873c159c1279ade15ba11ede1d12983 /net/sunrpc/xprtsock.c | |
parent | 9c5bf38d85a31b946664bcc21078ef5bb10672f7 (diff) |
SUNRPC: Create a helper to tell whether a transport is bound
Hide the contents and format of xprt->addr by eliminating direct uses
of the xprt->addr.sin_port field. This change is required to support
alternate RPC host address formats (eg IPv6).
Test-plan:
Destructive testing (unplugging the network temporarily). Repeated runs of
Connectathon locking suite with UDP and TCP.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r-- | net/sunrpc/xprtsock.c | 14 |
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; |