diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2007-12-10 14:56:31 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-01-30 02:05:50 -0500 |
commit | 9f6ad26d2abfd9a2ec4a34b934ca75c4239ab8cf (patch) | |
tree | 9b02d2180d4ff4bfce6db27f856aa119bbc1ac18 /net/sunrpc | |
parent | 510deb0d7035d4fd465627deb3a119ca854f9e00 (diff) |
SUNRPC: Fix socket address handling in rpcb_clnt
Make sure rpcb_clnt passes the correct address length to rpc_create().
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/rpcb_clnt.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index f876e37d1972..c1310f796224 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -148,12 +148,13 @@ static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status) | |||
148 | } | 148 | } |
149 | 149 | ||
150 | static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | 150 | static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, |
151 | int proto, int version, int privileged) | 151 | size_t salen, int proto, int version, |
152 | int privileged) | ||
152 | { | 153 | { |
153 | struct rpc_create_args args = { | 154 | struct rpc_create_args args = { |
154 | .protocol = proto, | 155 | .protocol = proto, |
155 | .address = srvaddr, | 156 | .address = srvaddr, |
156 | .addrsize = sizeof(struct sockaddr_in), | 157 | .addrsize = salen, |
157 | .servername = hostname, | 158 | .servername = hostname, |
158 | .program = &rpcb_program, | 159 | .program = &rpcb_program, |
159 | .version = version, | 160 | .version = version, |
@@ -216,7 +217,7 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) | |||
216 | prog, vers, prot, port); | 217 | prog, vers, prot, port); |
217 | 218 | ||
218 | rpcb_clnt = rpcb_create("localhost", (struct sockaddr *) &sin, | 219 | rpcb_clnt = rpcb_create("localhost", (struct sockaddr *) &sin, |
219 | XPRT_TRANSPORT_UDP, 2, 1); | 220 | sizeof(sin), XPRT_TRANSPORT_UDP, 2, 1); |
220 | if (IS_ERR(rpcb_clnt)) | 221 | if (IS_ERR(rpcb_clnt)) |
221 | return PTR_ERR(rpcb_clnt); | 222 | return PTR_ERR(rpcb_clnt); |
222 | 223 | ||
@@ -265,7 +266,8 @@ int rpcb_getport_sync(struct sockaddr_in *sin, __u32 prog, | |||
265 | __FUNCTION__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot); | 266 | __FUNCTION__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot); |
266 | 267 | ||
267 | sprintf(hostname, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr)); | 268 | sprintf(hostname, NIPQUAD_FMT, NIPQUAD(sin->sin_addr.s_addr)); |
268 | rpcb_clnt = rpcb_create(hostname, (struct sockaddr *)sin, prot, 2, 0); | 269 | rpcb_clnt = rpcb_create(hostname, (struct sockaddr *)sin, |
270 | sizeof(sin), prot, 2, 0); | ||
269 | if (IS_ERR(rpcb_clnt)) | 271 | if (IS_ERR(rpcb_clnt)) |
270 | return PTR_ERR(rpcb_clnt); | 272 | return PTR_ERR(rpcb_clnt); |
271 | 273 | ||
@@ -314,7 +316,9 @@ void rpcb_getport_async(struct rpc_task *task) | |||
314 | struct rpc_clnt *rpcb_clnt; | 316 | struct rpc_clnt *rpcb_clnt; |
315 | static struct rpcbind_args *map; | 317 | static struct rpcbind_args *map; |
316 | struct rpc_task *child; | 318 | struct rpc_task *child; |
317 | struct sockaddr addr; | 319 | struct sockaddr_storage addr; |
320 | struct sockaddr *sap = (struct sockaddr *)&addr; | ||
321 | size_t salen; | ||
318 | int status; | 322 | int status; |
319 | struct rpcb_info *info; | 323 | struct rpcb_info *info; |
320 | 324 | ||
@@ -344,10 +348,10 @@ void rpcb_getport_async(struct rpc_task *task) | |||
344 | goto bailout_nofree; | 348 | goto bailout_nofree; |
345 | } | 349 | } |
346 | 350 | ||
347 | rpc_peeraddr(clnt, (void *)&addr, sizeof(addr)); | 351 | salen = rpc_peeraddr(clnt, sap, sizeof(addr)); |
348 | 352 | ||
349 | /* Don't ever use rpcbind v2 for AF_INET6 requests */ | 353 | /* Don't ever use rpcbind v2 for AF_INET6 requests */ |
350 | switch (addr.sa_family) { | 354 | switch (sap->sa_family) { |
351 | case AF_INET: | 355 | case AF_INET: |
352 | info = rpcb_next_version; | 356 | info = rpcb_next_version; |
353 | break; | 357 | break; |
@@ -372,7 +376,7 @@ void rpcb_getport_async(struct rpc_task *task) | |||
372 | dprintk("RPC: %5u %s: trying rpcbind version %u\n", | 376 | dprintk("RPC: %5u %s: trying rpcbind version %u\n", |
373 | task->tk_pid, __FUNCTION__, bind_version); | 377 | task->tk_pid, __FUNCTION__, bind_version); |
374 | 378 | ||
375 | rpcb_clnt = rpcb_create(clnt->cl_server, &addr, xprt->prot, | 379 | rpcb_clnt = rpcb_create(clnt->cl_server, sap, salen, xprt->prot, |
376 | bind_version, 0); | 380 | bind_version, 0); |
377 | if (IS_ERR(rpcb_clnt)) { | 381 | if (IS_ERR(rpcb_clnt)) { |
378 | status = PTR_ERR(rpcb_clnt); | 382 | status = PTR_ERR(rpcb_clnt); |