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