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