diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2006-08-22 20:06:19 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-09-22 23:24:48 -0400 |
commit | c4efcb1d3e0bc76aeb9ca6301d19a5079893c6c9 (patch) | |
tree | 23f113b897f1ab2e00e4fcf774d93711d7f703b8 /net/sunrpc | |
parent | e7f7865743fff3d3938ec7540e5a784d662426da (diff) |
SUNRPC: Use "sockaddr_storage" for storing RPC client's remote peer address
IPv6 addresses are big (128 bytes). Now that no RPC client consumers treat
the addr field in rpc_xprt structs as an opaque, and access it only via the
API calls, we can safely widen the field in the rpc_xprt struct to
accomodate larger addresses.
Test plan:
Compile kernel with CONFIG_NFS enabled.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/clnt.c | 2 | ||||
-rw-r--r-- | net/sunrpc/xprt.c | 3 | ||||
-rw-r--r-- | net/sunrpc/xprtsock.c | 15 |
3 files changed, 13 insertions, 7 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index e5b19e348d88..ff1e90fd81ab 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -550,7 +550,7 @@ size_t rpc_peeraddr(struct rpc_clnt *clnt, struct sockaddr *buf, size_t bufsize) | |||
550 | if (bytes > bufsize) | 550 | if (bytes > bufsize) |
551 | bytes = bufsize; | 551 | bytes = bufsize; |
552 | memcpy(buf, &clnt->cl_xprt->addr, bytes); | 552 | memcpy(buf, &clnt->cl_xprt->addr, bytes); |
553 | return sizeof(xprt->addr); | 553 | return xprt->addrlen; |
554 | } | 554 | } |
555 | EXPORT_SYMBOL(rpc_peeraddr); | 555 | EXPORT_SYMBOL(rpc_peeraddr); |
556 | 556 | ||
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index b45abd0743cb..4987517cc74b 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -896,7 +896,8 @@ static struct rpc_xprt *xprt_setup(int proto, struct sockaddr_in *ap, struct rpc | |||
896 | if ((xprt = kzalloc(sizeof(struct rpc_xprt), GFP_KERNEL)) == NULL) | 896 | if ((xprt = kzalloc(sizeof(struct rpc_xprt), GFP_KERNEL)) == NULL) |
897 | return ERR_PTR(-ENOMEM); | 897 | return ERR_PTR(-ENOMEM); |
898 | 898 | ||
899 | xprt->addr = *ap; | 899 | memcpy(&xprt->addr, ap, sizeof(*ap)); |
900 | xprt->addrlen = sizeof(*ap); | ||
900 | 901 | ||
901 | switch (proto) { | 902 | switch (proto) { |
902 | case IPPROTO_UDP: | 903 | case IPPROTO_UDP: |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index cb8e6c34e12f..17179aa4c207 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -341,7 +341,7 @@ static int xs_udp_send_request(struct rpc_task *task) | |||
341 | 341 | ||
342 | req->rq_xtime = jiffies; | 342 | req->rq_xtime = jiffies; |
343 | status = xs_sendpages(xprt->sock, (struct sockaddr *) &xprt->addr, | 343 | status = xs_sendpages(xprt->sock, (struct sockaddr *) &xprt->addr, |
344 | sizeof(xprt->addr), xdr, req->rq_bytes_sent); | 344 | xprt->addrlen, xdr, req->rq_bytes_sent); |
345 | 345 | ||
346 | dprintk("RPC: xs_udp_send_request(%u) = %d\n", | 346 | dprintk("RPC: xs_udp_send_request(%u) = %d\n", |
347 | xdr->len - req->rq_bytes_sent, status); | 347 | xdr->len - req->rq_bytes_sent, status); |
@@ -1027,8 +1027,11 @@ static char *xs_print_peer_address(struct rpc_xprt *xprt, enum rpc_display_forma | |||
1027 | */ | 1027 | */ |
1028 | static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) | 1028 | static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) |
1029 | { | 1029 | { |
1030 | struct sockaddr_in *sap = (struct sockaddr_in *) &xprt->addr; | ||
1031 | |||
1030 | dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); | 1032 | dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); |
1031 | xprt->addr.sin_port = htons(port); | 1033 | |
1034 | sap->sin_port = htons(port); | ||
1032 | } | 1035 | } |
1033 | 1036 | ||
1034 | static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock) | 1037 | static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock) |
@@ -1209,7 +1212,7 @@ static void xs_tcp_connect_worker(void *args) | |||
1209 | xprt->stat.connect_count++; | 1212 | xprt->stat.connect_count++; |
1210 | xprt->stat.connect_start = jiffies; | 1213 | xprt->stat.connect_start = jiffies; |
1211 | status = sock->ops->connect(sock, (struct sockaddr *) &xprt->addr, | 1214 | status = sock->ops->connect(sock, (struct sockaddr *) &xprt->addr, |
1212 | sizeof(xprt->addr), O_NONBLOCK); | 1215 | xprt->addrlen, O_NONBLOCK); |
1213 | dprintk("RPC: %p connect status %d connected %d sock state %d\n", | 1216 | dprintk("RPC: %p connect status %d connected %d sock state %d\n", |
1214 | xprt, -status, xprt_connected(xprt), sock->sk->sk_state); | 1217 | xprt, -status, xprt_connected(xprt), sock->sk->sk_state); |
1215 | if (status < 0) { | 1218 | if (status < 0) { |
@@ -1359,6 +1362,7 @@ static struct rpc_xprt_ops xs_tcp_ops = { | |||
1359 | int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to) | 1362 | int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to) |
1360 | { | 1363 | { |
1361 | size_t slot_table_size; | 1364 | size_t slot_table_size; |
1365 | struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr; | ||
1362 | 1366 | ||
1363 | xprt->max_reqs = xprt_udp_slot_table_entries; | 1367 | xprt->max_reqs = xprt_udp_slot_table_entries; |
1364 | slot_table_size = xprt->max_reqs * sizeof(xprt->slot[0]); | 1368 | slot_table_size = xprt->max_reqs * sizeof(xprt->slot[0]); |
@@ -1366,7 +1370,7 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to) | |||
1366 | if (xprt->slot == NULL) | 1370 | if (xprt->slot == NULL) |
1367 | return -ENOMEM; | 1371 | return -ENOMEM; |
1368 | 1372 | ||
1369 | if (ntohs(xprt->addr.sin_port) != 0) | 1373 | if (ntohs(addr->sin_port != 0)) |
1370 | xprt_set_bound(xprt); | 1374 | xprt_set_bound(xprt); |
1371 | xprt->port = xs_get_random_port(); | 1375 | xprt->port = xs_get_random_port(); |
1372 | 1376 | ||
@@ -1405,6 +1409,7 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to) | |||
1405 | int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to) | 1409 | int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to) |
1406 | { | 1410 | { |
1407 | size_t slot_table_size; | 1411 | size_t slot_table_size; |
1412 | struct sockaddr_in *addr = (struct sockaddr_in *) &xprt->addr; | ||
1408 | 1413 | ||
1409 | xprt->max_reqs = xprt_tcp_slot_table_entries; | 1414 | xprt->max_reqs = xprt_tcp_slot_table_entries; |
1410 | slot_table_size = xprt->max_reqs * sizeof(xprt->slot[0]); | 1415 | slot_table_size = xprt->max_reqs * sizeof(xprt->slot[0]); |
@@ -1412,7 +1417,7 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to) | |||
1412 | if (xprt->slot == NULL) | 1417 | if (xprt->slot == NULL) |
1413 | return -ENOMEM; | 1418 | return -ENOMEM; |
1414 | 1419 | ||
1415 | if (ntohs(xprt->addr.sin_port) != 0) | 1420 | if (ntohs(addr->sin_port) != 0) |
1416 | xprt_set_bound(xprt); | 1421 | xprt_set_bound(xprt); |
1417 | xprt->port = xs_get_random_port(); | 1422 | xprt->port = xs_get_random_port(); |
1418 | 1423 | ||