diff options
-rw-r--r-- | fs/lockd/mon.c | 68 |
1 files changed, 25 insertions, 43 deletions
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index e0c918949644..d812818d0258 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c | |||
@@ -401,26 +401,22 @@ void nsm_release(struct nsm_handle *nsm) | |||
401 | * Status Monitor wire protocol. | 401 | * Status Monitor wire protocol. |
402 | */ | 402 | */ |
403 | 403 | ||
404 | static int encode_nsm_string(struct xdr_stream *xdr, const char *string) | 404 | static void encode_nsm_string(struct xdr_stream *xdr, const char *string) |
405 | { | 405 | { |
406 | const u32 len = strlen(string); | 406 | const u32 len = strlen(string); |
407 | __be32 *p; | 407 | __be32 *p; |
408 | 408 | ||
409 | if (unlikely(len > SM_MAXSTRLEN)) | 409 | BUG_ON(len > SM_MAXSTRLEN); |
410 | return -EIO; | 410 | p = xdr_reserve_space(xdr, 4 + len); |
411 | p = xdr_reserve_space(xdr, sizeof(u32) + len); | ||
412 | if (unlikely(p == NULL)) | ||
413 | return -EIO; | ||
414 | xdr_encode_opaque(p, string, len); | 411 | xdr_encode_opaque(p, string, len); |
415 | return 0; | ||
416 | } | 412 | } |
417 | 413 | ||
418 | /* | 414 | /* |
419 | * "mon_name" specifies the host to be monitored. | 415 | * "mon_name" specifies the host to be monitored. |
420 | */ | 416 | */ |
421 | static int encode_mon_name(struct xdr_stream *xdr, const struct nsm_args *argp) | 417 | static void encode_mon_name(struct xdr_stream *xdr, const struct nsm_args *argp) |
422 | { | 418 | { |
423 | return encode_nsm_string(xdr, argp->mon_name); | 419 | encode_nsm_string(xdr, argp->mon_name); |
424 | } | 420 | } |
425 | 421 | ||
426 | /* | 422 | /* |
@@ -429,35 +425,25 @@ static int encode_mon_name(struct xdr_stream *xdr, const struct nsm_args *argp) | |||
429 | * (via the NLMPROC_SM_NOTIFY call) that the state of host "mon_name" | 425 | * (via the NLMPROC_SM_NOTIFY call) that the state of host "mon_name" |
430 | * has changed. | 426 | * has changed. |
431 | */ | 427 | */ |
432 | static int encode_my_id(struct xdr_stream *xdr, const struct nsm_args *argp) | 428 | static void encode_my_id(struct xdr_stream *xdr, const struct nsm_args *argp) |
433 | { | 429 | { |
434 | int status; | ||
435 | __be32 *p; | 430 | __be32 *p; |
436 | 431 | ||
437 | status = encode_nsm_string(xdr, utsname()->nodename); | 432 | encode_nsm_string(xdr, utsname()->nodename); |
438 | if (unlikely(status != 0)) | 433 | p = xdr_reserve_space(xdr, 4 + 4 + 4); |
439 | return status; | 434 | *p++ = cpu_to_be32(argp->prog); |
440 | p = xdr_reserve_space(xdr, 3 * sizeof(u32)); | 435 | *p++ = cpu_to_be32(argp->vers); |
441 | if (unlikely(p == NULL)) | 436 | *p = cpu_to_be32(argp->proc); |
442 | return -EIO; | ||
443 | *p++ = htonl(argp->prog); | ||
444 | *p++ = htonl(argp->vers); | ||
445 | *p++ = htonl(argp->proc); | ||
446 | return 0; | ||
447 | } | 437 | } |
448 | 438 | ||
449 | /* | 439 | /* |
450 | * The "mon_id" argument specifies the non-private arguments | 440 | * The "mon_id" argument specifies the non-private arguments |
451 | * of an NSMPROC_MON or NSMPROC_UNMON call. | 441 | * of an NSMPROC_MON or NSMPROC_UNMON call. |
452 | */ | 442 | */ |
453 | static int encode_mon_id(struct xdr_stream *xdr, const struct nsm_args *argp) | 443 | static void encode_mon_id(struct xdr_stream *xdr, const struct nsm_args *argp) |
454 | { | 444 | { |
455 | int status; | 445 | encode_mon_name(xdr, argp); |
456 | 446 | encode_my_id(xdr, argp); | |
457 | status = encode_mon_name(xdr, argp); | ||
458 | if (unlikely(status != 0)) | ||
459 | return status; | ||
460 | return encode_my_id(xdr, argp); | ||
461 | } | 447 | } |
462 | 448 | ||
463 | /* | 449 | /* |
@@ -465,28 +451,23 @@ static int encode_mon_id(struct xdr_stream *xdr, const struct nsm_args *argp) | |||
465 | * by the NSMPROC_MON call. This information will be supplied in the | 451 | * by the NSMPROC_MON call. This information will be supplied in the |
466 | * NLMPROC_SM_NOTIFY call. | 452 | * NLMPROC_SM_NOTIFY call. |
467 | */ | 453 | */ |
468 | static int encode_priv(struct xdr_stream *xdr, const struct nsm_args *argp) | 454 | static void encode_priv(struct xdr_stream *xdr, const struct nsm_args *argp) |
469 | { | 455 | { |
470 | __be32 *p; | 456 | __be32 *p; |
471 | 457 | ||
472 | p = xdr_reserve_space(xdr, SM_PRIV_SIZE); | 458 | p = xdr_reserve_space(xdr, SM_PRIV_SIZE); |
473 | if (unlikely(p == NULL)) | ||
474 | return -EIO; | ||
475 | xdr_encode_opaque_fixed(p, argp->priv->data, SM_PRIV_SIZE); | 459 | xdr_encode_opaque_fixed(p, argp->priv->data, SM_PRIV_SIZE); |
476 | return 0; | ||
477 | } | 460 | } |
478 | 461 | ||
479 | static int xdr_enc_mon(struct rpc_rqst *req, __be32 *p, | 462 | static int xdr_enc_mon(struct rpc_rqst *req, __be32 *p, |
480 | const struct nsm_args *argp) | 463 | const struct nsm_args *argp) |
481 | { | 464 | { |
482 | struct xdr_stream xdr; | 465 | struct xdr_stream xdr; |
483 | int status; | ||
484 | 466 | ||
485 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 467 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
486 | status = encode_mon_id(&xdr, argp); | 468 | encode_mon_id(&xdr, argp); |
487 | if (unlikely(status)) | 469 | encode_priv(&xdr, argp); |
488 | return status; | 470 | return 0; |
489 | return encode_priv(&xdr, argp); | ||
490 | } | 471 | } |
491 | 472 | ||
492 | static int xdr_enc_unmon(struct rpc_rqst *req, __be32 *p, | 473 | static int xdr_enc_unmon(struct rpc_rqst *req, __be32 *p, |
@@ -495,7 +476,8 @@ static int xdr_enc_unmon(struct rpc_rqst *req, __be32 *p, | |||
495 | struct xdr_stream xdr; | 476 | struct xdr_stream xdr; |
496 | 477 | ||
497 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 478 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
498 | return encode_mon_id(&xdr, argp); | 479 | encode_mon_id(&xdr, argp); |
480 | return 0; | ||
499 | } | 481 | } |
500 | 482 | ||
501 | static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p, | 483 | static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p, |
@@ -504,11 +486,11 @@ static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p, | |||
504 | struct xdr_stream xdr; | 486 | struct xdr_stream xdr; |
505 | 487 | ||
506 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 488 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
507 | p = xdr_inline_decode(&xdr, 2 * sizeof(u32)); | 489 | p = xdr_inline_decode(&xdr, 4 + 4); |
508 | if (unlikely(p == NULL)) | 490 | if (unlikely(p == NULL)) |
509 | return -EIO; | 491 | return -EIO; |
510 | resp->status = ntohl(*p++); | 492 | resp->status = be32_to_cpup(p++); |
511 | resp->state = ntohl(*p); | 493 | resp->state = be32_to_cpup(p); |
512 | 494 | ||
513 | dprintk("lockd: xdr_dec_stat_res status %d state %d\n", | 495 | dprintk("lockd: xdr_dec_stat_res status %d state %d\n", |
514 | resp->status, resp->state); | 496 | resp->status, resp->state); |
@@ -521,10 +503,10 @@ static int xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p, | |||
521 | struct xdr_stream xdr; | 503 | struct xdr_stream xdr; |
522 | 504 | ||
523 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 505 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
524 | p = xdr_inline_decode(&xdr, sizeof(u32)); | 506 | p = xdr_inline_decode(&xdr, 4); |
525 | if (unlikely(p == NULL)) | 507 | if (unlikely(p == NULL)) |
526 | return -EIO; | 508 | return -EIO; |
527 | resp->state = ntohl(*p); | 509 | resp->state = be32_to_cpup(p); |
528 | 510 | ||
529 | dprintk("lockd: xdr_dec_stat state %d\n", resp->state); | 511 | dprintk("lockd: xdr_dec_stat state %d\n", resp->state); |
530 | return 0; | 512 | return 0; |