diff options
Diffstat (limited to 'fs/lockd/mon.c')
-rw-r--r-- | fs/lockd/mon.c | 111 |
1 files changed, 43 insertions, 68 deletions
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index e3015464fbab..23d7451b2938 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c | |||
@@ -69,6 +69,7 @@ static struct rpc_clnt *nsm_create(void) | |||
69 | .sin_addr.s_addr = htonl(INADDR_LOOPBACK), | 69 | .sin_addr.s_addr = htonl(INADDR_LOOPBACK), |
70 | }; | 70 | }; |
71 | struct rpc_create_args args = { | 71 | struct rpc_create_args args = { |
72 | .net = &init_net, | ||
72 | .protocol = XPRT_TRANSPORT_UDP, | 73 | .protocol = XPRT_TRANSPORT_UDP, |
73 | .address = (struct sockaddr *)&sin, | 74 | .address = (struct sockaddr *)&sin, |
74 | .addrsize = sizeof(sin), | 75 | .addrsize = sizeof(sin), |
@@ -400,26 +401,22 @@ void nsm_release(struct nsm_handle *nsm) | |||
400 | * Status Monitor wire protocol. | 401 | * Status Monitor wire protocol. |
401 | */ | 402 | */ |
402 | 403 | ||
403 | 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) |
404 | { | 405 | { |
405 | const u32 len = strlen(string); | 406 | const u32 len = strlen(string); |
406 | __be32 *p; | 407 | __be32 *p; |
407 | 408 | ||
408 | if (unlikely(len > SM_MAXSTRLEN)) | 409 | BUG_ON(len > SM_MAXSTRLEN); |
409 | return -EIO; | 410 | p = xdr_reserve_space(xdr, 4 + len); |
410 | p = xdr_reserve_space(xdr, sizeof(u32) + len); | ||
411 | if (unlikely(p == NULL)) | ||
412 | return -EIO; | ||
413 | xdr_encode_opaque(p, string, len); | 411 | xdr_encode_opaque(p, string, len); |
414 | return 0; | ||
415 | } | 412 | } |
416 | 413 | ||
417 | /* | 414 | /* |
418 | * "mon_name" specifies the host to be monitored. | 415 | * "mon_name" specifies the host to be monitored. |
419 | */ | 416 | */ |
420 | 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) |
421 | { | 418 | { |
422 | return encode_nsm_string(xdr, argp->mon_name); | 419 | encode_nsm_string(xdr, argp->mon_name); |
423 | } | 420 | } |
424 | 421 | ||
425 | /* | 422 | /* |
@@ -428,35 +425,25 @@ static int encode_mon_name(struct xdr_stream *xdr, const struct nsm_args *argp) | |||
428 | * (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" |
429 | * has changed. | 426 | * has changed. |
430 | */ | 427 | */ |
431 | 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) |
432 | { | 429 | { |
433 | int status; | ||
434 | __be32 *p; | 430 | __be32 *p; |
435 | 431 | ||
436 | status = encode_nsm_string(xdr, utsname()->nodename); | 432 | encode_nsm_string(xdr, utsname()->nodename); |
437 | if (unlikely(status != 0)) | 433 | p = xdr_reserve_space(xdr, 4 + 4 + 4); |
438 | return status; | 434 | *p++ = cpu_to_be32(argp->prog); |
439 | p = xdr_reserve_space(xdr, 3 * sizeof(u32)); | 435 | *p++ = cpu_to_be32(argp->vers); |
440 | if (unlikely(p == NULL)) | 436 | *p = cpu_to_be32(argp->proc); |
441 | return -EIO; | ||
442 | *p++ = htonl(argp->prog); | ||
443 | *p++ = htonl(argp->vers); | ||
444 | *p++ = htonl(argp->proc); | ||
445 | return 0; | ||
446 | } | 437 | } |
447 | 438 | ||
448 | /* | 439 | /* |
449 | * The "mon_id" argument specifies the non-private arguments | 440 | * The "mon_id" argument specifies the non-private arguments |
450 | * of an NSMPROC_MON or NSMPROC_UNMON call. | 441 | * of an NSMPROC_MON or NSMPROC_UNMON call. |
451 | */ | 442 | */ |
452 | 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) |
453 | { | 444 | { |
454 | int status; | 445 | encode_mon_name(xdr, argp); |
455 | 446 | encode_my_id(xdr, argp); | |
456 | status = encode_mon_name(xdr, argp); | ||
457 | if (unlikely(status != 0)) | ||
458 | return status; | ||
459 | return encode_my_id(xdr, argp); | ||
460 | } | 447 | } |
461 | 448 | ||
462 | /* | 449 | /* |
@@ -464,68 +451,56 @@ static int encode_mon_id(struct xdr_stream *xdr, const struct nsm_args *argp) | |||
464 | * 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 |
465 | * NLMPROC_SM_NOTIFY call. | 452 | * NLMPROC_SM_NOTIFY call. |
466 | */ | 453 | */ |
467 | 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) |
468 | { | 455 | { |
469 | __be32 *p; | 456 | __be32 *p; |
470 | 457 | ||
471 | p = xdr_reserve_space(xdr, SM_PRIV_SIZE); | 458 | p = xdr_reserve_space(xdr, SM_PRIV_SIZE); |
472 | if (unlikely(p == NULL)) | ||
473 | return -EIO; | ||
474 | xdr_encode_opaque_fixed(p, argp->priv->data, SM_PRIV_SIZE); | 459 | xdr_encode_opaque_fixed(p, argp->priv->data, SM_PRIV_SIZE); |
475 | return 0; | ||
476 | } | 460 | } |
477 | 461 | ||
478 | static int xdr_enc_mon(struct rpc_rqst *req, __be32 *p, | 462 | static void nsm_xdr_enc_mon(struct rpc_rqst *req, struct xdr_stream *xdr, |
479 | const struct nsm_args *argp) | 463 | const struct nsm_args *argp) |
480 | { | 464 | { |
481 | struct xdr_stream xdr; | 465 | encode_mon_id(xdr, argp); |
482 | int status; | 466 | encode_priv(xdr, argp); |
483 | |||
484 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | ||
485 | status = encode_mon_id(&xdr, argp); | ||
486 | if (unlikely(status)) | ||
487 | return status; | ||
488 | return encode_priv(&xdr, argp); | ||
489 | } | 467 | } |
490 | 468 | ||
491 | static int xdr_enc_unmon(struct rpc_rqst *req, __be32 *p, | 469 | static void nsm_xdr_enc_unmon(struct rpc_rqst *req, struct xdr_stream *xdr, |
492 | const struct nsm_args *argp) | 470 | const struct nsm_args *argp) |
493 | { | 471 | { |
494 | struct xdr_stream xdr; | 472 | encode_mon_id(xdr, argp); |
495 | |||
496 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | ||
497 | return encode_mon_id(&xdr, argp); | ||
498 | } | 473 | } |
499 | 474 | ||
500 | static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p, | 475 | static int nsm_xdr_dec_stat_res(struct rpc_rqst *rqstp, |
501 | struct nsm_res *resp) | 476 | struct xdr_stream *xdr, |
477 | struct nsm_res *resp) | ||
502 | { | 478 | { |
503 | struct xdr_stream xdr; | 479 | __be32 *p; |
504 | 480 | ||
505 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 481 | p = xdr_inline_decode(xdr, 4 + 4); |
506 | p = xdr_inline_decode(&xdr, 2 * sizeof(u32)); | ||
507 | if (unlikely(p == NULL)) | 482 | if (unlikely(p == NULL)) |
508 | return -EIO; | 483 | return -EIO; |
509 | resp->status = ntohl(*p++); | 484 | resp->status = be32_to_cpup(p++); |
510 | resp->state = ntohl(*p); | 485 | resp->state = be32_to_cpup(p); |
511 | 486 | ||
512 | dprintk("lockd: xdr_dec_stat_res status %d state %d\n", | 487 | dprintk("lockd: %s status %d state %d\n", |
513 | resp->status, resp->state); | 488 | __func__, resp->status, resp->state); |
514 | return 0; | 489 | return 0; |
515 | } | 490 | } |
516 | 491 | ||
517 | static int xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p, | 492 | static int nsm_xdr_dec_stat(struct rpc_rqst *rqstp, |
518 | struct nsm_res *resp) | 493 | struct xdr_stream *xdr, |
494 | struct nsm_res *resp) | ||
519 | { | 495 | { |
520 | struct xdr_stream xdr; | 496 | __be32 *p; |
521 | 497 | ||
522 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 498 | p = xdr_inline_decode(xdr, 4); |
523 | p = xdr_inline_decode(&xdr, sizeof(u32)); | ||
524 | if (unlikely(p == NULL)) | 499 | if (unlikely(p == NULL)) |
525 | return -EIO; | 500 | return -EIO; |
526 | resp->state = ntohl(*p); | 501 | resp->state = be32_to_cpup(p); |
527 | 502 | ||
528 | dprintk("lockd: xdr_dec_stat state %d\n", resp->state); | 503 | dprintk("lockd: %s state %d\n", __func__, resp->state); |
529 | return 0; | 504 | return 0; |
530 | } | 505 | } |
531 | 506 | ||
@@ -541,8 +516,8 @@ static int xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p, | |||
541 | static struct rpc_procinfo nsm_procedures[] = { | 516 | static struct rpc_procinfo nsm_procedures[] = { |
542 | [NSMPROC_MON] = { | 517 | [NSMPROC_MON] = { |
543 | .p_proc = NSMPROC_MON, | 518 | .p_proc = NSMPROC_MON, |
544 | .p_encode = (kxdrproc_t)xdr_enc_mon, | 519 | .p_encode = (kxdreproc_t)nsm_xdr_enc_mon, |
545 | .p_decode = (kxdrproc_t)xdr_dec_stat_res, | 520 | .p_decode = (kxdrdproc_t)nsm_xdr_dec_stat_res, |
546 | .p_arglen = SM_mon_sz, | 521 | .p_arglen = SM_mon_sz, |
547 | .p_replen = SM_monres_sz, | 522 | .p_replen = SM_monres_sz, |
548 | .p_statidx = NSMPROC_MON, | 523 | .p_statidx = NSMPROC_MON, |
@@ -550,8 +525,8 @@ static struct rpc_procinfo nsm_procedures[] = { | |||
550 | }, | 525 | }, |
551 | [NSMPROC_UNMON] = { | 526 | [NSMPROC_UNMON] = { |
552 | .p_proc = NSMPROC_UNMON, | 527 | .p_proc = NSMPROC_UNMON, |
553 | .p_encode = (kxdrproc_t)xdr_enc_unmon, | 528 | .p_encode = (kxdreproc_t)nsm_xdr_enc_unmon, |
554 | .p_decode = (kxdrproc_t)xdr_dec_stat, | 529 | .p_decode = (kxdrdproc_t)nsm_xdr_dec_stat, |
555 | .p_arglen = SM_mon_id_sz, | 530 | .p_arglen = SM_mon_id_sz, |
556 | .p_replen = SM_unmonres_sz, | 531 | .p_replen = SM_unmonres_sz, |
557 | .p_statidx = NSMPROC_UNMON, | 532 | .p_statidx = NSMPROC_UNMON, |