xref: /openbmc/linux/fs/lockd/svc4proc.c (revision f5c27da4)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * linux/fs/lockd/svc4proc.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 
11 #include <linux/types.h>
12 #include <linux/time.h>
13 #include <linux/lockd/lockd.h>
14 #include <linux/lockd/share.h>
15 #include <linux/sunrpc/svc_xprt.h>
16 
17 #define NLMDBG_FACILITY		NLMDBG_CLIENT
18 
19 /*
20  * Obtain client and file from arguments
21  */
22 static __be32
23 nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
24 			struct nlm_host **hostp, struct nlm_file **filp)
25 {
26 	struct nlm_host		*host = NULL;
27 	struct nlm_file		*file = NULL;
28 	struct nlm_lock		*lock = &argp->lock;
29 	__be32			error = 0;
30 
31 	/* nfsd callbacks must have been installed for this procedure */
32 	if (!nlmsvc_ops)
33 		return nlm_lck_denied_nolocks;
34 
35 	if (lock->lock_start > OFFSET_MAX ||
36 	    (lock->lock_len && ((lock->lock_len - 1) > (OFFSET_MAX - lock->lock_start))))
37 		return nlm4_fbig;
38 
39 	/* Obtain host handle */
40 	if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
41 	 || (argp->monitor && nsm_monitor(host) < 0))
42 		goto no_locks;
43 	*hostp = host;
44 
45 	/* Obtain file pointer. Not used by FREE_ALL call. */
46 	if (filp != NULL) {
47 		int mode = lock_to_openmode(&lock->fl);
48 
49 		error = nlm_lookup_file(rqstp, &file, lock);
50 		if (error)
51 			goto no_locks;
52 		*filp = file;
53 
54 		/* Set up the missing parts of the file_lock structure */
55 		lock->fl.fl_file  = file->f_file[mode];
56 		lock->fl.fl_pid = current->tgid;
57 		lock->fl.fl_start = (loff_t)lock->lock_start;
58 		lock->fl.fl_end = lock->lock_len ?
59 				   (loff_t)(lock->lock_start + lock->lock_len - 1) :
60 				   OFFSET_MAX;
61 		lock->fl.fl_lmops = &nlmsvc_lock_operations;
62 		nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid);
63 		if (!lock->fl.fl_owner) {
64 			/* lockowner allocation has failed */
65 			nlmsvc_release_host(host);
66 			return nlm_lck_denied_nolocks;
67 		}
68 	}
69 
70 	return 0;
71 
72 no_locks:
73 	nlmsvc_release_host(host);
74  	if (error)
75 		return error;
76 	return nlm_lck_denied_nolocks;
77 }
78 
79 /*
80  * NULL: Test for presence of service
81  */
82 static __be32
83 nlm4svc_proc_null(struct svc_rqst *rqstp)
84 {
85 	dprintk("lockd: NULL          called\n");
86 	return rpc_success;
87 }
88 
89 /*
90  * TEST: Check for conflicting lock
91  */
92 static __be32
93 __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
94 {
95 	struct nlm_args *argp = rqstp->rq_argp;
96 	struct nlm_host	*host;
97 	struct nlm_file	*file;
98 	struct nlm_lockowner *test_owner;
99 	__be32 rc = rpc_success;
100 
101 	dprintk("lockd: TEST4        called\n");
102 	resp->cookie = argp->cookie;
103 
104 	/* Obtain client and file */
105 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
106 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
107 
108 	test_owner = argp->lock.fl.fl_owner;
109 	/* Now check for conflicting locks */
110 	resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie);
111 	if (resp->status == nlm_drop_reply)
112 		rc = rpc_drop_reply;
113 	else
114 		dprintk("lockd: TEST4        status %d\n", ntohl(resp->status));
115 
116 	nlmsvc_put_lockowner(test_owner);
117 	nlmsvc_release_host(host);
118 	nlm_release_file(file);
119 	return rc;
120 }
121 
122 static __be32
123 nlm4svc_proc_test(struct svc_rqst *rqstp)
124 {
125 	return __nlm4svc_proc_test(rqstp, rqstp->rq_resp);
126 }
127 
128 static __be32
129 __nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_res *resp)
130 {
131 	struct nlm_args *argp = rqstp->rq_argp;
132 	struct nlm_host	*host;
133 	struct nlm_file	*file;
134 	__be32 rc = rpc_success;
135 
136 	dprintk("lockd: LOCK          called\n");
137 
138 	resp->cookie = argp->cookie;
139 
140 	/* Obtain client and file */
141 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
142 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
143 
144 #if 0
145 	/* If supplied state doesn't match current state, we assume it's
146 	 * an old request that time-warped somehow. Any error return would
147 	 * do in this case because it's irrelevant anyway.
148 	 *
149 	 * NB: We don't retrieve the remote host's state yet.
150 	 */
151 	if (host->h_nsmstate && host->h_nsmstate != argp->state) {
152 		resp->status = nlm_lck_denied_nolocks;
153 	} else
154 #endif
155 
156 	/* Now try to lock the file */
157 	resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock,
158 					argp->block, &argp->cookie,
159 					argp->reclaim);
160 	if (resp->status == nlm_drop_reply)
161 		rc = rpc_drop_reply;
162 	else
163 		dprintk("lockd: LOCK         status %d\n", ntohl(resp->status));
164 
165 	nlmsvc_release_lockowner(&argp->lock);
166 	nlmsvc_release_host(host);
167 	nlm_release_file(file);
168 	return rc;
169 }
170 
171 static __be32
172 nlm4svc_proc_lock(struct svc_rqst *rqstp)
173 {
174 	return __nlm4svc_proc_lock(rqstp, rqstp->rq_resp);
175 }
176 
177 static __be32
178 __nlm4svc_proc_cancel(struct svc_rqst *rqstp, struct nlm_res *resp)
179 {
180 	struct nlm_args *argp = rqstp->rq_argp;
181 	struct nlm_host	*host;
182 	struct nlm_file	*file;
183 
184 	dprintk("lockd: CANCEL        called\n");
185 
186 	resp->cookie = argp->cookie;
187 
188 	/* Don't accept requests during grace period */
189 	if (locks_in_grace(SVC_NET(rqstp))) {
190 		resp->status = nlm_lck_denied_grace_period;
191 		return rpc_success;
192 	}
193 
194 	/* Obtain client and file */
195 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
196 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
197 
198 	/* Try to cancel request. */
199 	resp->status = nlmsvc_cancel_blocked(SVC_NET(rqstp), file, &argp->lock);
200 
201 	dprintk("lockd: CANCEL        status %d\n", ntohl(resp->status));
202 	nlmsvc_release_lockowner(&argp->lock);
203 	nlmsvc_release_host(host);
204 	nlm_release_file(file);
205 	return rpc_success;
206 }
207 
208 static __be32
209 nlm4svc_proc_cancel(struct svc_rqst *rqstp)
210 {
211 	return __nlm4svc_proc_cancel(rqstp, rqstp->rq_resp);
212 }
213 
214 /*
215  * UNLOCK: release a lock
216  */
217 static __be32
218 __nlm4svc_proc_unlock(struct svc_rqst *rqstp, struct nlm_res *resp)
219 {
220 	struct nlm_args *argp = rqstp->rq_argp;
221 	struct nlm_host	*host;
222 	struct nlm_file	*file;
223 
224 	dprintk("lockd: UNLOCK        called\n");
225 
226 	resp->cookie = argp->cookie;
227 
228 	/* Don't accept new lock requests during grace period */
229 	if (locks_in_grace(SVC_NET(rqstp))) {
230 		resp->status = nlm_lck_denied_grace_period;
231 		return rpc_success;
232 	}
233 
234 	/* Obtain client and file */
235 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
236 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
237 
238 	/* Now try to remove the lock */
239 	resp->status = nlmsvc_unlock(SVC_NET(rqstp), file, &argp->lock);
240 
241 	dprintk("lockd: UNLOCK        status %d\n", ntohl(resp->status));
242 	nlmsvc_release_lockowner(&argp->lock);
243 	nlmsvc_release_host(host);
244 	nlm_release_file(file);
245 	return rpc_success;
246 }
247 
248 static __be32
249 nlm4svc_proc_unlock(struct svc_rqst *rqstp)
250 {
251 	return __nlm4svc_proc_unlock(rqstp, rqstp->rq_resp);
252 }
253 
254 /*
255  * GRANTED: A server calls us to tell that a process' lock request
256  * was granted
257  */
258 static __be32
259 __nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_res *resp)
260 {
261 	struct nlm_args *argp = rqstp->rq_argp;
262 
263 	resp->cookie = argp->cookie;
264 
265 	dprintk("lockd: GRANTED       called\n");
266 	resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock);
267 	dprintk("lockd: GRANTED       status %d\n", ntohl(resp->status));
268 	return rpc_success;
269 }
270 
271 static __be32
272 nlm4svc_proc_granted(struct svc_rqst *rqstp)
273 {
274 	return __nlm4svc_proc_granted(rqstp, rqstp->rq_resp);
275 }
276 
277 /*
278  * This is the generic lockd callback for async RPC calls
279  */
280 static void nlm4svc_callback_exit(struct rpc_task *task, void *data)
281 {
282 }
283 
284 static void nlm4svc_callback_release(void *data)
285 {
286 	nlmsvc_release_call(data);
287 }
288 
289 static const struct rpc_call_ops nlm4svc_callback_ops = {
290 	.rpc_call_done = nlm4svc_callback_exit,
291 	.rpc_release = nlm4svc_callback_release,
292 };
293 
294 /*
295  * `Async' versions of the above service routines. They aren't really,
296  * because we send the callback before the reply proper. I hope this
297  * doesn't break any clients.
298  */
299 static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc,
300 		__be32 (*func)(struct svc_rqst *,  struct nlm_res *))
301 {
302 	struct nlm_args *argp = rqstp->rq_argp;
303 	struct nlm_host	*host;
304 	struct nlm_rqst	*call;
305 	__be32 stat;
306 
307 	host = nlmsvc_lookup_host(rqstp,
308 				  argp->lock.caller,
309 				  argp->lock.len);
310 	if (host == NULL)
311 		return rpc_system_err;
312 
313 	call = nlm_alloc_call(host);
314 	nlmsvc_release_host(host);
315 	if (call == NULL)
316 		return rpc_system_err;
317 
318 	stat = func(rqstp, &call->a_res);
319 	if (stat != 0) {
320 		nlmsvc_release_call(call);
321 		return stat;
322 	}
323 
324 	call->a_flags = RPC_TASK_ASYNC;
325 	if (nlm_async_reply(call, proc, &nlm4svc_callback_ops) < 0)
326 		return rpc_system_err;
327 	return rpc_success;
328 }
329 
330 static __be32 nlm4svc_proc_test_msg(struct svc_rqst *rqstp)
331 {
332 	dprintk("lockd: TEST_MSG      called\n");
333 	return nlm4svc_callback(rqstp, NLMPROC_TEST_RES, __nlm4svc_proc_test);
334 }
335 
336 static __be32 nlm4svc_proc_lock_msg(struct svc_rqst *rqstp)
337 {
338 	dprintk("lockd: LOCK_MSG      called\n");
339 	return nlm4svc_callback(rqstp, NLMPROC_LOCK_RES, __nlm4svc_proc_lock);
340 }
341 
342 static __be32 nlm4svc_proc_cancel_msg(struct svc_rqst *rqstp)
343 {
344 	dprintk("lockd: CANCEL_MSG    called\n");
345 	return nlm4svc_callback(rqstp, NLMPROC_CANCEL_RES, __nlm4svc_proc_cancel);
346 }
347 
348 static __be32 nlm4svc_proc_unlock_msg(struct svc_rqst *rqstp)
349 {
350 	dprintk("lockd: UNLOCK_MSG    called\n");
351 	return nlm4svc_callback(rqstp, NLMPROC_UNLOCK_RES, __nlm4svc_proc_unlock);
352 }
353 
354 static __be32 nlm4svc_proc_granted_msg(struct svc_rqst *rqstp)
355 {
356 	dprintk("lockd: GRANTED_MSG   called\n");
357 	return nlm4svc_callback(rqstp, NLMPROC_GRANTED_RES, __nlm4svc_proc_granted);
358 }
359 
360 /*
361  * SHARE: create a DOS share or alter existing share.
362  */
363 static __be32
364 nlm4svc_proc_share(struct svc_rqst *rqstp)
365 {
366 	struct nlm_args *argp = rqstp->rq_argp;
367 	struct nlm_res *resp = rqstp->rq_resp;
368 	struct nlm_host	*host;
369 	struct nlm_file	*file;
370 
371 	dprintk("lockd: SHARE         called\n");
372 
373 	resp->cookie = argp->cookie;
374 
375 	/* Don't accept new lock requests during grace period */
376 	if (locks_in_grace(SVC_NET(rqstp)) && !argp->reclaim) {
377 		resp->status = nlm_lck_denied_grace_period;
378 		return rpc_success;
379 	}
380 
381 	/* Obtain client and file */
382 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
383 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
384 
385 	/* Now try to create the share */
386 	resp->status = nlmsvc_share_file(host, file, argp);
387 
388 	dprintk("lockd: SHARE         status %d\n", ntohl(resp->status));
389 	nlmsvc_release_lockowner(&argp->lock);
390 	nlmsvc_release_host(host);
391 	nlm_release_file(file);
392 	return rpc_success;
393 }
394 
395 /*
396  * UNSHARE: Release a DOS share.
397  */
398 static __be32
399 nlm4svc_proc_unshare(struct svc_rqst *rqstp)
400 {
401 	struct nlm_args *argp = rqstp->rq_argp;
402 	struct nlm_res *resp = rqstp->rq_resp;
403 	struct nlm_host	*host;
404 	struct nlm_file	*file;
405 
406 	dprintk("lockd: UNSHARE       called\n");
407 
408 	resp->cookie = argp->cookie;
409 
410 	/* Don't accept requests during grace period */
411 	if (locks_in_grace(SVC_NET(rqstp))) {
412 		resp->status = nlm_lck_denied_grace_period;
413 		return rpc_success;
414 	}
415 
416 	/* Obtain client and file */
417 	if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
418 		return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
419 
420 	/* Now try to lock the file */
421 	resp->status = nlmsvc_unshare_file(host, file, argp);
422 
423 	dprintk("lockd: UNSHARE       status %d\n", ntohl(resp->status));
424 	nlmsvc_release_lockowner(&argp->lock);
425 	nlmsvc_release_host(host);
426 	nlm_release_file(file);
427 	return rpc_success;
428 }
429 
430 /*
431  * NM_LOCK: Create an unmonitored lock
432  */
433 static __be32
434 nlm4svc_proc_nm_lock(struct svc_rqst *rqstp)
435 {
436 	struct nlm_args *argp = rqstp->rq_argp;
437 
438 	dprintk("lockd: NM_LOCK       called\n");
439 
440 	argp->monitor = 0;		/* just clean the monitor flag */
441 	return nlm4svc_proc_lock(rqstp);
442 }
443 
444 /*
445  * FREE_ALL: Release all locks and shares held by client
446  */
447 static __be32
448 nlm4svc_proc_free_all(struct svc_rqst *rqstp)
449 {
450 	struct nlm_args *argp = rqstp->rq_argp;
451 	struct nlm_host	*host;
452 
453 	/* Obtain client */
454 	if (nlm4svc_retrieve_args(rqstp, argp, &host, NULL))
455 		return rpc_success;
456 
457 	nlmsvc_free_host_resources(host);
458 	nlmsvc_release_host(host);
459 	return rpc_success;
460 }
461 
462 /*
463  * SM_NOTIFY: private callback from statd (not part of official NLM proto)
464  */
465 static __be32
466 nlm4svc_proc_sm_notify(struct svc_rqst *rqstp)
467 {
468 	struct nlm_reboot *argp = rqstp->rq_argp;
469 
470 	dprintk("lockd: SM_NOTIFY     called\n");
471 
472 	if (!nlm_privileged_requester(rqstp)) {
473 		char buf[RPC_MAX_ADDRBUFLEN];
474 		printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
475 				svc_print_addr(rqstp, buf, sizeof(buf)));
476 		return rpc_system_err;
477 	}
478 
479 	nlm_host_rebooted(SVC_NET(rqstp), argp);
480 	return rpc_success;
481 }
482 
483 /*
484  * client sent a GRANTED_RES, let's remove the associated block
485  */
486 static __be32
487 nlm4svc_proc_granted_res(struct svc_rqst *rqstp)
488 {
489 	struct nlm_res *argp = rqstp->rq_argp;
490 
491         if (!nlmsvc_ops)
492                 return rpc_success;
493 
494         dprintk("lockd: GRANTED_RES   called\n");
495 
496         nlmsvc_grant_reply(&argp->cookie, argp->status);
497         return rpc_success;
498 }
499 
500 static __be32
501 nlm4svc_proc_unused(struct svc_rqst *rqstp)
502 {
503 	return rpc_proc_unavail;
504 }
505 
506 
507 /*
508  * NLM Server procedures.
509  */
510 
511 struct nlm_void			{ int dummy; };
512 
513 #define	Ck	(1+XDR_QUADLEN(NLM_MAXCOOKIELEN))	/* cookie */
514 #define	No	(1+1024/4)				/* netobj */
515 #define	St	1					/* status */
516 #define	Rg	4					/* range (offset + length) */
517 
518 const struct svc_procedure nlmsvc_procedures4[24] = {
519 	[NLMPROC_NULL] = {
520 		.pc_func = nlm4svc_proc_null,
521 		.pc_decode = nlm4svc_decode_void,
522 		.pc_encode = nlm4svc_encode_void,
523 		.pc_argsize = sizeof(struct nlm_void),
524 		.pc_argzero = sizeof(struct nlm_void),
525 		.pc_ressize = sizeof(struct nlm_void),
526 		.pc_xdrressize = St,
527 		.pc_name = "NULL",
528 	},
529 	[NLMPROC_TEST] = {
530 		.pc_func = nlm4svc_proc_test,
531 		.pc_decode = nlm4svc_decode_testargs,
532 		.pc_encode = nlm4svc_encode_testres,
533 		.pc_argsize = sizeof(struct nlm_args),
534 		.pc_argzero = sizeof(struct nlm_args),
535 		.pc_ressize = sizeof(struct nlm_res),
536 		.pc_xdrressize = Ck+St+2+No+Rg,
537 		.pc_name = "TEST",
538 	},
539 	[NLMPROC_LOCK] = {
540 		.pc_func = nlm4svc_proc_lock,
541 		.pc_decode = nlm4svc_decode_lockargs,
542 		.pc_encode = nlm4svc_encode_res,
543 		.pc_argsize = sizeof(struct nlm_args),
544 		.pc_argzero = sizeof(struct nlm_args),
545 		.pc_ressize = sizeof(struct nlm_res),
546 		.pc_xdrressize = Ck+St,
547 		.pc_name = "LOCK",
548 	},
549 	[NLMPROC_CANCEL] = {
550 		.pc_func = nlm4svc_proc_cancel,
551 		.pc_decode = nlm4svc_decode_cancargs,
552 		.pc_encode = nlm4svc_encode_res,
553 		.pc_argsize = sizeof(struct nlm_args),
554 		.pc_argzero = sizeof(struct nlm_args),
555 		.pc_ressize = sizeof(struct nlm_res),
556 		.pc_xdrressize = Ck+St,
557 		.pc_name = "CANCEL",
558 	},
559 	[NLMPROC_UNLOCK] = {
560 		.pc_func = nlm4svc_proc_unlock,
561 		.pc_decode = nlm4svc_decode_unlockargs,
562 		.pc_encode = nlm4svc_encode_res,
563 		.pc_argsize = sizeof(struct nlm_args),
564 		.pc_argzero = sizeof(struct nlm_args),
565 		.pc_ressize = sizeof(struct nlm_res),
566 		.pc_xdrressize = Ck+St,
567 		.pc_name = "UNLOCK",
568 	},
569 	[NLMPROC_GRANTED] = {
570 		.pc_func = nlm4svc_proc_granted,
571 		.pc_decode = nlm4svc_decode_testargs,
572 		.pc_encode = nlm4svc_encode_res,
573 		.pc_argsize = sizeof(struct nlm_args),
574 		.pc_argzero = sizeof(struct nlm_args),
575 		.pc_ressize = sizeof(struct nlm_res),
576 		.pc_xdrressize = Ck+St,
577 		.pc_name = "GRANTED",
578 	},
579 	[NLMPROC_TEST_MSG] = {
580 		.pc_func = nlm4svc_proc_test_msg,
581 		.pc_decode = nlm4svc_decode_testargs,
582 		.pc_encode = nlm4svc_encode_void,
583 		.pc_argsize = sizeof(struct nlm_args),
584 		.pc_argzero = sizeof(struct nlm_args),
585 		.pc_ressize = sizeof(struct nlm_void),
586 		.pc_xdrressize = St,
587 		.pc_name = "TEST_MSG",
588 	},
589 	[NLMPROC_LOCK_MSG] = {
590 		.pc_func = nlm4svc_proc_lock_msg,
591 		.pc_decode = nlm4svc_decode_lockargs,
592 		.pc_encode = nlm4svc_encode_void,
593 		.pc_argsize = sizeof(struct nlm_args),
594 		.pc_argzero = sizeof(struct nlm_args),
595 		.pc_ressize = sizeof(struct nlm_void),
596 		.pc_xdrressize = St,
597 		.pc_name = "LOCK_MSG",
598 	},
599 	[NLMPROC_CANCEL_MSG] = {
600 		.pc_func = nlm4svc_proc_cancel_msg,
601 		.pc_decode = nlm4svc_decode_cancargs,
602 		.pc_encode = nlm4svc_encode_void,
603 		.pc_argsize = sizeof(struct nlm_args),
604 		.pc_argzero = sizeof(struct nlm_args),
605 		.pc_ressize = sizeof(struct nlm_void),
606 		.pc_xdrressize = St,
607 		.pc_name = "CANCEL_MSG",
608 	},
609 	[NLMPROC_UNLOCK_MSG] = {
610 		.pc_func = nlm4svc_proc_unlock_msg,
611 		.pc_decode = nlm4svc_decode_unlockargs,
612 		.pc_encode = nlm4svc_encode_void,
613 		.pc_argsize = sizeof(struct nlm_args),
614 		.pc_argzero = sizeof(struct nlm_args),
615 		.pc_ressize = sizeof(struct nlm_void),
616 		.pc_xdrressize = St,
617 		.pc_name = "UNLOCK_MSG",
618 	},
619 	[NLMPROC_GRANTED_MSG] = {
620 		.pc_func = nlm4svc_proc_granted_msg,
621 		.pc_decode = nlm4svc_decode_testargs,
622 		.pc_encode = nlm4svc_encode_void,
623 		.pc_argsize = sizeof(struct nlm_args),
624 		.pc_argzero = sizeof(struct nlm_args),
625 		.pc_ressize = sizeof(struct nlm_void),
626 		.pc_xdrressize = St,
627 		.pc_name = "GRANTED_MSG",
628 	},
629 	[NLMPROC_TEST_RES] = {
630 		.pc_func = nlm4svc_proc_null,
631 		.pc_decode = nlm4svc_decode_void,
632 		.pc_encode = nlm4svc_encode_void,
633 		.pc_argsize = sizeof(struct nlm_res),
634 		.pc_argzero = sizeof(struct nlm_res),
635 		.pc_ressize = sizeof(struct nlm_void),
636 		.pc_xdrressize = St,
637 		.pc_name = "TEST_RES",
638 	},
639 	[NLMPROC_LOCK_RES] = {
640 		.pc_func = nlm4svc_proc_null,
641 		.pc_decode = nlm4svc_decode_void,
642 		.pc_encode = nlm4svc_encode_void,
643 		.pc_argsize = sizeof(struct nlm_res),
644 		.pc_argzero = sizeof(struct nlm_res),
645 		.pc_ressize = sizeof(struct nlm_void),
646 		.pc_xdrressize = St,
647 		.pc_name = "LOCK_RES",
648 	},
649 	[NLMPROC_CANCEL_RES] = {
650 		.pc_func = nlm4svc_proc_null,
651 		.pc_decode = nlm4svc_decode_void,
652 		.pc_encode = nlm4svc_encode_void,
653 		.pc_argsize = sizeof(struct nlm_res),
654 		.pc_argzero = sizeof(struct nlm_res),
655 		.pc_ressize = sizeof(struct nlm_void),
656 		.pc_xdrressize = St,
657 		.pc_name = "CANCEL_RES",
658 	},
659 	[NLMPROC_UNLOCK_RES] = {
660 		.pc_func = nlm4svc_proc_null,
661 		.pc_decode = nlm4svc_decode_void,
662 		.pc_encode = nlm4svc_encode_void,
663 		.pc_argsize = sizeof(struct nlm_res),
664 		.pc_argzero = sizeof(struct nlm_res),
665 		.pc_ressize = sizeof(struct nlm_void),
666 		.pc_xdrressize = St,
667 		.pc_name = "UNLOCK_RES",
668 	},
669 	[NLMPROC_GRANTED_RES] = {
670 		.pc_func = nlm4svc_proc_granted_res,
671 		.pc_decode = nlm4svc_decode_res,
672 		.pc_encode = nlm4svc_encode_void,
673 		.pc_argsize = sizeof(struct nlm_res),
674 		.pc_argzero = sizeof(struct nlm_res),
675 		.pc_ressize = sizeof(struct nlm_void),
676 		.pc_xdrressize = St,
677 		.pc_name = "GRANTED_RES",
678 	},
679 	[NLMPROC_NSM_NOTIFY] = {
680 		.pc_func = nlm4svc_proc_sm_notify,
681 		.pc_decode = nlm4svc_decode_reboot,
682 		.pc_encode = nlm4svc_encode_void,
683 		.pc_argsize = sizeof(struct nlm_reboot),
684 		.pc_argzero = sizeof(struct nlm_reboot),
685 		.pc_ressize = sizeof(struct nlm_void),
686 		.pc_xdrressize = St,
687 		.pc_name = "SM_NOTIFY",
688 	},
689 	[17] = {
690 		.pc_func = nlm4svc_proc_unused,
691 		.pc_decode = nlm4svc_decode_void,
692 		.pc_encode = nlm4svc_encode_void,
693 		.pc_argsize = sizeof(struct nlm_void),
694 		.pc_argzero = sizeof(struct nlm_void),
695 		.pc_ressize = sizeof(struct nlm_void),
696 		.pc_xdrressize = 0,
697 		.pc_name = "UNUSED",
698 	},
699 	[18] = {
700 		.pc_func = nlm4svc_proc_unused,
701 		.pc_decode = nlm4svc_decode_void,
702 		.pc_encode = nlm4svc_encode_void,
703 		.pc_argsize = sizeof(struct nlm_void),
704 		.pc_argzero = sizeof(struct nlm_void),
705 		.pc_ressize = sizeof(struct nlm_void),
706 		.pc_xdrressize = 0,
707 		.pc_name = "UNUSED",
708 	},
709 	[19] = {
710 		.pc_func = nlm4svc_proc_unused,
711 		.pc_decode = nlm4svc_decode_void,
712 		.pc_encode = nlm4svc_encode_void,
713 		.pc_argsize = sizeof(struct nlm_void),
714 		.pc_argzero = sizeof(struct nlm_void),
715 		.pc_ressize = sizeof(struct nlm_void),
716 		.pc_xdrressize = 0,
717 		.pc_name = "UNUSED",
718 	},
719 	[NLMPROC_SHARE] = {
720 		.pc_func = nlm4svc_proc_share,
721 		.pc_decode = nlm4svc_decode_shareargs,
722 		.pc_encode = nlm4svc_encode_shareres,
723 		.pc_argsize = sizeof(struct nlm_args),
724 		.pc_argzero = sizeof(struct nlm_args),
725 		.pc_ressize = sizeof(struct nlm_res),
726 		.pc_xdrressize = Ck+St+1,
727 		.pc_name = "SHARE",
728 	},
729 	[NLMPROC_UNSHARE] = {
730 		.pc_func = nlm4svc_proc_unshare,
731 		.pc_decode = nlm4svc_decode_shareargs,
732 		.pc_encode = nlm4svc_encode_shareres,
733 		.pc_argsize = sizeof(struct nlm_args),
734 		.pc_argzero = sizeof(struct nlm_args),
735 		.pc_ressize = sizeof(struct nlm_res),
736 		.pc_xdrressize = Ck+St+1,
737 		.pc_name = "UNSHARE",
738 	},
739 	[NLMPROC_NM_LOCK] = {
740 		.pc_func = nlm4svc_proc_nm_lock,
741 		.pc_decode = nlm4svc_decode_lockargs,
742 		.pc_encode = nlm4svc_encode_res,
743 		.pc_argsize = sizeof(struct nlm_args),
744 		.pc_argzero = sizeof(struct nlm_args),
745 		.pc_ressize = sizeof(struct nlm_res),
746 		.pc_xdrressize = Ck+St,
747 		.pc_name = "NM_LOCK",
748 	},
749 	[NLMPROC_FREE_ALL] = {
750 		.pc_func = nlm4svc_proc_free_all,
751 		.pc_decode = nlm4svc_decode_notify,
752 		.pc_encode = nlm4svc_encode_void,
753 		.pc_argsize = sizeof(struct nlm_args),
754 		.pc_argzero = sizeof(struct nlm_args),
755 		.pc_ressize = sizeof(struct nlm_void),
756 		.pc_xdrressize = St,
757 		.pc_name = "FREE_ALL",
758 	},
759 };
760