aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-08-18 19:34:00 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-09-29 18:13:37 -0400
commit14aeb2118d6e9fd9ee988324c740a00c80979093 (patch)
treeca98af50a2e90fb782605ab6235c3a4b30c5b1a4
parentb6632339e3afbcbb438a3c8935190ea22464fc99 (diff)
SUNRPC: Simplify rpcb_register() API
Bruce suggested there's no need to expose the difference between an error sending the PMAP_SET request and an error reply from the portmapper to rpcb_register's callers. The user space equivalent of rpcb_register() is pmap_set(3), which returns a bool_t : either the PMAP set worked, or it didn't. Simple. So let's remove the "*okay" argument from rpcb_register() and rpcb_v4_register(), and simply return an error if any part of the call didn't work. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r--include/linux/sunrpc/clnt.h4
-rw-r--r--net/sunrpc/rpcb_clnt.c65
-rw-r--r--net/sunrpc/svc.c8
3 files changed, 32 insertions, 45 deletions
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index e5bfe01ee305..8ac8e75243a7 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -124,10 +124,10 @@ struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
124void rpc_shutdown_client(struct rpc_clnt *); 124void rpc_shutdown_client(struct rpc_clnt *);
125void rpc_release_client(struct rpc_clnt *); 125void rpc_release_client(struct rpc_clnt *);
126 126
127int rpcb_register(u32, u32, int, unsigned short, int *); 127int rpcb_register(u32, u32, int, unsigned short);
128int rpcb_v4_register(const u32 program, const u32 version, 128int rpcb_v4_register(const u32 program, const u32 version,
129 const struct sockaddr *address, 129 const struct sockaddr *address,
130 const char *netid, int *result); 130 const char *netid);
131int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int); 131int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int);
132void rpcb_getport_async(struct rpc_task *); 132void rpcb_getport_async(struct rpc_task *);
133 133
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
178static int rpcb_register_call(struct sockaddr *addr, size_t addrlen, 178static 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 */
239int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) 240int 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 */
374int rpcb_v4_register(const u32 program, const u32 version, 369int 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,
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 9ba17044109d..9805143d0660 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -730,7 +730,7 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)
730 struct svc_program *progp; 730 struct svc_program *progp;
731 unsigned long flags; 731 unsigned long flags;
732 unsigned int i; 732 unsigned int i;
733 int error = 0, dummy; 733 int error = 0;
734 734
735 if (!port) 735 if (!port)
736 clear_thread_flag(TIF_SIGPENDING); 736 clear_thread_flag(TIF_SIGPENDING);
@@ -751,13 +751,9 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)
751 if (progp->pg_vers[i]->vs_hidden) 751 if (progp->pg_vers[i]->vs_hidden)
752 continue; 752 continue;
753 753
754 error = rpcb_register(progp->pg_prog, i, proto, port, &dummy); 754 error = rpcb_register(progp->pg_prog, i, proto, port);
755 if (error < 0) 755 if (error < 0)
756 break; 756 break;
757 if (port && !dummy) {
758 error = -EACCES;
759 break;
760 }
761 } 757 }
762 } 758 }
763 759