svc.c (65ba3d2425bf51165b6e88509c632bd15d12883d) svc.c (f1aa2eb5ea05ccd1fd92d235346e60e90a1ed949)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/fs/lockd/svc.c
4 *
5 * This is the central lockd service.
6 *
7 * FIXME: Separate the lockd NFS server functionality from the lockd NFS
8 * client functionality. Oh why didn't Sun create two separate

--- 482 unchanged lines hidden (view full) ---

491 .mode = 0644,
492 .proc_handler = proc_dointvec_minmax,
493 .extra1 = (int *) &nlm_port_min,
494 .extra2 = (int *) &nlm_port_max,
495 },
496 {
497 .procname = "nsm_use_hostnames",
498 .data = &nsm_use_hostnames,
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * linux/fs/lockd/svc.c
4 *
5 * This is the central lockd service.
6 *
7 * FIXME: Separate the lockd NFS server functionality from the lockd NFS
8 * client functionality. Oh why didn't Sun create two separate

--- 482 unchanged lines hidden (view full) ---

491 .mode = 0644,
492 .proc_handler = proc_dointvec_minmax,
493 .extra1 = (int *) &nlm_port_min,
494 .extra2 = (int *) &nlm_port_max,
495 },
496 {
497 .procname = "nsm_use_hostnames",
498 .data = &nsm_use_hostnames,
499 .maxlen = sizeof(int),
499 .maxlen = sizeof(bool),
500 .mode = 0644,
501 .proc_handler = proc_dobool,
502 },
503 {
504 .procname = "nsm_local_state",
505 .data = &nsm_local_state,
506 .maxlen = sizeof(int),
507 .mode = 0644,

--- 172 unchanged lines hidden (view full) ---

680}
681
682module_init(init_nlm);
683module_exit(exit_nlm);
684
685/**
686 * nlmsvc_dispatch - Process an NLM Request
687 * @rqstp: incoming request
500 .mode = 0644,
501 .proc_handler = proc_dobool,
502 },
503 {
504 .procname = "nsm_local_state",
505 .data = &nsm_local_state,
506 .maxlen = sizeof(int),
507 .mode = 0644,

--- 172 unchanged lines hidden (view full) ---

680}
681
682module_init(init_nlm);
683module_exit(exit_nlm);
684
685/**
686 * nlmsvc_dispatch - Process an NLM Request
687 * @rqstp: incoming request
688 * @statp: pointer to location of accept_stat field in RPC Reply buffer
688 *
689 * Return values:
690 * %0: Processing complete; do not send a Reply
691 * %1: Processing complete; send Reply in rqstp->rq_res
692 */
689 *
690 * Return values:
691 * %0: Processing complete; do not send a Reply
692 * %1: Processing complete; send Reply in rqstp->rq_res
693 */
693static int nlmsvc_dispatch(struct svc_rqst *rqstp)
694static int nlmsvc_dispatch(struct svc_rqst *rqstp, __be32 *statp)
694{
695 const struct svc_procedure *procp = rqstp->rq_procinfo;
695{
696 const struct svc_procedure *procp = rqstp->rq_procinfo;
696 __be32 *statp = rqstp->rq_accept_statp;
697
697
698 svcxdr_init_decode(rqstp);
698 if (!procp->pc_decode(rqstp, &rqstp->rq_arg_stream))
699 goto out_decode_err;
700
701 *statp = procp->pc_func(rqstp);
702 if (*statp == rpc_drop_reply)
703 return 0;
704 if (*statp != rpc_success)
705 return 1;
706
699 if (!procp->pc_decode(rqstp, &rqstp->rq_arg_stream))
700 goto out_decode_err;
701
702 *statp = procp->pc_func(rqstp);
703 if (*statp == rpc_drop_reply)
704 return 0;
705 if (*statp != rpc_success)
706 return 1;
707
708 svcxdr_init_encode(rqstp);
707 if (!procp->pc_encode(rqstp, &rqstp->rq_res_stream))
708 goto out_encode_err;
709
710 return 1;
711
712out_decode_err:
713 *statp = rpc_garbage_args;
714 return 1;
715
716out_encode_err:
717 *statp = rpc_system_err;
718 return 1;
719}
720
721/*
722 * Define NLM program and procedures
723 */
709 if (!procp->pc_encode(rqstp, &rqstp->rq_res_stream))
710 goto out_encode_err;
711
712 return 1;
713
714out_decode_err:
715 *statp = rpc_garbage_args;
716 return 1;
717
718out_encode_err:
719 *statp = rpc_system_err;
720 return 1;
721}
722
723/*
724 * Define NLM program and procedures
725 */
724static DEFINE_PER_CPU_ALIGNED(unsigned long, nlmsvc_version1_count[17]);
726static unsigned int nlmsvc_version1_count[17];
725static const struct svc_version nlmsvc_version1 = {
726 .vs_vers = 1,
727 .vs_nproc = 17,
728 .vs_proc = nlmsvc_procedures,
729 .vs_count = nlmsvc_version1_count,
730 .vs_dispatch = nlmsvc_dispatch,
731 .vs_xdrsize = NLMSVC_XDRSIZE,
732};
727static const struct svc_version nlmsvc_version1 = {
728 .vs_vers = 1,
729 .vs_nproc = 17,
730 .vs_proc = nlmsvc_procedures,
731 .vs_count = nlmsvc_version1_count,
732 .vs_dispatch = nlmsvc_dispatch,
733 .vs_xdrsize = NLMSVC_XDRSIZE,
734};
733
734static DEFINE_PER_CPU_ALIGNED(unsigned long,
735 nlmsvc_version3_count[ARRAY_SIZE(nlmsvc_procedures)]);
735static unsigned int nlmsvc_version3_count[24];
736static const struct svc_version nlmsvc_version3 = {
737 .vs_vers = 3,
736static const struct svc_version nlmsvc_version3 = {
737 .vs_vers = 3,
738 .vs_nproc = ARRAY_SIZE(nlmsvc_procedures),
738 .vs_nproc = 24,
739 .vs_proc = nlmsvc_procedures,
740 .vs_count = nlmsvc_version3_count,
741 .vs_dispatch = nlmsvc_dispatch,
742 .vs_xdrsize = NLMSVC_XDRSIZE,
743};
739 .vs_proc = nlmsvc_procedures,
740 .vs_count = nlmsvc_version3_count,
741 .vs_dispatch = nlmsvc_dispatch,
742 .vs_xdrsize = NLMSVC_XDRSIZE,
743};
744
745#ifdef CONFIG_LOCKD_V4
744#ifdef CONFIG_LOCKD_V4
746static DEFINE_PER_CPU_ALIGNED(unsigned long,
747 nlmsvc_version4_count[ARRAY_SIZE(nlmsvc_procedures4)]);
745static unsigned int nlmsvc_version4_count[24];
748static const struct svc_version nlmsvc_version4 = {
749 .vs_vers = 4,
746static const struct svc_version nlmsvc_version4 = {
747 .vs_vers = 4,
750 .vs_nproc = ARRAY_SIZE(nlmsvc_procedures4),
748 .vs_nproc = 24,
751 .vs_proc = nlmsvc_procedures4,
752 .vs_count = nlmsvc_version4_count,
753 .vs_dispatch = nlmsvc_dispatch,
754 .vs_xdrsize = NLMSVC_XDRSIZE,
755};
756#endif
749 .vs_proc = nlmsvc_procedures4,
750 .vs_count = nlmsvc_version4_count,
751 .vs_dispatch = nlmsvc_dispatch,
752 .vs_xdrsize = NLMSVC_XDRSIZE,
753};
754#endif
757
758static const struct svc_version *nlmsvc_version[] = {
759 [1] = &nlmsvc_version1,
760 [3] = &nlmsvc_version3,
761#ifdef CONFIG_LOCKD_V4
762 [4] = &nlmsvc_version4,
763#endif
764};
765

--- 14 unchanged lines hidden ---
755static const struct svc_version *nlmsvc_version[] = {
756 [1] = &nlmsvc_version1,
757 [3] = &nlmsvc_version3,
758#ifdef CONFIG_LOCKD_V4
759 [4] = &nlmsvc_version4,
760#endif
761};
762

--- 14 unchanged lines hidden ---