blob: 32784f508c8106313a4b1e7728b56e22bcd857b7 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * linux/fs/lockd/svcproc.c
4 *
5 * Lockd server procedures. We don't implement the NLM_*_RES
6 * procedures because we don't use the async procedures.
7 *
8 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
9 */
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/types.h>
12#include <linux/time.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/lockd/lockd.h>
14#include <linux/lockd/share.h>
Stanislav Kinsbursky5ccb0062012-07-25 16:57:22 +040015#include <linux/sunrpc/svc_xprt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17#define NLMDBG_FACILITY NLMDBG_CLIENT
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#ifdef CONFIG_LOCKD_V4
Al Viro52921e02006-10-19 23:28:46 -070020static __be32
21cast_to_nlm(__be32 status, u32 vers)
Linus Torvalds1da177e2005-04-16 15:20:36 -070022{
23 /* Note: status is assumed to be in network byte order !!! */
24 if (vers != 4){
25 switch (status) {
26 case nlm_granted:
27 case nlm_lck_denied:
28 case nlm_lck_denied_nolocks:
29 case nlm_lck_blocked:
30 case nlm_lck_denied_grace_period:
Marc Eshel5ea0d752006-11-28 16:27:06 -050031 case nlm_drop_reply:
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 break;
33 case nlm4_deadlock:
34 status = nlm_lck_denied;
35 break;
36 default:
37 status = nlm_lck_denied_nolocks;
38 }
39 }
40
41 return (status);
42}
43#define cast_status(status) (cast_to_nlm(status, rqstp->rq_vers))
44#else
45#define cast_status(status) (status)
46#endif
47
48/*
49 * Obtain client and file from arguments
50 */
Al Viro52921e02006-10-19 23:28:46 -070051static __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -070052nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
53 struct nlm_host **hostp, struct nlm_file **filp)
54{
55 struct nlm_host *host = NULL;
56 struct nlm_file *file = NULL;
57 struct nlm_lock *lock = &argp->lock;
J. Bruce Fields7f024fc2021-08-23 16:44:00 -040058 int mode;
Al Viro52921e02006-10-19 23:28:46 -070059 __be32 error = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61 /* nfsd callbacks must have been installed for this procedure */
62 if (!nlmsvc_ops)
63 return nlm_lck_denied_nolocks;
64
65 /* Obtain host handle */
Olaf Kirchdb4e4c92006-10-04 02:15:52 -070066 if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
Olaf Kirch977faf32006-10-04 02:15:51 -070067 || (argp->monitor && nsm_monitor(host) < 0))
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 goto no_locks;
69 *hostp = host;
70
71 /* Obtain file pointer. Not used by FREE_ALL call. */
72 if (filp != NULL) {
J. Bruce Fields2dc6f192021-08-23 12:01:18 -040073 error = cast_status(nlm_lookup_file(rqstp, &file, lock));
Trond Myklebustcd0b16c2012-10-13 00:30:28 -040074 if (error != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 goto no_locks;
76 *filp = file;
77
78 /* Set up the missing parts of the file_lock structure */
J. Bruce Fields7f024fc2021-08-23 16:44:00 -040079 mode = lock_to_openmode(&lock->fl);
Jeff Layton75c79402022-11-11 14:36:36 -050080 lock->fl.fl_flags = FL_POSIX;
J. Bruce Fields7f024fc2021-08-23 16:44:00 -040081 lock->fl.fl_file = file->f_file[mode];
Benjamin Coddington646d73e2019-05-23 10:45:47 -040082 lock->fl.fl_pid = current->tgid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 lock->fl.fl_lmops = &nlmsvc_lock_operations;
Benjamin Coddington89e0edf2019-05-23 10:45:45 -040084 nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid);
85 if (!lock->fl.fl_owner) {
86 /* lockowner allocation has failed */
87 nlmsvc_release_host(host);
88 return nlm_lck_denied_nolocks;
89 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 }
91
92 return 0;
93
94no_locks:
Chuck Lever67216b92010-12-14 15:06:12 +000095 nlmsvc_release_host(host);
NeilBrownd343fce2006-10-17 00:10:18 -070096 if (error)
97 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 return nlm_lck_denied_nolocks;
99}
100
101/*
102 * NULL: Test for presence of service
103 */
Al Viro7111c662006-10-19 23:28:45 -0700104static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200105nlmsvc_proc_null(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106{
107 dprintk("lockd: NULL called\n");
108 return rpc_success;
109}
110
111/*
112 * TEST: Check for conflicting lock
113 */
Al Viro7111c662006-10-19 23:28:45 -0700114static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200115__nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200117 struct nlm_args *argp = rqstp->rq_argp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 struct nlm_host *host;
119 struct nlm_file *file;
Benjamin Coddington184cefb2022-06-13 09:40:06 -0400120 struct nlm_lockowner *test_owner;
Harvey Harrison317602f2008-07-20 23:41:24 -0700121 __be32 rc = rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123 dprintk("lockd: TEST called\n");
124 resp->cookie = argp->cookie;
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 /* Obtain client and file */
127 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700128 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
Benjamin Coddington184cefb2022-06-13 09:40:06 -0400130 test_owner = argp->lock.fl.fl_owner;
131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 /* Now check for conflicting locks */
Jeff Layton8f920d52008-07-15 14:06:48 -0400133 resp->status = cast_status(nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie));
Marc Eshel5ea0d752006-11-28 16:27:06 -0500134 if (resp->status == nlm_drop_reply)
Oleg Drokinb7e6b862007-11-26 13:35:11 -0500135 rc = rpc_drop_reply;
136 else
137 dprintk("lockd: TEST status %d vers %d\n",
138 ntohl(resp->status), rqstp->rq_vers);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
Benjamin Coddington184cefb2022-06-13 09:40:06 -0400140 nlmsvc_put_lockowner(test_owner);
Chuck Lever67216b92010-12-14 15:06:12 +0000141 nlmsvc_release_host(host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 nlm_release_file(file);
Oleg Drokinb7e6b862007-11-26 13:35:11 -0500143 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144}
145
Al Viro7111c662006-10-19 23:28:45 -0700146static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200147nlmsvc_proc_test(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200149 return __nlmsvc_proc_test(rqstp, rqstp->rq_resp);
150}
151
152static __be32
153__nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_res *resp)
154{
155 struct nlm_args *argp = rqstp->rq_argp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 struct nlm_host *host;
157 struct nlm_file *file;
Harvey Harrison317602f2008-07-20 23:41:24 -0700158 __be32 rc = rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
160 dprintk("lockd: LOCK called\n");
161
162 resp->cookie = argp->cookie;
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 /* Obtain client and file */
165 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700166 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
168#if 0
169 /* If supplied state doesn't match current state, we assume it's
170 * an old request that time-warped somehow. Any error return would
171 * do in this case because it's irrelevant anyway.
172 *
173 * NB: We don't retrieve the remote host's state yet.
174 */
175 if (host->h_nsmstate && host->h_nsmstate != argp->state) {
176 resp->status = nlm_lck_denied_nolocks;
177 } else
178#endif
179
180 /* Now try to lock the file */
Jeff Layton6cde4de2008-07-15 14:26:17 -0400181 resp->status = cast_status(nlmsvc_lock(rqstp, file, host, &argp->lock,
J. Bruce Fieldsb2b50282008-02-06 13:59:23 -0500182 argp->block, &argp->cookie,
183 argp->reclaim));
Marc Eshel1a8322b2006-11-28 16:27:06 -0500184 if (resp->status == nlm_drop_reply)
Oleg Drokinb7e6b862007-11-26 13:35:11 -0500185 rc = rpc_drop_reply;
186 else
187 dprintk("lockd: LOCK status %d\n", ntohl(resp->status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
Benjamin Coddington89e0edf2019-05-23 10:45:45 -0400189 nlmsvc_release_lockowner(&argp->lock);
Chuck Lever67216b92010-12-14 15:06:12 +0000190 nlmsvc_release_host(host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 nlm_release_file(file);
Oleg Drokinb7e6b862007-11-26 13:35:11 -0500192 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193}
194
Al Viro7111c662006-10-19 23:28:45 -0700195static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200196nlmsvc_proc_lock(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200198 return __nlmsvc_proc_lock(rqstp, rqstp->rq_resp);
199}
200
201static __be32
202__nlmsvc_proc_cancel(struct svc_rqst *rqstp, struct nlm_res *resp)
203{
204 struct nlm_args *argp = rqstp->rq_argp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 struct nlm_host *host;
206 struct nlm_file *file;
Stanislav Kinsbursky5ccb0062012-07-25 16:57:22 +0400207 struct net *net = SVC_NET(rqstp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
209 dprintk("lockd: CANCEL called\n");
210
211 resp->cookie = argp->cookie;
212
213 /* Don't accept requests during grace period */
Stanislav Kinsbursky5ccb0062012-07-25 16:57:22 +0400214 if (locks_in_grace(net)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 resp->status = nlm_lck_denied_grace_period;
216 return rpc_success;
217 }
218
219 /* Obtain client and file */
220 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700221 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223 /* Try to cancel request. */
Stanislav Kinsbursky5ccb0062012-07-25 16:57:22 +0400224 resp->status = cast_status(nlmsvc_cancel_blocked(net, file, &argp->lock));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
226 dprintk("lockd: CANCEL status %d\n", ntohl(resp->status));
Benjamin Coddington89e0edf2019-05-23 10:45:45 -0400227 nlmsvc_release_lockowner(&argp->lock);
Chuck Lever67216b92010-12-14 15:06:12 +0000228 nlmsvc_release_host(host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 nlm_release_file(file);
230 return rpc_success;
231}
232
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200233static __be32
234nlmsvc_proc_cancel(struct svc_rqst *rqstp)
235{
236 return __nlmsvc_proc_cancel(rqstp, rqstp->rq_resp);
237}
238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239/*
240 * UNLOCK: release a lock
241 */
Al Viro7111c662006-10-19 23:28:45 -0700242static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200243__nlmsvc_proc_unlock(struct svc_rqst *rqstp, struct nlm_res *resp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200245 struct nlm_args *argp = rqstp->rq_argp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 struct nlm_host *host;
247 struct nlm_file *file;
Stanislav Kinsbursky5ccb0062012-07-25 16:57:22 +0400248 struct net *net = SVC_NET(rqstp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
250 dprintk("lockd: UNLOCK called\n");
251
252 resp->cookie = argp->cookie;
253
254 /* Don't accept new lock requests during grace period */
Stanislav Kinsbursky5ccb0062012-07-25 16:57:22 +0400255 if (locks_in_grace(net)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 resp->status = nlm_lck_denied_grace_period;
257 return rpc_success;
258 }
259
260 /* Obtain client and file */
261 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700262 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
264 /* Now try to remove the lock */
Stanislav Kinsbursky5ccb0062012-07-25 16:57:22 +0400265 resp->status = cast_status(nlmsvc_unlock(net, file, &argp->lock));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
267 dprintk("lockd: UNLOCK status %d\n", ntohl(resp->status));
Benjamin Coddington89e0edf2019-05-23 10:45:45 -0400268 nlmsvc_release_lockowner(&argp->lock);
Chuck Lever67216b92010-12-14 15:06:12 +0000269 nlmsvc_release_host(host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 nlm_release_file(file);
271 return rpc_success;
272}
273
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200274static __be32
275nlmsvc_proc_unlock(struct svc_rqst *rqstp)
276{
277 return __nlmsvc_proc_unlock(rqstp, rqstp->rq_resp);
278}
279
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280/*
281 * GRANTED: A server calls us to tell that a process' lock request
282 * was granted
283 */
Al Viro7111c662006-10-19 23:28:45 -0700284static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200285__nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_res *resp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200287 struct nlm_args *argp = rqstp->rq_argp;
288
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 resp->cookie = argp->cookie;
290
291 dprintk("lockd: GRANTED called\n");
Chuck Leverdcff09f2008-10-03 12:50:36 -0400292 resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 dprintk("lockd: GRANTED status %d\n", ntohl(resp->status));
294 return rpc_success;
295}
296
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200297static __be32
298nlmsvc_proc_granted(struct svc_rqst *rqstp)
299{
300 return __nlmsvc_proc_granted(rqstp, rqstp->rq_resp);
301}
302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303/*
Trond Myklebustd4716622006-03-20 13:44:45 -0500304 * This is the generic lockd callback for async RPC calls
305 */
306static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
307{
Trond Myklebustd4716622006-03-20 13:44:45 -0500308}
309
Chuck Lever7db836d2010-12-14 15:05:42 +0000310void nlmsvc_release_call(struct nlm_rqst *call)
311{
Elena Reshetovafbca30c2017-11-29 13:15:46 +0200312 if (!refcount_dec_and_test(&call->a_count))
Chuck Lever7db836d2010-12-14 15:05:42 +0000313 return;
Chuck Lever67216b92010-12-14 15:06:12 +0000314 nlmsvc_release_host(call->a_host);
Chuck Lever7db836d2010-12-14 15:05:42 +0000315 kfree(call);
316}
317
Trond Myklebustd4716622006-03-20 13:44:45 -0500318static void nlmsvc_callback_release(void *data)
319{
Chuck Lever7db836d2010-12-14 15:05:42 +0000320 nlmsvc_release_call(data);
Trond Myklebustd4716622006-03-20 13:44:45 -0500321}
322
323static const struct rpc_call_ops nlmsvc_callback_ops = {
324 .rpc_call_done = nlmsvc_callback_exit,
325 .rpc_release = nlmsvc_callback_release,
326};
327
328/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 * `Async' versions of the above service routines. They aren't really,
330 * because we send the callback before the reply proper. I hope this
331 * doesn't break any clients.
332 */
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200333static __be32 nlmsvc_callback(struct svc_rqst *rqstp, u32 proc,
334 __be32 (*func)(struct svc_rqst *, struct nlm_res *))
Trond Myklebustd4716622006-03-20 13:44:45 -0500335{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200336 struct nlm_args *argp = rqstp->rq_argp;
Trond Myklebustd4716622006-03-20 13:44:45 -0500337 struct nlm_host *host;
338 struct nlm_rqst *call;
Al Viro7111c662006-10-19 23:28:45 -0700339 __be32 stat;
Trond Myklebustd4716622006-03-20 13:44:45 -0500340
Olaf Kirchdb4e4c92006-10-04 02:15:52 -0700341 host = nlmsvc_lookup_host(rqstp,
342 argp->lock.caller,
343 argp->lock.len);
Trond Myklebustd4716622006-03-20 13:44:45 -0500344 if (host == NULL)
345 return rpc_system_err;
346
347 call = nlm_alloc_call(host);
Al Viro446945a2012-07-26 00:39:50 +0400348 nlmsvc_release_host(host);
Trond Myklebustd4716622006-03-20 13:44:45 -0500349 if (call == NULL)
350 return rpc_system_err;
351
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200352 stat = func(rqstp, &call->a_res);
Trond Myklebustd4716622006-03-20 13:44:45 -0500353 if (stat != 0) {
Chuck Lever7db836d2010-12-14 15:05:42 +0000354 nlmsvc_release_call(call);
Trond Myklebustd4716622006-03-20 13:44:45 -0500355 return stat;
356 }
357
358 call->a_flags = RPC_TASK_ASYNC;
359 if (nlm_async_reply(call, proc, &nlmsvc_callback_ops) < 0)
360 return rpc_system_err;
361 return rpc_success;
362}
363
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200364static __be32 nlmsvc_proc_test_msg(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 dprintk("lockd: TEST_MSG called\n");
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200367 return nlmsvc_callback(rqstp, NLMPROC_TEST_RES, __nlmsvc_proc_test);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368}
369
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200370static __be32 nlmsvc_proc_lock_msg(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 dprintk("lockd: LOCK_MSG called\n");
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200373 return nlmsvc_callback(rqstp, NLMPROC_LOCK_RES, __nlmsvc_proc_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374}
375
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200376static __be32 nlmsvc_proc_cancel_msg(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 dprintk("lockd: CANCEL_MSG called\n");
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200379 return nlmsvc_callback(rqstp, NLMPROC_CANCEL_RES, __nlmsvc_proc_cancel);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380}
381
Al Viro7111c662006-10-19 23:28:45 -0700382static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200383nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 dprintk("lockd: UNLOCK_MSG called\n");
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200386 return nlmsvc_callback(rqstp, NLMPROC_UNLOCK_RES, __nlmsvc_proc_unlock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387}
388
Al Viro7111c662006-10-19 23:28:45 -0700389static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200390nlmsvc_proc_granted_msg(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 dprintk("lockd: GRANTED_MSG called\n");
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200393 return nlmsvc_callback(rqstp, NLMPROC_GRANTED_RES, __nlmsvc_proc_granted);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394}
395
396/*
397 * SHARE: create a DOS share or alter existing share.
398 */
Al Viro7111c662006-10-19 23:28:45 -0700399static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200400nlmsvc_proc_share(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200402 struct nlm_args *argp = rqstp->rq_argp;
403 struct nlm_res *resp = rqstp->rq_resp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 struct nlm_host *host;
405 struct nlm_file *file;
406
407 dprintk("lockd: SHARE called\n");
408
409 resp->cookie = argp->cookie;
410
411 /* Don't accept new lock requests during grace period */
Stanislav Kinsbursky5ccb0062012-07-25 16:57:22 +0400412 if (locks_in_grace(SVC_NET(rqstp)) && !argp->reclaim) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 resp->status = nlm_lck_denied_grace_period;
414 return rpc_success;
415 }
416
417 /* Obtain client and file */
418 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700419 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420
421 /* Now try to create the share */
422 resp->status = cast_status(nlmsvc_share_file(host, file, argp));
423
424 dprintk("lockd: SHARE status %d\n", ntohl(resp->status));
Benjamin Coddington89e0edf2019-05-23 10:45:45 -0400425 nlmsvc_release_lockowner(&argp->lock);
Chuck Lever67216b92010-12-14 15:06:12 +0000426 nlmsvc_release_host(host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 nlm_release_file(file);
428 return rpc_success;
429}
430
431/*
432 * UNSHARE: Release a DOS share.
433 */
Al Viro7111c662006-10-19 23:28:45 -0700434static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200435nlmsvc_proc_unshare(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200437 struct nlm_args *argp = rqstp->rq_argp;
438 struct nlm_res *resp = rqstp->rq_resp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 struct nlm_host *host;
440 struct nlm_file *file;
441
442 dprintk("lockd: UNSHARE called\n");
443
444 resp->cookie = argp->cookie;
445
446 /* Don't accept requests during grace period */
Stanislav Kinsbursky5ccb0062012-07-25 16:57:22 +0400447 if (locks_in_grace(SVC_NET(rqstp))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 resp->status = nlm_lck_denied_grace_period;
449 return rpc_success;
450 }
451
452 /* Obtain client and file */
453 if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
NeilBrownd343fce2006-10-17 00:10:18 -0700454 return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
456 /* Now try to unshare the file */
457 resp->status = cast_status(nlmsvc_unshare_file(host, file, argp));
458
459 dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status));
Benjamin Coddington89e0edf2019-05-23 10:45:45 -0400460 nlmsvc_release_lockowner(&argp->lock);
Chuck Lever67216b92010-12-14 15:06:12 +0000461 nlmsvc_release_host(host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 nlm_release_file(file);
463 return rpc_success;
464}
465
466/*
467 * NM_LOCK: Create an unmonitored lock
468 */
Al Viro7111c662006-10-19 23:28:45 -0700469static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200470nlmsvc_proc_nm_lock(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200472 struct nlm_args *argp = rqstp->rq_argp;
473
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 dprintk("lockd: NM_LOCK called\n");
475
476 argp->monitor = 0; /* just clean the monitor flag */
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200477 return nlmsvc_proc_lock(rqstp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}
479
480/*
481 * FREE_ALL: Release all locks and shares held by client
482 */
Al Viro7111c662006-10-19 23:28:45 -0700483static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200484nlmsvc_proc_free_all(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200486 struct nlm_args *argp = rqstp->rq_argp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 struct nlm_host *host;
488
489 /* Obtain client */
490 if (nlmsvc_retrieve_args(rqstp, argp, &host, NULL))
491 return rpc_success;
492
493 nlmsvc_free_host_resources(host);
Chuck Lever67216b92010-12-14 15:06:12 +0000494 nlmsvc_release_host(host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 return rpc_success;
496}
497
498/*
499 * SM_NOTIFY: private callback from statd (not part of official NLM proto)
500 */
Al Viro7111c662006-10-19 23:28:45 -0700501static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200502nlmsvc_proc_sm_notify(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200504 struct nlm_reboot *argp = rqstp->rq_argp;
505
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 dprintk("lockd: SM_NOTIFY called\n");
Chuck Leverb85e4672008-10-03 12:50:44 -0400507
508 if (!nlm_privileged_requester(rqstp)) {
Chuck Leverad06e4b2007-02-12 00:53:32 -0800509 char buf[RPC_MAX_ADDRBUFLEN];
510 printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
511 svc_print_addr(rqstp, buf, sizeof(buf)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 return rpc_system_err;
513 }
514
Andrey Ryabinin0ad95472015-09-23 15:49:29 +0300515 nlm_host_rebooted(SVC_NET(rqstp), argp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 return rpc_success;
517}
518
519/*
520 * client sent a GRANTED_RES, let's remove the associated block
521 */
Al Viro7111c662006-10-19 23:28:45 -0700522static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200523nlmsvc_proc_granted_res(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200525 struct nlm_res *argp = rqstp->rq_argp;
526
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 if (!nlmsvc_ops)
528 return rpc_success;
529
530 dprintk("lockd: GRANTED_RES called\n");
531
Olaf Kirch39be4502006-10-04 02:16:03 -0700532 nlmsvc_grant_reply(&argp->cookie, argp->status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 return rpc_success;
534}
535
Chuck Lever49d99602020-10-01 18:59:02 -0400536static __be32
537nlmsvc_proc_unused(struct svc_rqst *rqstp)
538{
539 return rpc_proc_unavail;
540}
541
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 * NLM Server procedures.
544 */
545
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546struct nlm_void { int dummy; };
547
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548#define Ck (1+XDR_QUADLEN(NLM_MAXCOOKIELEN)) /* cookie */
549#define St 1 /* status */
550#define No (1+1024/4) /* Net Obj */
551#define Rg 2 /* range - offset + size */
552
Chuck Lever49d99602020-10-01 18:59:02 -0400553const struct svc_procedure nlmsvc_procedures[24] = {
554 [NLMPROC_NULL] = {
555 .pc_func = nlmsvc_proc_null,
556 .pc_decode = nlmsvc_decode_void,
557 .pc_encode = nlmsvc_encode_void,
558 .pc_argsize = sizeof(struct nlm_void),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400559 .pc_argzero = sizeof(struct nlm_void),
Chuck Lever49d99602020-10-01 18:59:02 -0400560 .pc_ressize = sizeof(struct nlm_void),
561 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400562 .pc_name = "NULL",
Chuck Lever49d99602020-10-01 18:59:02 -0400563 },
564 [NLMPROC_TEST] = {
565 .pc_func = nlmsvc_proc_test,
566 .pc_decode = nlmsvc_decode_testargs,
567 .pc_encode = nlmsvc_encode_testres,
568 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400569 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400570 .pc_ressize = sizeof(struct nlm_res),
571 .pc_xdrressize = Ck+St+2+No+Rg,
Chuck Lever2289e872020-09-17 17:22:49 -0400572 .pc_name = "TEST",
Chuck Lever49d99602020-10-01 18:59:02 -0400573 },
574 [NLMPROC_LOCK] = {
575 .pc_func = nlmsvc_proc_lock,
576 .pc_decode = nlmsvc_decode_lockargs,
577 .pc_encode = nlmsvc_encode_res,
578 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400579 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400580 .pc_ressize = sizeof(struct nlm_res),
581 .pc_xdrressize = Ck+St,
Chuck Lever2289e872020-09-17 17:22:49 -0400582 .pc_name = "LOCK",
Chuck Lever49d99602020-10-01 18:59:02 -0400583 },
584 [NLMPROC_CANCEL] = {
585 .pc_func = nlmsvc_proc_cancel,
586 .pc_decode = nlmsvc_decode_cancargs,
587 .pc_encode = nlmsvc_encode_res,
588 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400589 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400590 .pc_ressize = sizeof(struct nlm_res),
591 .pc_xdrressize = Ck+St,
Chuck Lever2289e872020-09-17 17:22:49 -0400592 .pc_name = "CANCEL",
Chuck Lever49d99602020-10-01 18:59:02 -0400593 },
594 [NLMPROC_UNLOCK] = {
595 .pc_func = nlmsvc_proc_unlock,
596 .pc_decode = nlmsvc_decode_unlockargs,
597 .pc_encode = nlmsvc_encode_res,
598 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400599 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400600 .pc_ressize = sizeof(struct nlm_res),
601 .pc_xdrressize = Ck+St,
Chuck Lever2289e872020-09-17 17:22:49 -0400602 .pc_name = "UNLOCK",
Chuck Lever49d99602020-10-01 18:59:02 -0400603 },
604 [NLMPROC_GRANTED] = {
605 .pc_func = nlmsvc_proc_granted,
606 .pc_decode = nlmsvc_decode_testargs,
607 .pc_encode = nlmsvc_encode_res,
608 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400609 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400610 .pc_ressize = sizeof(struct nlm_res),
611 .pc_xdrressize = Ck+St,
Chuck Lever2289e872020-09-17 17:22:49 -0400612 .pc_name = "GRANTED",
Chuck Lever49d99602020-10-01 18:59:02 -0400613 },
614 [NLMPROC_TEST_MSG] = {
615 .pc_func = nlmsvc_proc_test_msg,
616 .pc_decode = nlmsvc_decode_testargs,
617 .pc_encode = nlmsvc_encode_void,
618 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400619 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400620 .pc_ressize = sizeof(struct nlm_void),
621 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400622 .pc_name = "TEST_MSG",
Chuck Lever49d99602020-10-01 18:59:02 -0400623 },
624 [NLMPROC_LOCK_MSG] = {
625 .pc_func = nlmsvc_proc_lock_msg,
626 .pc_decode = nlmsvc_decode_lockargs,
627 .pc_encode = nlmsvc_encode_void,
628 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400629 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400630 .pc_ressize = sizeof(struct nlm_void),
631 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400632 .pc_name = "LOCK_MSG",
Chuck Lever49d99602020-10-01 18:59:02 -0400633 },
634 [NLMPROC_CANCEL_MSG] = {
635 .pc_func = nlmsvc_proc_cancel_msg,
636 .pc_decode = nlmsvc_decode_cancargs,
637 .pc_encode = nlmsvc_encode_void,
638 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400639 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400640 .pc_ressize = sizeof(struct nlm_void),
641 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400642 .pc_name = "CANCEL_MSG",
Chuck Lever49d99602020-10-01 18:59:02 -0400643 },
644 [NLMPROC_UNLOCK_MSG] = {
645 .pc_func = nlmsvc_proc_unlock_msg,
646 .pc_decode = nlmsvc_decode_unlockargs,
647 .pc_encode = nlmsvc_encode_void,
648 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400649 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400650 .pc_ressize = sizeof(struct nlm_void),
651 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400652 .pc_name = "UNLOCK_MSG",
Chuck Lever49d99602020-10-01 18:59:02 -0400653 },
654 [NLMPROC_GRANTED_MSG] = {
655 .pc_func = nlmsvc_proc_granted_msg,
656 .pc_decode = nlmsvc_decode_testargs,
657 .pc_encode = nlmsvc_encode_void,
658 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400659 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400660 .pc_ressize = sizeof(struct nlm_void),
661 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400662 .pc_name = "GRANTED_MSG",
Chuck Lever49d99602020-10-01 18:59:02 -0400663 },
664 [NLMPROC_TEST_RES] = {
665 .pc_func = nlmsvc_proc_null,
666 .pc_decode = nlmsvc_decode_void,
667 .pc_encode = nlmsvc_encode_void,
668 .pc_argsize = sizeof(struct nlm_res),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400669 .pc_argzero = sizeof(struct nlm_res),
Chuck Lever49d99602020-10-01 18:59:02 -0400670 .pc_ressize = sizeof(struct nlm_void),
671 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400672 .pc_name = "TEST_RES",
Chuck Lever49d99602020-10-01 18:59:02 -0400673 },
674 [NLMPROC_LOCK_RES] = {
675 .pc_func = nlmsvc_proc_null,
676 .pc_decode = nlmsvc_decode_void,
677 .pc_encode = nlmsvc_encode_void,
678 .pc_argsize = sizeof(struct nlm_res),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400679 .pc_argzero = sizeof(struct nlm_res),
Chuck Lever49d99602020-10-01 18:59:02 -0400680 .pc_ressize = sizeof(struct nlm_void),
681 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400682 .pc_name = "LOCK_RES",
Chuck Lever49d99602020-10-01 18:59:02 -0400683 },
684 [NLMPROC_CANCEL_RES] = {
685 .pc_func = nlmsvc_proc_null,
686 .pc_decode = nlmsvc_decode_void,
687 .pc_encode = nlmsvc_encode_void,
688 .pc_argsize = sizeof(struct nlm_res),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400689 .pc_argzero = sizeof(struct nlm_res),
Chuck Lever49d99602020-10-01 18:59:02 -0400690 .pc_ressize = sizeof(struct nlm_void),
691 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400692 .pc_name = "CANCEL_RES",
Chuck Lever49d99602020-10-01 18:59:02 -0400693 },
694 [NLMPROC_UNLOCK_RES] = {
695 .pc_func = nlmsvc_proc_null,
696 .pc_decode = nlmsvc_decode_void,
697 .pc_encode = nlmsvc_encode_void,
698 .pc_argsize = sizeof(struct nlm_res),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400699 .pc_argzero = sizeof(struct nlm_res),
Chuck Lever49d99602020-10-01 18:59:02 -0400700 .pc_ressize = sizeof(struct nlm_void),
701 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400702 .pc_name = "UNLOCK_RES",
Chuck Lever49d99602020-10-01 18:59:02 -0400703 },
704 [NLMPROC_GRANTED_RES] = {
705 .pc_func = nlmsvc_proc_granted_res,
706 .pc_decode = nlmsvc_decode_res,
707 .pc_encode = nlmsvc_encode_void,
708 .pc_argsize = sizeof(struct nlm_res),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400709 .pc_argzero = sizeof(struct nlm_res),
Chuck Lever49d99602020-10-01 18:59:02 -0400710 .pc_ressize = sizeof(struct nlm_void),
711 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400712 .pc_name = "GRANTED_RES",
Chuck Lever49d99602020-10-01 18:59:02 -0400713 },
714 [NLMPROC_NSM_NOTIFY] = {
715 .pc_func = nlmsvc_proc_sm_notify,
716 .pc_decode = nlmsvc_decode_reboot,
717 .pc_encode = nlmsvc_encode_void,
718 .pc_argsize = sizeof(struct nlm_reboot),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400719 .pc_argzero = sizeof(struct nlm_reboot),
Chuck Lever49d99602020-10-01 18:59:02 -0400720 .pc_ressize = sizeof(struct nlm_void),
721 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400722 .pc_name = "SM_NOTIFY",
Chuck Lever49d99602020-10-01 18:59:02 -0400723 },
724 [17] = {
725 .pc_func = nlmsvc_proc_unused,
726 .pc_decode = nlmsvc_decode_void,
727 .pc_encode = nlmsvc_encode_void,
728 .pc_argsize = sizeof(struct nlm_void),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400729 .pc_argzero = sizeof(struct nlm_void),
Chuck Lever49d99602020-10-01 18:59:02 -0400730 .pc_ressize = sizeof(struct nlm_void),
731 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400732 .pc_name = "UNUSED",
Chuck Lever49d99602020-10-01 18:59:02 -0400733 },
734 [18] = {
735 .pc_func = nlmsvc_proc_unused,
736 .pc_decode = nlmsvc_decode_void,
737 .pc_encode = nlmsvc_encode_void,
738 .pc_argsize = sizeof(struct nlm_void),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400739 .pc_argzero = sizeof(struct nlm_void),
Chuck Lever49d99602020-10-01 18:59:02 -0400740 .pc_ressize = sizeof(struct nlm_void),
741 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400742 .pc_name = "UNUSED",
Chuck Lever49d99602020-10-01 18:59:02 -0400743 },
744 [19] = {
745 .pc_func = nlmsvc_proc_unused,
746 .pc_decode = nlmsvc_decode_void,
747 .pc_encode = nlmsvc_encode_void,
748 .pc_argsize = sizeof(struct nlm_void),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400749 .pc_argzero = sizeof(struct nlm_void),
Chuck Lever49d99602020-10-01 18:59:02 -0400750 .pc_ressize = sizeof(struct nlm_void),
751 .pc_xdrressize = St,
Chuck Lever2289e872020-09-17 17:22:49 -0400752 .pc_name = "UNUSED",
Chuck Lever49d99602020-10-01 18:59:02 -0400753 },
754 [NLMPROC_SHARE] = {
755 .pc_func = nlmsvc_proc_share,
756 .pc_decode = nlmsvc_decode_shareargs,
757 .pc_encode = nlmsvc_encode_shareres,
758 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400759 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400760 .pc_ressize = sizeof(struct nlm_res),
761 .pc_xdrressize = Ck+St+1,
Chuck Lever2289e872020-09-17 17:22:49 -0400762 .pc_name = "SHARE",
Chuck Lever49d99602020-10-01 18:59:02 -0400763 },
764 [NLMPROC_UNSHARE] = {
765 .pc_func = nlmsvc_proc_unshare,
766 .pc_decode = nlmsvc_decode_shareargs,
767 .pc_encode = nlmsvc_encode_shareres,
768 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400769 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400770 .pc_ressize = sizeof(struct nlm_res),
771 .pc_xdrressize = Ck+St+1,
Chuck Lever2289e872020-09-17 17:22:49 -0400772 .pc_name = "UNSHARE",
Chuck Lever49d99602020-10-01 18:59:02 -0400773 },
774 [NLMPROC_NM_LOCK] = {
775 .pc_func = nlmsvc_proc_nm_lock,
776 .pc_decode = nlmsvc_decode_lockargs,
777 .pc_encode = nlmsvc_encode_res,
778 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400779 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400780 .pc_ressize = sizeof(struct nlm_res),
781 .pc_xdrressize = Ck+St,
Chuck Lever2289e872020-09-17 17:22:49 -0400782 .pc_name = "NM_LOCK",
Chuck Lever49d99602020-10-01 18:59:02 -0400783 },
784 [NLMPROC_FREE_ALL] = {
785 .pc_func = nlmsvc_proc_free_all,
786 .pc_decode = nlmsvc_decode_notify,
787 .pc_encode = nlmsvc_encode_void,
788 .pc_argsize = sizeof(struct nlm_args),
Chuck Lever103cc1f2022-09-12 17:22:38 -0400789 .pc_argzero = sizeof(struct nlm_args),
Chuck Lever49d99602020-10-01 18:59:02 -0400790 .pc_ressize = sizeof(struct nlm_void),
791 .pc_xdrressize = 0,
Chuck Lever2289e872020-09-17 17:22:49 -0400792 .pc_name = "FREE_ALL",
Chuck Lever49d99602020-10-01 18:59:02 -0400793 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794};