aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/svc.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2006-09-27 01:28:46 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-28 21:01:20 -0400
commit7699431301b189fca7ccbb64fe54e5a5170f8497 (patch)
tree4c20c5121776984cb054de3e0759cbeae860de3a /net/sunrpc/svc.c
parent13d8eaa06abfeb708b60fa64203a20db033088b3 (diff)
[SUNRPC]: svc_{get,put}nl()
* add svc_getnl(): Take network-endian value from buffer, convert to host-endian and return it. * add svc_putnl(): Take host-endian value, convert to network-endian and put it into a buffer. * annotate svc_getu32()/svc_putu32() as dealing with network-endian. * convert to svc_getnl(), svc_putnl(). [AV: in large part it's a carved-up Alexey's patch] Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sunrpc/svc.c')
-rw-r--r--net/sunrpc/svc.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index b76a227dd3ad..6589e1ad47fa 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -284,16 +284,16 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
284 rqstp->rq_sendfile_ok = 1; 284 rqstp->rq_sendfile_ok = 1;
285 /* tcp needs a space for the record length... */ 285 /* tcp needs a space for the record length... */
286 if (rqstp->rq_prot == IPPROTO_TCP) 286 if (rqstp->rq_prot == IPPROTO_TCP)
287 svc_putu32(resv, 0); 287 svc_putnl(resv, 0);
288 288
289 rqstp->rq_xid = svc_getu32(argv); 289 rqstp->rq_xid = svc_getu32(argv);
290 svc_putu32(resv, rqstp->rq_xid); 290 svc_putu32(resv, rqstp->rq_xid);
291 291
292 dir = ntohl(svc_getu32(argv)); 292 dir = svc_getnl(argv);
293 vers = ntohl(svc_getu32(argv)); 293 vers = svc_getnl(argv);
294 294
295 /* First words of reply: */ 295 /* First words of reply: */
296 svc_putu32(resv, xdr_one); /* REPLY */ 296 svc_putnl(resv, 1); /* REPLY */
297 297
298 if (dir != 0) /* direction != CALL */ 298 if (dir != 0) /* direction != CALL */
299 goto err_bad_dir; 299 goto err_bad_dir;
@@ -303,11 +303,11 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
303 /* Save position in case we later decide to reject: */ 303 /* Save position in case we later decide to reject: */
304 accept_statp = resv->iov_base + resv->iov_len; 304 accept_statp = resv->iov_base + resv->iov_len;
305 305
306 svc_putu32(resv, xdr_zero); /* ACCEPT */ 306 svc_putnl(resv, 0); /* ACCEPT */
307 307
308 rqstp->rq_prog = prog = ntohl(svc_getu32(argv)); /* program number */ 308 rqstp->rq_prog = prog = svc_getnl(argv); /* program number */
309 rqstp->rq_vers = vers = ntohl(svc_getu32(argv)); /* version number */ 309 rqstp->rq_vers = vers = svc_getnl(argv); /* version number */
310 rqstp->rq_proc = proc = ntohl(svc_getu32(argv)); /* procedure number */ 310 rqstp->rq_proc = proc = svc_getnl(argv); /* procedure number */
311 311
312 progp = serv->sv_program; 312 progp = serv->sv_program;
313 313
@@ -361,7 +361,7 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
361 361
362 /* Build the reply header. */ 362 /* Build the reply header. */
363 statp = resv->iov_base +resv->iov_len; 363 statp = resv->iov_base +resv->iov_len;
364 svc_putu32(resv, rpc_success); /* RPC_SUCCESS */ 364 svc_putnl(resv, RPC_SUCCESS);
365 365
366 /* Bump per-procedure stats counter */ 366 /* Bump per-procedure stats counter */
367 procp->pc_count++; 367 procp->pc_count++;
@@ -439,10 +439,10 @@ err_bad_dir:
439 439
440err_bad_rpc: 440err_bad_rpc:
441 serv->sv_stats->rpcbadfmt++; 441 serv->sv_stats->rpcbadfmt++;
442 svc_putu32(resv, xdr_one); /* REJECT */ 442 svc_putnl(resv, 1); /* REJECT */
443 svc_putu32(resv, xdr_zero); /* RPC_MISMATCH */ 443 svc_putnl(resv, 0); /* RPC_MISMATCH */
444 svc_putu32(resv, xdr_two); /* Only RPCv2 supported */ 444 svc_putnl(resv, 2); /* Only RPCv2 supported */
445 svc_putu32(resv, xdr_two); 445 svc_putnl(resv, 2);
446 goto sendit; 446 goto sendit;
447 447
448err_bad_auth: 448err_bad_auth:
@@ -450,15 +450,15 @@ err_bad_auth:
450 serv->sv_stats->rpcbadauth++; 450 serv->sv_stats->rpcbadauth++;
451 /* Restore write pointer to location of accept status: */ 451 /* Restore write pointer to location of accept status: */
452 xdr_ressize_check(rqstp, accept_statp); 452 xdr_ressize_check(rqstp, accept_statp);
453 svc_putu32(resv, xdr_one); /* REJECT */ 453 svc_putnl(resv, 1); /* REJECT */
454 svc_putu32(resv, xdr_one); /* AUTH_ERROR */ 454 svc_putnl(resv, 1); /* AUTH_ERROR */
455 svc_putu32(resv, auth_stat); /* status */ 455 svc_putnl(resv, ntohl(auth_stat)); /* status */
456 goto sendit; 456 goto sendit;
457 457
458err_bad_prog: 458err_bad_prog:
459 dprintk("svc: unknown program %d\n", prog); 459 dprintk("svc: unknown program %d\n", prog);
460 serv->sv_stats->rpcbadfmt++; 460 serv->sv_stats->rpcbadfmt++;
461 svc_putu32(resv, rpc_prog_unavail); 461 svc_putnl(resv, RPC_PROG_UNAVAIL);
462 goto sendit; 462 goto sendit;
463 463
464err_bad_vers: 464err_bad_vers:
@@ -466,9 +466,9 @@ err_bad_vers:
466 printk("svc: unknown version (%d)\n", vers); 466 printk("svc: unknown version (%d)\n", vers);
467#endif 467#endif
468 serv->sv_stats->rpcbadfmt++; 468 serv->sv_stats->rpcbadfmt++;
469 svc_putu32(resv, rpc_prog_mismatch); 469 svc_putnl(resv, RPC_PROG_MISMATCH);
470 svc_putu32(resv, htonl(progp->pg_lovers)); 470 svc_putnl(resv, progp->pg_lovers);
471 svc_putu32(resv, htonl(progp->pg_hivers)); 471 svc_putnl(resv, progp->pg_hivers);
472 goto sendit; 472 goto sendit;
473 473
474err_bad_proc: 474err_bad_proc:
@@ -476,7 +476,7 @@ err_bad_proc:
476 printk("svc: unknown procedure (%d)\n", proc); 476 printk("svc: unknown procedure (%d)\n", proc);
477#endif 477#endif
478 serv->sv_stats->rpcbadfmt++; 478 serv->sv_stats->rpcbadfmt++;
479 svc_putu32(resv, rpc_proc_unavail); 479 svc_putnl(resv, RPC_PROC_UNAVAIL);
480 goto sendit; 480 goto sendit;
481 481
482err_garbage: 482err_garbage:
@@ -486,6 +486,6 @@ err_garbage:
486 rpc_stat = rpc_garbage_args; 486 rpc_stat = rpc_garbage_args;
487err_bad: 487err_bad:
488 serv->sv_stats->rpcbadfmt++; 488 serv->sv_stats->rpcbadfmt++;
489 svc_putu32(resv, rpc_stat); 489 svc_putnl(resv, ntohl(rpc_stat));
490 goto sendit; 490 goto sendit;
491} 491}