diff options
Diffstat (limited to 'net/sunrpc/rpcb_clnt.c')
-rw-r--r-- | net/sunrpc/rpcb_clnt.c | 65 |
1 files changed, 28 insertions, 37 deletions
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index 24db2b4d12d3..cc7250d4659b 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -176,13 +176,12 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | |||
176 | } | 176 | } |
177 | 177 | ||
178 | static int rpcb_register_call(struct sockaddr *addr, size_t addrlen, | 178 | static int rpcb_register_call(struct sockaddr *addr, size_t addrlen, |
179 | u32 version, struct rpc_message *msg, | 179 | u32 version, struct rpc_message *msg) |
180 | int *result) | ||
181 | { | 180 | { |
182 | struct rpc_clnt *rpcb_clnt; | 181 | struct rpc_clnt *rpcb_clnt; |
183 | int error = 0; | 182 | int result, error = 0; |
184 | 183 | ||
185 | *result = 0; | 184 | msg->rpc_resp = &result; |
186 | 185 | ||
187 | rpcb_clnt = rpcb_create_local(addr, addrlen, version); | 186 | rpcb_clnt = rpcb_create_local(addr, addrlen, version); |
188 | if (!IS_ERR(rpcb_clnt)) { | 187 | if (!IS_ERR(rpcb_clnt)) { |
@@ -191,12 +190,19 @@ static int rpcb_register_call(struct sockaddr *addr, size_t addrlen, | |||
191 | } else | 190 | } else |
192 | error = PTR_ERR(rpcb_clnt); | 191 | error = PTR_ERR(rpcb_clnt); |
193 | 192 | ||
194 | if (error < 0) | 193 | if (error < 0) { |
195 | printk(KERN_WARNING "RPC: failed to contact local rpcbind " | 194 | printk(KERN_WARNING "RPC: failed to contact local rpcbind " |
196 | "server (errno %d).\n", -error); | 195 | "server (errno %d).\n", -error); |
197 | dprintk("RPC: registration status %d/%d\n", error, *result); | 196 | return error; |
197 | } | ||
198 | |||
199 | if (!result) { | ||
200 | dprintk("RPC: registration failed\n"); | ||
201 | return -EACCES; | ||
202 | } | ||
198 | 203 | ||
199 | return error; | 204 | dprintk("RPC: registration succeeded\n"); |
205 | return 0; | ||
200 | } | 206 | } |
201 | 207 | ||
202 | /** | 208 | /** |
@@ -205,7 +211,11 @@ static int rpcb_register_call(struct sockaddr *addr, size_t addrlen, | |||
205 | * @vers: RPC version number to bind | 211 | * @vers: RPC version number to bind |
206 | * @prot: transport protocol to register | 212 | * @prot: transport protocol to register |
207 | * @port: port value to register | 213 | * @port: port value to register |
208 | * @okay: OUT: result code | 214 | * |
215 | * Returns zero if the registration request was dispatched successfully | ||
216 | * and the rpcbind daemon returned success. Otherwise, returns an errno | ||
217 | * value that reflects the nature of the error (request could not be | ||
218 | * dispatched, timed out, or rpcbind returned an error). | ||
209 | * | 219 | * |
210 | * RPC services invoke this function to advertise their contact | 220 | * RPC services invoke this function to advertise their contact |
211 | * information via the system's rpcbind daemon. RPC services | 221 | * information via the system's rpcbind daemon. RPC services |
@@ -217,15 +227,6 @@ static int rpcb_register_call(struct sockaddr *addr, size_t addrlen, | |||
217 | * all registered transports for [program, version] from the local | 227 | * all registered transports for [program, version] from the local |
218 | * rpcbind database. | 228 | * rpcbind database. |
219 | * | 229 | * |
220 | * Returns zero if the registration request was dispatched | ||
221 | * successfully and a reply was received. The rpcbind daemon's | ||
222 | * boolean result code is stored in *okay. | ||
223 | * | ||
224 | * Returns an errno value and sets *result to zero if there was | ||
225 | * some problem that prevented the rpcbind request from being | ||
226 | * dispatched, or if the rpcbind daemon did not respond within | ||
227 | * the timeout. | ||
228 | * | ||
229 | * This function uses rpcbind protocol version 2 to contact the | 230 | * This function uses rpcbind protocol version 2 to contact the |
230 | * local rpcbind daemon. | 231 | * local rpcbind daemon. |
231 | * | 232 | * |
@@ -236,7 +237,7 @@ static int rpcb_register_call(struct sockaddr *addr, size_t addrlen, | |||
236 | * IN6ADDR_ANY (ie available for all AF_INET and AF_INET6 | 237 | * IN6ADDR_ANY (ie available for all AF_INET and AF_INET6 |
237 | * addresses). | 238 | * addresses). |
238 | */ | 239 | */ |
239 | int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) | 240 | int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port) |
240 | { | 241 | { |
241 | struct rpcbind_args map = { | 242 | struct rpcbind_args map = { |
242 | .r_prog = prog, | 243 | .r_prog = prog, |
@@ -246,7 +247,6 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) | |||
246 | }; | 247 | }; |
247 | struct rpc_message msg = { | 248 | struct rpc_message msg = { |
248 | .rpc_argp = &map, | 249 | .rpc_argp = &map, |
249 | .rpc_resp = okay, | ||
250 | }; | 250 | }; |
251 | 251 | ||
252 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " | 252 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " |
@@ -259,7 +259,7 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) | |||
259 | 259 | ||
260 | return rpcb_register_call((struct sockaddr *)&rpcb_inaddr_loopback, | 260 | return rpcb_register_call((struct sockaddr *)&rpcb_inaddr_loopback, |
261 | sizeof(rpcb_inaddr_loopback), | 261 | sizeof(rpcb_inaddr_loopback), |
262 | RPCBVERS_2, &msg, okay); | 262 | RPCBVERS_2, &msg); |
263 | } | 263 | } |
264 | 264 | ||
265 | /* | 265 | /* |
@@ -290,7 +290,7 @@ static int rpcb_register_netid4(struct sockaddr_in *address_to_register, | |||
290 | 290 | ||
291 | return rpcb_register_call((struct sockaddr *)&rpcb_inaddr_loopback, | 291 | return rpcb_register_call((struct sockaddr *)&rpcb_inaddr_loopback, |
292 | sizeof(rpcb_inaddr_loopback), | 292 | sizeof(rpcb_inaddr_loopback), |
293 | RPCBVERS_4, msg, msg->rpc_resp); | 293 | RPCBVERS_4, msg); |
294 | } | 294 | } |
295 | 295 | ||
296 | /* | 296 | /* |
@@ -321,7 +321,7 @@ static int rpcb_register_netid6(struct sockaddr_in6 *address_to_register, | |||
321 | 321 | ||
322 | return rpcb_register_call((struct sockaddr *)&rpcb_in6addr_loopback, | 322 | return rpcb_register_call((struct sockaddr *)&rpcb_in6addr_loopback, |
323 | sizeof(rpcb_in6addr_loopback), | 323 | sizeof(rpcb_in6addr_loopback), |
324 | RPCBVERS_4, msg, msg->rpc_resp); | 324 | RPCBVERS_4, msg); |
325 | } | 325 | } |
326 | 326 | ||
327 | /** | 327 | /** |
@@ -330,7 +330,11 @@ static int rpcb_register_netid6(struct sockaddr_in6 *address_to_register, | |||
330 | * @version: RPC version number of service to (un)register | 330 | * @version: RPC version number of service to (un)register |
331 | * @address: address family, IP address, and port to (un)register | 331 | * @address: address family, IP address, and port to (un)register |
332 | * @netid: netid of transport protocol to (un)register | 332 | * @netid: netid of transport protocol to (un)register |
333 | * @result: result code from rpcbind RPC call | 333 | * |
334 | * Returns zero if the registration request was dispatched successfully | ||
335 | * and the rpcbind daemon returned success. Otherwise, returns an errno | ||
336 | * value that reflects the nature of the error (request could not be | ||
337 | * dispatched, timed out, or rpcbind returned an error). | ||
334 | * | 338 | * |
335 | * RPC services invoke this function to advertise their contact | 339 | * RPC services invoke this function to advertise their contact |
336 | * information via the system's rpcbind daemon. RPC services | 340 | * information via the system's rpcbind daemon. RPC services |
@@ -342,15 +346,6 @@ static int rpcb_register_netid6(struct sockaddr_in6 *address_to_register, | |||
342 | * to zero. Callers pass a netid of "" to unregister all | 346 | * to zero. Callers pass a netid of "" to unregister all |
343 | * transport netids associated with [program, version, address]. | 347 | * transport netids associated with [program, version, address]. |
344 | * | 348 | * |
345 | * Returns zero if the registration request was dispatched | ||
346 | * successfully and a reply was received. The rpcbind daemon's | ||
347 | * result code is stored in *result. | ||
348 | * | ||
349 | * Returns an errno value and sets *result to zero if there was | ||
350 | * some problem that prevented the rpcbind request from being | ||
351 | * dispatched, or if the rpcbind daemon did not respond within | ||
352 | * the timeout. | ||
353 | * | ||
354 | * This function uses rpcbind protocol version 4 to contact the | 349 | * This function uses rpcbind protocol version 4 to contact the |
355 | * local rpcbind daemon. The local rpcbind daemon must support | 350 | * local rpcbind daemon. The local rpcbind daemon must support |
356 | * version 4 of the rpcbind protocol in order for these functions | 351 | * version 4 of the rpcbind protocol in order for these functions |
@@ -372,8 +367,7 @@ static int rpcb_register_netid6(struct sockaddr_in6 *address_to_register, | |||
372 | * advertises the service on all IPv4 and IPv6 addresses. | 367 | * advertises the service on all IPv4 and IPv6 addresses. |
373 | */ | 368 | */ |
374 | int rpcb_v4_register(const u32 program, const u32 version, | 369 | int rpcb_v4_register(const u32 program, const u32 version, |
375 | const struct sockaddr *address, const char *netid, | 370 | const struct sockaddr *address, const char *netid) |
376 | int *result) | ||
377 | { | 371 | { |
378 | struct rpcbind_args map = { | 372 | struct rpcbind_args map = { |
379 | .r_prog = program, | 373 | .r_prog = program, |
@@ -383,11 +377,8 @@ int rpcb_v4_register(const u32 program, const u32 version, | |||
383 | }; | 377 | }; |
384 | struct rpc_message msg = { | 378 | struct rpc_message msg = { |
385 | .rpc_argp = &map, | 379 | .rpc_argp = &map, |
386 | .rpc_resp = result, | ||
387 | }; | 380 | }; |
388 | 381 | ||
389 | *result = 0; | ||
390 | |||
391 | switch (address->sa_family) { | 382 | switch (address->sa_family) { |
392 | case AF_INET: | 383 | case AF_INET: |
393 | return rpcb_register_netid4((struct sockaddr_in *)address, | 384 | return rpcb_register_netid4((struct sockaddr_in *)address, |