xref: /titanic_51/usr/src/uts/common/klm/nlm_rpc_svc.c (revision bbaa8b60dd95d714741fc474adad3cf710ef4efd)
1*bbaa8b60SDan Kruchinin /*
2*bbaa8b60SDan Kruchinin  * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
3*bbaa8b60SDan Kruchinin  * Authors: Doug Rabson <dfr@rabson.org>
4*bbaa8b60SDan Kruchinin  * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
5*bbaa8b60SDan Kruchinin  *
6*bbaa8b60SDan Kruchinin  * Redistribution and use in source and binary forms, with or without
7*bbaa8b60SDan Kruchinin  * modification, are permitted provided that the following conditions
8*bbaa8b60SDan Kruchinin  * are met:
9*bbaa8b60SDan Kruchinin  * 1. Redistributions of source code must retain the above copyright
10*bbaa8b60SDan Kruchinin  *    notice, this list of conditions and the following disclaimer.
11*bbaa8b60SDan Kruchinin  * 2. Redistributions in binary form must reproduce the above copyright
12*bbaa8b60SDan Kruchinin  *    notice, this list of conditions and the following disclaimer in the
13*bbaa8b60SDan Kruchinin  *    documentation and/or other materials provided with the distribution.
14*bbaa8b60SDan Kruchinin  *
15*bbaa8b60SDan Kruchinin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16*bbaa8b60SDan Kruchinin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17*bbaa8b60SDan Kruchinin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18*bbaa8b60SDan Kruchinin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19*bbaa8b60SDan Kruchinin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20*bbaa8b60SDan Kruchinin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21*bbaa8b60SDan Kruchinin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*bbaa8b60SDan Kruchinin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23*bbaa8b60SDan Kruchinin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24*bbaa8b60SDan Kruchinin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25*bbaa8b60SDan Kruchinin  * SUCH DAMAGE.
26*bbaa8b60SDan Kruchinin  */
27*bbaa8b60SDan Kruchinin 
28*bbaa8b60SDan Kruchinin /*
29*bbaa8b60SDan Kruchinin  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
30*bbaa8b60SDan Kruchinin  * Copyright (c) 2012 by Delphix. All rights reserved.
31*bbaa8b60SDan Kruchinin  */
32*bbaa8b60SDan Kruchinin 
33*bbaa8b60SDan Kruchinin /*
34*bbaa8b60SDan Kruchinin  * NFS Lock Manager, RPC service functions (nlm_..._svc)
35*bbaa8b60SDan Kruchinin  * Called via nlm_dispatch.c tables.
36*bbaa8b60SDan Kruchinin  *
37*bbaa8b60SDan Kruchinin  * Source code derived from FreeBSD nlm_prot_server.c
38*bbaa8b60SDan Kruchinin  *
39*bbaa8b60SDan Kruchinin  * The real service functions all use nlm4_... args and return
40*bbaa8b60SDan Kruchinin  * data types.  These wrappers convert older forms to and from
41*bbaa8b60SDan Kruchinin  * the new forms and call the nlm_do_... service functions.
42*bbaa8b60SDan Kruchinin  */
43*bbaa8b60SDan Kruchinin 
44*bbaa8b60SDan Kruchinin #include <sys/param.h>
45*bbaa8b60SDan Kruchinin #include <sys/systm.h>
46*bbaa8b60SDan Kruchinin 
47*bbaa8b60SDan Kruchinin #include <rpcsvc/nlm_prot.h>
48*bbaa8b60SDan Kruchinin #include "nlm_impl.h"
49*bbaa8b60SDan Kruchinin 
50*bbaa8b60SDan Kruchinin /*
51*bbaa8b60SDan Kruchinin  * Convert between various versions of the protocol structures.
52*bbaa8b60SDan Kruchinin  */
53*bbaa8b60SDan Kruchinin 
54*bbaa8b60SDan Kruchinin /*
55*bbaa8b60SDan Kruchinin  * Down-convert, for granted_1 call
56*bbaa8b60SDan Kruchinin  *
57*bbaa8b60SDan Kruchinin  * This converts a 64-bit lock to 32-bit form for our granted
58*bbaa8b60SDan Kruchinin  * call-back when we're dealing with a 32-bit NLM client.
59*bbaa8b60SDan Kruchinin  * Our NLM_LOCK handler ensures that any lock we grant to a
60*bbaa8b60SDan Kruchinin  * 32-bit client can be represented in 32-bits.  If the
61*bbaa8b60SDan Kruchinin  * ASSERTs here fire, then the call to nlm_init_flock in
62*bbaa8b60SDan Kruchinin  * nlm_do_lock has failed to restrict a 32-bit client to
63*bbaa8b60SDan Kruchinin  * 32-bit lock ranges.
64*bbaa8b60SDan Kruchinin  */
65*bbaa8b60SDan Kruchinin static void
66*bbaa8b60SDan Kruchinin nlm_convert_to_nlm_lock(struct nlm_lock *dst, struct nlm4_lock *src)
67*bbaa8b60SDan Kruchinin {
68*bbaa8b60SDan Kruchinin 	dst->caller_name = src->caller_name;
69*bbaa8b60SDan Kruchinin 	dst->fh = src->fh;
70*bbaa8b60SDan Kruchinin 	dst->oh = src->oh;
71*bbaa8b60SDan Kruchinin 	dst->svid = src->svid;
72*bbaa8b60SDan Kruchinin 	ASSERT(src->l_offset <= MAX_UOFF32);
73*bbaa8b60SDan Kruchinin 	dst->l_offset = (uint32_t)src->l_offset;
74*bbaa8b60SDan Kruchinin 	ASSERT(src->l_len <= MAX_UOFF32);
75*bbaa8b60SDan Kruchinin 	dst->l_len = (uint32_t)src->l_len;
76*bbaa8b60SDan Kruchinin }
77*bbaa8b60SDan Kruchinin 
78*bbaa8b60SDan Kruchinin /*
79*bbaa8b60SDan Kruchinin  * Up-convert for v1 svc functions with a 32-bit lock range arg.
80*bbaa8b60SDan Kruchinin  * Note that lock range checks (like overflow) are done later,
81*bbaa8b60SDan Kruchinin  * in nlm_init_flock().
82*bbaa8b60SDan Kruchinin  */
83*bbaa8b60SDan Kruchinin static void
84*bbaa8b60SDan Kruchinin nlm_convert_to_nlm4_lock(struct nlm4_lock *dst, struct nlm_lock *src)
85*bbaa8b60SDan Kruchinin {
86*bbaa8b60SDan Kruchinin 
87*bbaa8b60SDan Kruchinin 	dst->caller_name = src->caller_name;
88*bbaa8b60SDan Kruchinin 	dst->fh = src->fh;
89*bbaa8b60SDan Kruchinin 	dst->oh = src->oh;
90*bbaa8b60SDan Kruchinin 	dst->svid = src->svid;
91*bbaa8b60SDan Kruchinin 	dst->l_offset = src->l_offset;
92*bbaa8b60SDan Kruchinin 	dst->l_len = src->l_len;
93*bbaa8b60SDan Kruchinin }
94*bbaa8b60SDan Kruchinin 
95*bbaa8b60SDan Kruchinin static void
96*bbaa8b60SDan Kruchinin nlm_convert_to_nlm4_share(struct nlm4_share *dst, struct nlm_share *src)
97*bbaa8b60SDan Kruchinin {
98*bbaa8b60SDan Kruchinin 
99*bbaa8b60SDan Kruchinin 	dst->caller_name = src->caller_name;
100*bbaa8b60SDan Kruchinin 	dst->fh = src->fh;
101*bbaa8b60SDan Kruchinin 	dst->oh = src->oh;
102*bbaa8b60SDan Kruchinin 	dst->mode = src->mode;
103*bbaa8b60SDan Kruchinin 	dst->access = src->access;
104*bbaa8b60SDan Kruchinin }
105*bbaa8b60SDan Kruchinin 
106*bbaa8b60SDan Kruchinin /*
107*bbaa8b60SDan Kruchinin  * Down-convert for v1 NLM_TEST or NLM_TEST_MSG response.
108*bbaa8b60SDan Kruchinin  * Note that nlm_do_test is careful to give us lock ranges
109*bbaa8b60SDan Kruchinin  * that can be represented with 32-bit values.  If the
110*bbaa8b60SDan Kruchinin  * ASSERTs here fire, then the code in nlm_do_test that
111*bbaa8b60SDan Kruchinin  * builds an nlm4_holder for a 32-bit client has failed to
112*bbaa8b60SDan Kruchinin  * restrict the reported conflicting lock range so it's a
113*bbaa8b60SDan Kruchinin  * valid 32-bit lock range.
114*bbaa8b60SDan Kruchinin  */
115*bbaa8b60SDan Kruchinin static void
116*bbaa8b60SDan Kruchinin nlm_convert_to_nlm_holder(struct nlm_holder *dst, struct nlm4_holder *src)
117*bbaa8b60SDan Kruchinin {
118*bbaa8b60SDan Kruchinin 	dst->exclusive = src->exclusive;
119*bbaa8b60SDan Kruchinin 	dst->svid = src->svid;
120*bbaa8b60SDan Kruchinin 	dst->oh = src->oh;
121*bbaa8b60SDan Kruchinin 	ASSERT(src->l_offset <= MAX_UOFF32);
122*bbaa8b60SDan Kruchinin 	dst->l_offset = (uint32_t)src->l_offset;
123*bbaa8b60SDan Kruchinin 	ASSERT(src->l_len <= MAX_UOFF32);
124*bbaa8b60SDan Kruchinin 	dst->l_len = (uint32_t)src->l_len;
125*bbaa8b60SDan Kruchinin }
126*bbaa8b60SDan Kruchinin 
127*bbaa8b60SDan Kruchinin static enum nlm_stats
128*bbaa8b60SDan Kruchinin nlm_convert_to_nlm_stats(enum nlm4_stats src)
129*bbaa8b60SDan Kruchinin {
130*bbaa8b60SDan Kruchinin 	if (src > nlm4_deadlck)
131*bbaa8b60SDan Kruchinin 		return (nlm_denied);
132*bbaa8b60SDan Kruchinin 	return ((enum nlm_stats)src);
133*bbaa8b60SDan Kruchinin }
134*bbaa8b60SDan Kruchinin 
135*bbaa8b60SDan Kruchinin static void
136*bbaa8b60SDan Kruchinin nlm_convert_to_nlm_res(struct nlm_res *dst, struct nlm4_res *src)
137*bbaa8b60SDan Kruchinin {
138*bbaa8b60SDan Kruchinin 	dst->cookie = src->cookie;
139*bbaa8b60SDan Kruchinin 	dst->stat.stat = nlm_convert_to_nlm_stats(src->stat.stat);
140*bbaa8b60SDan Kruchinin }
141*bbaa8b60SDan Kruchinin 
142*bbaa8b60SDan Kruchinin /* ******************************************************************** */
143*bbaa8b60SDan Kruchinin 
144*bbaa8b60SDan Kruchinin /*
145*bbaa8b60SDan Kruchinin  * Version 1 svc functions
146*bbaa8b60SDan Kruchinin  */
147*bbaa8b60SDan Kruchinin 
148*bbaa8b60SDan Kruchinin bool_t
149*bbaa8b60SDan Kruchinin nlm_test_1_svc(struct nlm_testargs *argp, nlm_testres *resp,
150*bbaa8b60SDan Kruchinin     struct svc_req *sr)
151*bbaa8b60SDan Kruchinin {
152*bbaa8b60SDan Kruchinin 	nlm4_testargs args4;
153*bbaa8b60SDan Kruchinin 	nlm4_testres res4;
154*bbaa8b60SDan Kruchinin 
155*bbaa8b60SDan Kruchinin 	bzero(&args4, sizeof (args4));
156*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
157*bbaa8b60SDan Kruchinin 
158*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
159*bbaa8b60SDan Kruchinin 	args4.exclusive = argp->exclusive;
160*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
161*bbaa8b60SDan Kruchinin 
162*bbaa8b60SDan Kruchinin 	nlm_do_test(&args4, &res4, sr, NULL);
163*bbaa8b60SDan Kruchinin 
164*bbaa8b60SDan Kruchinin 	resp->cookie = res4.cookie;
165*bbaa8b60SDan Kruchinin 	resp->stat.stat = nlm_convert_to_nlm_stats(res4.stat.stat);
166*bbaa8b60SDan Kruchinin 	if (resp->stat.stat == nlm_denied)
167*bbaa8b60SDan Kruchinin 		nlm_convert_to_nlm_holder(
168*bbaa8b60SDan Kruchinin 		    &resp->stat.nlm_testrply_u.holder,
169*bbaa8b60SDan Kruchinin 		    &res4.stat.nlm4_testrply_u.holder);
170*bbaa8b60SDan Kruchinin 
171*bbaa8b60SDan Kruchinin 	return (TRUE);
172*bbaa8b60SDan Kruchinin }
173*bbaa8b60SDan Kruchinin 
174*bbaa8b60SDan Kruchinin /*
175*bbaa8b60SDan Kruchinin  * Callback functions for nlm_lock_1_svc
176*bbaa8b60SDan Kruchinin  */
177*bbaa8b60SDan Kruchinin static bool_t nlm_lock_1_reply(SVCXPRT *, nlm4_res *);
178*bbaa8b60SDan Kruchinin static enum clnt_stat nlm_granted_1_cb(nlm4_testargs *, void *, CLIENT *);
179*bbaa8b60SDan Kruchinin 
180*bbaa8b60SDan Kruchinin bool_t
181*bbaa8b60SDan Kruchinin nlm_lock_1_svc(nlm_lockargs *argp, nlm_res *resp,
182*bbaa8b60SDan Kruchinin     struct svc_req *sr)
183*bbaa8b60SDan Kruchinin {
184*bbaa8b60SDan Kruchinin 	nlm4_lockargs args4;
185*bbaa8b60SDan Kruchinin 	nlm4_res res4;
186*bbaa8b60SDan Kruchinin 
187*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
188*bbaa8b60SDan Kruchinin 
189*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
190*bbaa8b60SDan Kruchinin 	args4.block = argp->block;
191*bbaa8b60SDan Kruchinin 	args4.exclusive = argp->exclusive;
192*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
193*bbaa8b60SDan Kruchinin 	args4.reclaim = argp->reclaim;
194*bbaa8b60SDan Kruchinin 	args4.state = argp->state;
195*bbaa8b60SDan Kruchinin 
196*bbaa8b60SDan Kruchinin 	/* NLM_LOCK */
197*bbaa8b60SDan Kruchinin 	nlm_do_lock(&args4, &res4, sr,
198*bbaa8b60SDan Kruchinin 	    nlm_lock_1_reply, NULL,
199*bbaa8b60SDan Kruchinin 	    nlm_granted_1_cb);
200*bbaa8b60SDan Kruchinin 
201*bbaa8b60SDan Kruchinin 	/* for freeresult */
202*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(resp, &res4);
203*bbaa8b60SDan Kruchinin 
204*bbaa8b60SDan Kruchinin 	/* above does its own reply */
205*bbaa8b60SDan Kruchinin 	return (FALSE);
206*bbaa8b60SDan Kruchinin }
207*bbaa8b60SDan Kruchinin 
208*bbaa8b60SDan Kruchinin static bool_t
209*bbaa8b60SDan Kruchinin nlm_lock_1_reply(SVCXPRT *transp, nlm4_res *resp)
210*bbaa8b60SDan Kruchinin {
211*bbaa8b60SDan Kruchinin 	nlm_res res1;
212*bbaa8b60SDan Kruchinin 
213*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(&res1, resp);
214*bbaa8b60SDan Kruchinin 	return (svc_sendreply(transp, xdr_nlm_res, (char *)&res1));
215*bbaa8b60SDan Kruchinin }
216*bbaa8b60SDan Kruchinin 
217*bbaa8b60SDan Kruchinin static enum clnt_stat
218*bbaa8b60SDan Kruchinin nlm_granted_1_cb(nlm4_testargs *argp, void *resp, CLIENT *clnt)
219*bbaa8b60SDan Kruchinin {
220*bbaa8b60SDan Kruchinin 	nlm_testargs args1;
221*bbaa8b60SDan Kruchinin 	nlm_res res1;
222*bbaa8b60SDan Kruchinin 	int rv;
223*bbaa8b60SDan Kruchinin 
224*bbaa8b60SDan Kruchinin 	bzero(&res1, sizeof (res1));
225*bbaa8b60SDan Kruchinin 
226*bbaa8b60SDan Kruchinin 	args1.cookie = argp->cookie;
227*bbaa8b60SDan Kruchinin 	args1.exclusive = argp->exclusive;
228*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_lock(&args1.alock, &argp->alock);
229*bbaa8b60SDan Kruchinin 
230*bbaa8b60SDan Kruchinin 	rv = nlm_granted_1(&args1, &res1, clnt);
231*bbaa8b60SDan Kruchinin 
232*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
233*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm_res, (void *)&res1);
234*bbaa8b60SDan Kruchinin 	(void) resp;
235*bbaa8b60SDan Kruchinin 
236*bbaa8b60SDan Kruchinin 	return (rv);
237*bbaa8b60SDan Kruchinin }
238*bbaa8b60SDan Kruchinin 
239*bbaa8b60SDan Kruchinin bool_t
240*bbaa8b60SDan Kruchinin nlm_cancel_1_svc(struct nlm_cancargs *argp, nlm_res *resp,
241*bbaa8b60SDan Kruchinin     struct svc_req *sr)
242*bbaa8b60SDan Kruchinin {
243*bbaa8b60SDan Kruchinin 	nlm4_cancargs args4;
244*bbaa8b60SDan Kruchinin 	nlm4_res res4;
245*bbaa8b60SDan Kruchinin 
246*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
247*bbaa8b60SDan Kruchinin 
248*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
249*bbaa8b60SDan Kruchinin 	args4.block = argp->block;
250*bbaa8b60SDan Kruchinin 	args4.exclusive = argp->exclusive;
251*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
252*bbaa8b60SDan Kruchinin 
253*bbaa8b60SDan Kruchinin 	nlm_do_cancel(&args4, &res4, sr, NULL);
254*bbaa8b60SDan Kruchinin 
255*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(resp, &res4);
256*bbaa8b60SDan Kruchinin 
257*bbaa8b60SDan Kruchinin 	return (TRUE);
258*bbaa8b60SDan Kruchinin }
259*bbaa8b60SDan Kruchinin 
260*bbaa8b60SDan Kruchinin bool_t
261*bbaa8b60SDan Kruchinin nlm_unlock_1_svc(struct nlm_unlockargs *argp, nlm_res *resp,
262*bbaa8b60SDan Kruchinin     struct svc_req *sr)
263*bbaa8b60SDan Kruchinin {
264*bbaa8b60SDan Kruchinin 	nlm4_unlockargs args4;
265*bbaa8b60SDan Kruchinin 	nlm4_res res4;
266*bbaa8b60SDan Kruchinin 
267*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
268*bbaa8b60SDan Kruchinin 
269*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
270*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
271*bbaa8b60SDan Kruchinin 
272*bbaa8b60SDan Kruchinin 	nlm_do_unlock(&args4, &res4, sr, NULL);
273*bbaa8b60SDan Kruchinin 
274*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(resp, &res4);
275*bbaa8b60SDan Kruchinin 
276*bbaa8b60SDan Kruchinin 	return (TRUE);
277*bbaa8b60SDan Kruchinin }
278*bbaa8b60SDan Kruchinin 
279*bbaa8b60SDan Kruchinin bool_t
280*bbaa8b60SDan Kruchinin nlm_granted_1_svc(struct nlm_testargs *argp, nlm_res *resp,
281*bbaa8b60SDan Kruchinin     struct svc_req *sr)
282*bbaa8b60SDan Kruchinin {
283*bbaa8b60SDan Kruchinin 	nlm4_testargs args4;
284*bbaa8b60SDan Kruchinin 	nlm4_res res4;
285*bbaa8b60SDan Kruchinin 
286*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
287*bbaa8b60SDan Kruchinin 
288*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
289*bbaa8b60SDan Kruchinin 	args4.exclusive = argp->exclusive;
290*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
291*bbaa8b60SDan Kruchinin 
292*bbaa8b60SDan Kruchinin 	nlm_do_granted(&args4, &res4, sr, NULL);
293*bbaa8b60SDan Kruchinin 
294*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(resp, &res4);
295*bbaa8b60SDan Kruchinin 
296*bbaa8b60SDan Kruchinin 	return (TRUE);
297*bbaa8b60SDan Kruchinin }
298*bbaa8b60SDan Kruchinin 
299*bbaa8b60SDan Kruchinin /*
300*bbaa8b60SDan Kruchinin  * The _msg_ calls get no reply.  Instead, these callers
301*bbaa8b60SDan Kruchinin  * expect an RPC call to the corresponding _res function.
302*bbaa8b60SDan Kruchinin  * We pass this callback function to nlm_do_test so it will
303*bbaa8b60SDan Kruchinin  * use it to do the RPC callback, with the correct res type.
304*bbaa8b60SDan Kruchinin  *
305*bbaa8b60SDan Kruchinin  * The callback functions have nearly the same arg signature
306*bbaa8b60SDan Kruchinin  * as the client call functions so that many of those can be
307*bbaa8b60SDan Kruchinin  * optimized to nothing by the compiler.  Also, passing the
308*bbaa8b60SDan Kruchinin  * null result arg for these just to reduce warnings.
309*bbaa8b60SDan Kruchinin  *
310*bbaa8b60SDan Kruchinin  * See similar callbacks for other _msg functions below.
311*bbaa8b60SDan Kruchinin  */
312*bbaa8b60SDan Kruchinin 
313*bbaa8b60SDan Kruchinin static enum clnt_stat nlm_test_res_1_cb(nlm4_testres *, void *, CLIENT *);
314*bbaa8b60SDan Kruchinin 
315*bbaa8b60SDan Kruchinin bool_t
316*bbaa8b60SDan Kruchinin nlm_test_msg_1_svc(struct nlm_testargs *argp, void *resp,
317*bbaa8b60SDan Kruchinin     struct svc_req *sr)
318*bbaa8b60SDan Kruchinin {
319*bbaa8b60SDan Kruchinin 	nlm4_testargs args4;
320*bbaa8b60SDan Kruchinin 	nlm4_testres res4;
321*bbaa8b60SDan Kruchinin 
322*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
323*bbaa8b60SDan Kruchinin 
324*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
325*bbaa8b60SDan Kruchinin 	args4.exclusive = argp->exclusive;
326*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
327*bbaa8b60SDan Kruchinin 
328*bbaa8b60SDan Kruchinin 	nlm_do_test(&args4, &res4, sr,
329*bbaa8b60SDan Kruchinin 	    nlm_test_res_1_cb);
330*bbaa8b60SDan Kruchinin 
331*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
332*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_testres, (void *)&res4);
333*bbaa8b60SDan Kruchinin 	(void) resp;
334*bbaa8b60SDan Kruchinin 
335*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
336*bbaa8b60SDan Kruchinin 	return (FALSE);
337*bbaa8b60SDan Kruchinin }
338*bbaa8b60SDan Kruchinin 
339*bbaa8b60SDan Kruchinin static enum clnt_stat
340*bbaa8b60SDan Kruchinin nlm_test_res_1_cb(nlm4_testres *res4, void *null, CLIENT *clnt)
341*bbaa8b60SDan Kruchinin {
342*bbaa8b60SDan Kruchinin 	nlm_testres res1;
343*bbaa8b60SDan Kruchinin 
344*bbaa8b60SDan Kruchinin 	res1.cookie = res4->cookie;
345*bbaa8b60SDan Kruchinin 	res1.stat.stat = nlm_convert_to_nlm_stats(res4->stat.stat);
346*bbaa8b60SDan Kruchinin 	if (res1.stat.stat == nlm_denied)
347*bbaa8b60SDan Kruchinin 		nlm_convert_to_nlm_holder(
348*bbaa8b60SDan Kruchinin 		    &res1.stat.nlm_testrply_u.holder,
349*bbaa8b60SDan Kruchinin 		    &res4->stat.nlm4_testrply_u.holder);
350*bbaa8b60SDan Kruchinin 
351*bbaa8b60SDan Kruchinin 	return (nlm_test_res_1(&res1, null, clnt));
352*bbaa8b60SDan Kruchinin }
353*bbaa8b60SDan Kruchinin 
354*bbaa8b60SDan Kruchinin /*
355*bbaa8b60SDan Kruchinin  * Callback functions for nlm_lock_msg_1_svc
356*bbaa8b60SDan Kruchinin  */
357*bbaa8b60SDan Kruchinin static enum clnt_stat nlm_lock_res_1_cb(nlm4_res *, void *, CLIENT *);
358*bbaa8b60SDan Kruchinin static enum clnt_stat nlm_granted_msg_1_cb(nlm4_testargs *, void *, CLIENT *);
359*bbaa8b60SDan Kruchinin 
360*bbaa8b60SDan Kruchinin bool_t
361*bbaa8b60SDan Kruchinin nlm_lock_msg_1_svc(nlm_lockargs *argp, void *resp,
362*bbaa8b60SDan Kruchinin     struct svc_req *sr)
363*bbaa8b60SDan Kruchinin {
364*bbaa8b60SDan Kruchinin 	nlm4_lockargs args4;
365*bbaa8b60SDan Kruchinin 	nlm4_res res4;
366*bbaa8b60SDan Kruchinin 
367*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
368*bbaa8b60SDan Kruchinin 
369*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
370*bbaa8b60SDan Kruchinin 	args4.block = argp->block;
371*bbaa8b60SDan Kruchinin 	args4.exclusive = argp->exclusive;
372*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
373*bbaa8b60SDan Kruchinin 	args4.reclaim = argp->reclaim;
374*bbaa8b60SDan Kruchinin 	args4.state = argp->state;
375*bbaa8b60SDan Kruchinin 
376*bbaa8b60SDan Kruchinin 	/* NLM_LOCK_MSG */
377*bbaa8b60SDan Kruchinin 	nlm_do_lock(&args4, &res4, sr,
378*bbaa8b60SDan Kruchinin 	    NULL, nlm_lock_res_1_cb,
379*bbaa8b60SDan Kruchinin 	    nlm_granted_msg_1_cb);
380*bbaa8b60SDan Kruchinin 
381*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
382*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_res, (void *)&res4);
383*bbaa8b60SDan Kruchinin 	(void) resp;
384*bbaa8b60SDan Kruchinin 
385*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
386*bbaa8b60SDan Kruchinin 	return (FALSE);
387*bbaa8b60SDan Kruchinin }
388*bbaa8b60SDan Kruchinin 
389*bbaa8b60SDan Kruchinin static enum clnt_stat
390*bbaa8b60SDan Kruchinin nlm_lock_res_1_cb(nlm4_res *resp, void *null, CLIENT *clnt)
391*bbaa8b60SDan Kruchinin {
392*bbaa8b60SDan Kruchinin 	nlm_res res1;
393*bbaa8b60SDan Kruchinin 
394*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(&res1, resp);
395*bbaa8b60SDan Kruchinin 	return (nlm_lock_res_1(&res1, null, clnt));
396*bbaa8b60SDan Kruchinin }
397*bbaa8b60SDan Kruchinin 
398*bbaa8b60SDan Kruchinin static enum clnt_stat
399*bbaa8b60SDan Kruchinin nlm_granted_msg_1_cb(nlm4_testargs *argp, void *null, CLIENT *clnt)
400*bbaa8b60SDan Kruchinin {
401*bbaa8b60SDan Kruchinin 	nlm_testargs args1;
402*bbaa8b60SDan Kruchinin 
403*bbaa8b60SDan Kruchinin 	args1.cookie = argp->cookie;
404*bbaa8b60SDan Kruchinin 	args1.exclusive = argp->exclusive;
405*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_lock(&args1.alock, &argp->alock);
406*bbaa8b60SDan Kruchinin 
407*bbaa8b60SDan Kruchinin 	return (nlm_granted_msg_1(&args1, null, clnt));
408*bbaa8b60SDan Kruchinin 
409*bbaa8b60SDan Kruchinin }
410*bbaa8b60SDan Kruchinin 
411*bbaa8b60SDan Kruchinin 
412*bbaa8b60SDan Kruchinin static enum clnt_stat nlm_cancel_res_1_cb(nlm4_res *, void *, CLIENT *);
413*bbaa8b60SDan Kruchinin 
414*bbaa8b60SDan Kruchinin bool_t
415*bbaa8b60SDan Kruchinin nlm_cancel_msg_1_svc(struct nlm_cancargs *argp, void *resp,
416*bbaa8b60SDan Kruchinin     struct svc_req *sr)
417*bbaa8b60SDan Kruchinin {
418*bbaa8b60SDan Kruchinin 	nlm4_cancargs args4;
419*bbaa8b60SDan Kruchinin 	nlm4_res res4;
420*bbaa8b60SDan Kruchinin 
421*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
422*bbaa8b60SDan Kruchinin 
423*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
424*bbaa8b60SDan Kruchinin 	args4.block = argp->block;
425*bbaa8b60SDan Kruchinin 	args4.exclusive = argp->exclusive;
426*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
427*bbaa8b60SDan Kruchinin 
428*bbaa8b60SDan Kruchinin 	nlm_do_cancel(&args4, &res4, sr,
429*bbaa8b60SDan Kruchinin 	    nlm_cancel_res_1_cb);
430*bbaa8b60SDan Kruchinin 
431*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
432*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_res, (void *)&res4);
433*bbaa8b60SDan Kruchinin 	(void) resp;
434*bbaa8b60SDan Kruchinin 
435*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
436*bbaa8b60SDan Kruchinin 	return (FALSE);
437*bbaa8b60SDan Kruchinin }
438*bbaa8b60SDan Kruchinin 
439*bbaa8b60SDan Kruchinin static enum clnt_stat
440*bbaa8b60SDan Kruchinin nlm_cancel_res_1_cb(nlm4_res *res4, void *null, CLIENT *clnt)
441*bbaa8b60SDan Kruchinin {
442*bbaa8b60SDan Kruchinin 	nlm_res res1;
443*bbaa8b60SDan Kruchinin 
444*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(&res1, res4);
445*bbaa8b60SDan Kruchinin 	return (nlm_cancel_res_1(&res1, null, clnt));
446*bbaa8b60SDan Kruchinin }
447*bbaa8b60SDan Kruchinin 
448*bbaa8b60SDan Kruchinin 
449*bbaa8b60SDan Kruchinin static enum clnt_stat nlm_unlock_res_1_cb(nlm4_res *, void *, CLIENT *);
450*bbaa8b60SDan Kruchinin 
451*bbaa8b60SDan Kruchinin bool_t
452*bbaa8b60SDan Kruchinin nlm_unlock_msg_1_svc(struct nlm_unlockargs *argp, void *resp,
453*bbaa8b60SDan Kruchinin     struct svc_req *sr)
454*bbaa8b60SDan Kruchinin {
455*bbaa8b60SDan Kruchinin 	nlm4_unlockargs args4;
456*bbaa8b60SDan Kruchinin 	nlm4_res res4;
457*bbaa8b60SDan Kruchinin 
458*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
459*bbaa8b60SDan Kruchinin 
460*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
461*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
462*bbaa8b60SDan Kruchinin 
463*bbaa8b60SDan Kruchinin 	nlm_do_unlock(&args4, &res4, sr,
464*bbaa8b60SDan Kruchinin 	    nlm_unlock_res_1_cb);
465*bbaa8b60SDan Kruchinin 
466*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
467*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_res, (void *)&res4);
468*bbaa8b60SDan Kruchinin 	(void) resp;
469*bbaa8b60SDan Kruchinin 
470*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
471*bbaa8b60SDan Kruchinin 	return (FALSE);
472*bbaa8b60SDan Kruchinin }
473*bbaa8b60SDan Kruchinin 
474*bbaa8b60SDan Kruchinin static enum clnt_stat
475*bbaa8b60SDan Kruchinin nlm_unlock_res_1_cb(nlm4_res *res4, void *null, CLIENT *clnt)
476*bbaa8b60SDan Kruchinin {
477*bbaa8b60SDan Kruchinin 	nlm_res res1;
478*bbaa8b60SDan Kruchinin 
479*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(&res1, res4);
480*bbaa8b60SDan Kruchinin 	return (nlm_unlock_res_1(&res1, null, clnt));
481*bbaa8b60SDan Kruchinin }
482*bbaa8b60SDan Kruchinin 
483*bbaa8b60SDan Kruchinin 
484*bbaa8b60SDan Kruchinin static enum clnt_stat nlm_granted_res_1_cb(nlm4_res *, void *, CLIENT *);
485*bbaa8b60SDan Kruchinin 
486*bbaa8b60SDan Kruchinin bool_t
487*bbaa8b60SDan Kruchinin nlm_granted_msg_1_svc(struct nlm_testargs *argp, void *resp,
488*bbaa8b60SDan Kruchinin     struct svc_req *sr)
489*bbaa8b60SDan Kruchinin {
490*bbaa8b60SDan Kruchinin 	nlm4_testargs args4;
491*bbaa8b60SDan Kruchinin 	nlm4_res res4;
492*bbaa8b60SDan Kruchinin 
493*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
494*bbaa8b60SDan Kruchinin 
495*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
496*bbaa8b60SDan Kruchinin 	args4.exclusive = argp->exclusive;
497*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
498*bbaa8b60SDan Kruchinin 
499*bbaa8b60SDan Kruchinin 	nlm_do_granted(&args4, &res4, sr,
500*bbaa8b60SDan Kruchinin 	    nlm_granted_res_1_cb);
501*bbaa8b60SDan Kruchinin 
502*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
503*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_res, (void *)&res4);
504*bbaa8b60SDan Kruchinin 	(void) resp;
505*bbaa8b60SDan Kruchinin 
506*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
507*bbaa8b60SDan Kruchinin 	return (FALSE);
508*bbaa8b60SDan Kruchinin }
509*bbaa8b60SDan Kruchinin 
510*bbaa8b60SDan Kruchinin static enum clnt_stat
511*bbaa8b60SDan Kruchinin nlm_granted_res_1_cb(nlm4_res *res4, void *null, CLIENT *clnt)
512*bbaa8b60SDan Kruchinin {
513*bbaa8b60SDan Kruchinin 	nlm_res res1;
514*bbaa8b60SDan Kruchinin 
515*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(&res1, res4);
516*bbaa8b60SDan Kruchinin 	return (nlm_granted_res_1(&res1, null, clnt));
517*bbaa8b60SDan Kruchinin }
518*bbaa8b60SDan Kruchinin 
519*bbaa8b60SDan Kruchinin /*
520*bbaa8b60SDan Kruchinin  * The _res_ calls get no reply.  These RPC calls are
521*bbaa8b60SDan Kruchinin  * "call backs" in response to RPC _msg_ calls.
522*bbaa8b60SDan Kruchinin  * We don't care about these responses.
523*bbaa8b60SDan Kruchinin  */
524*bbaa8b60SDan Kruchinin 
525*bbaa8b60SDan Kruchinin /* ARGSUSED */
526*bbaa8b60SDan Kruchinin bool_t
527*bbaa8b60SDan Kruchinin nlm_test_res_1_svc(nlm_testres *argp, void *resp, struct svc_req *sr)
528*bbaa8b60SDan Kruchinin {
529*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
530*bbaa8b60SDan Kruchinin 	return (FALSE);
531*bbaa8b60SDan Kruchinin }
532*bbaa8b60SDan Kruchinin 
533*bbaa8b60SDan Kruchinin /* ARGSUSED */
534*bbaa8b60SDan Kruchinin bool_t
535*bbaa8b60SDan Kruchinin nlm_lock_res_1_svc(nlm_res *argp, void *resp, struct svc_req *sr)
536*bbaa8b60SDan Kruchinin {
537*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
538*bbaa8b60SDan Kruchinin 	return (FALSE);
539*bbaa8b60SDan Kruchinin }
540*bbaa8b60SDan Kruchinin 
541*bbaa8b60SDan Kruchinin /* ARGSUSED */
542*bbaa8b60SDan Kruchinin bool_t
543*bbaa8b60SDan Kruchinin nlm_cancel_res_1_svc(nlm_res *argp, void *resp, struct svc_req *sr)
544*bbaa8b60SDan Kruchinin {
545*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
546*bbaa8b60SDan Kruchinin 	return (FALSE);
547*bbaa8b60SDan Kruchinin }
548*bbaa8b60SDan Kruchinin 
549*bbaa8b60SDan Kruchinin /* ARGSUSED */
550*bbaa8b60SDan Kruchinin bool_t
551*bbaa8b60SDan Kruchinin nlm_unlock_res_1_svc(nlm_res *argp, void *resp, struct svc_req *sr)
552*bbaa8b60SDan Kruchinin {
553*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
554*bbaa8b60SDan Kruchinin 	return (FALSE);
555*bbaa8b60SDan Kruchinin }
556*bbaa8b60SDan Kruchinin 
557*bbaa8b60SDan Kruchinin /* ARGSUSED */
558*bbaa8b60SDan Kruchinin bool_t
559*bbaa8b60SDan Kruchinin nlm_granted_res_1_svc(nlm_res *argp, void *resp, struct svc_req *sr)
560*bbaa8b60SDan Kruchinin {
561*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
562*bbaa8b60SDan Kruchinin 	return (FALSE);
563*bbaa8b60SDan Kruchinin }
564*bbaa8b60SDan Kruchinin 
565*bbaa8b60SDan Kruchinin /*
566*bbaa8b60SDan Kruchinin  * Version 2 svc functions (used by local statd)
567*bbaa8b60SDan Kruchinin  */
568*bbaa8b60SDan Kruchinin 
569*bbaa8b60SDan Kruchinin bool_t
570*bbaa8b60SDan Kruchinin nlm_sm_notify1_2_svc(struct nlm_sm_status *argp, void *resp,
571*bbaa8b60SDan Kruchinin     struct svc_req *sr)
572*bbaa8b60SDan Kruchinin {
573*bbaa8b60SDan Kruchinin 	nlm_do_notify1(argp, resp, sr);
574*bbaa8b60SDan Kruchinin 	return (TRUE);
575*bbaa8b60SDan Kruchinin }
576*bbaa8b60SDan Kruchinin 
577*bbaa8b60SDan Kruchinin bool_t
578*bbaa8b60SDan Kruchinin nlm_sm_notify2_2_svc(struct nlm_sm_status *argp, void *resp,
579*bbaa8b60SDan Kruchinin     struct svc_req *sr)
580*bbaa8b60SDan Kruchinin {
581*bbaa8b60SDan Kruchinin 	nlm_do_notify2(argp, resp, sr);
582*bbaa8b60SDan Kruchinin 	return (TRUE);
583*bbaa8b60SDan Kruchinin }
584*bbaa8b60SDan Kruchinin 
585*bbaa8b60SDan Kruchinin /*
586*bbaa8b60SDan Kruchinin  * Version 3 svc functions
587*bbaa8b60SDan Kruchinin  */
588*bbaa8b60SDan Kruchinin 
589*bbaa8b60SDan Kruchinin bool_t
590*bbaa8b60SDan Kruchinin nlm_share_3_svc(nlm_shareargs *argp, nlm_shareres *resp,
591*bbaa8b60SDan Kruchinin     struct svc_req *sr)
592*bbaa8b60SDan Kruchinin {
593*bbaa8b60SDan Kruchinin 	nlm4_shareargs args4;
594*bbaa8b60SDan Kruchinin 	nlm4_shareres res4;
595*bbaa8b60SDan Kruchinin 
596*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
597*bbaa8b60SDan Kruchinin 
598*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
599*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_share(&args4.share, &argp->share);
600*bbaa8b60SDan Kruchinin 	args4.reclaim = argp->reclaim;
601*bbaa8b60SDan Kruchinin 
602*bbaa8b60SDan Kruchinin 	nlm_do_share(&args4, &res4, sr);
603*bbaa8b60SDan Kruchinin 
604*bbaa8b60SDan Kruchinin 	resp->cookie = res4.cookie;
605*bbaa8b60SDan Kruchinin 	resp->stat = nlm_convert_to_nlm_stats(res4.stat);
606*bbaa8b60SDan Kruchinin 	resp->sequence = res4.sequence;
607*bbaa8b60SDan Kruchinin 
608*bbaa8b60SDan Kruchinin 	return (TRUE);
609*bbaa8b60SDan Kruchinin }
610*bbaa8b60SDan Kruchinin 
611*bbaa8b60SDan Kruchinin bool_t
612*bbaa8b60SDan Kruchinin nlm_unshare_3_svc(nlm_shareargs *argp, nlm_shareres *resp,
613*bbaa8b60SDan Kruchinin     struct svc_req *sr)
614*bbaa8b60SDan Kruchinin {
615*bbaa8b60SDan Kruchinin 	nlm4_shareargs args4;
616*bbaa8b60SDan Kruchinin 	nlm4_shareres res4;
617*bbaa8b60SDan Kruchinin 
618*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
619*bbaa8b60SDan Kruchinin 
620*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
621*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_share(&args4.share, &argp->share);
622*bbaa8b60SDan Kruchinin 	args4.reclaim = argp->reclaim;
623*bbaa8b60SDan Kruchinin 
624*bbaa8b60SDan Kruchinin 	nlm_do_unshare(&args4, &res4, sr);
625*bbaa8b60SDan Kruchinin 
626*bbaa8b60SDan Kruchinin 	resp->cookie = res4.cookie;
627*bbaa8b60SDan Kruchinin 	resp->stat = nlm_convert_to_nlm_stats(res4.stat);
628*bbaa8b60SDan Kruchinin 	resp->sequence = res4.sequence;
629*bbaa8b60SDan Kruchinin 
630*bbaa8b60SDan Kruchinin 	return (TRUE);
631*bbaa8b60SDan Kruchinin }
632*bbaa8b60SDan Kruchinin 
633*bbaa8b60SDan Kruchinin bool_t
634*bbaa8b60SDan Kruchinin nlm_nm_lock_3_svc(nlm_lockargs *argp, nlm_res *resp, struct svc_req *sr)
635*bbaa8b60SDan Kruchinin {
636*bbaa8b60SDan Kruchinin 	nlm4_lockargs args4;
637*bbaa8b60SDan Kruchinin 	nlm4_res res4;
638*bbaa8b60SDan Kruchinin 
639*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
640*bbaa8b60SDan Kruchinin 
641*bbaa8b60SDan Kruchinin 	args4.cookie = argp->cookie;
642*bbaa8b60SDan Kruchinin 	args4.block = argp->block;
643*bbaa8b60SDan Kruchinin 	args4.exclusive = argp->exclusive;
644*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm4_lock(&args4.alock, &argp->alock);
645*bbaa8b60SDan Kruchinin 	args4.reclaim = argp->reclaim;
646*bbaa8b60SDan Kruchinin 	args4.state = argp->state;
647*bbaa8b60SDan Kruchinin 
648*bbaa8b60SDan Kruchinin 	/*
649*bbaa8b60SDan Kruchinin 	 * Don't allow blocking for non-monitored (nm_lock) calls.
650*bbaa8b60SDan Kruchinin 	 * These clients don't handle any callbacks, including
651*bbaa8b60SDan Kruchinin 	 * the granted call we make after a blocking lock.
652*bbaa8b60SDan Kruchinin 	 * Same reply callback as nlm_lock_1_svc
653*bbaa8b60SDan Kruchinin 	 */
654*bbaa8b60SDan Kruchinin 	args4.block = FALSE;
655*bbaa8b60SDan Kruchinin 
656*bbaa8b60SDan Kruchinin 	/* NLM_NM_LOCK */
657*bbaa8b60SDan Kruchinin 	nlm_do_lock(&args4, &res4, sr,
658*bbaa8b60SDan Kruchinin 	    nlm_lock_1_reply, NULL,
659*bbaa8b60SDan Kruchinin 	    NULL); /* indicates non-monitored */
660*bbaa8b60SDan Kruchinin 
661*bbaa8b60SDan Kruchinin 	/* for freeresult */
662*bbaa8b60SDan Kruchinin 	nlm_convert_to_nlm_res(resp, &res4);
663*bbaa8b60SDan Kruchinin 
664*bbaa8b60SDan Kruchinin 	/* above does its own reply */
665*bbaa8b60SDan Kruchinin 	return (FALSE);
666*bbaa8b60SDan Kruchinin }
667*bbaa8b60SDan Kruchinin 
668*bbaa8b60SDan Kruchinin bool_t
669*bbaa8b60SDan Kruchinin nlm_free_all_3_svc(nlm_notify *argp, void *resp, struct svc_req *sr)
670*bbaa8b60SDan Kruchinin {
671*bbaa8b60SDan Kruchinin 	struct nlm4_notify args4;
672*bbaa8b60SDan Kruchinin 
673*bbaa8b60SDan Kruchinin 	args4.name = argp->name;
674*bbaa8b60SDan Kruchinin 	args4.state = argp->state;
675*bbaa8b60SDan Kruchinin 
676*bbaa8b60SDan Kruchinin 	nlm_do_free_all(&args4, resp, sr);
677*bbaa8b60SDan Kruchinin 
678*bbaa8b60SDan Kruchinin 	return (TRUE);
679*bbaa8b60SDan Kruchinin }
680*bbaa8b60SDan Kruchinin 
681*bbaa8b60SDan Kruchinin /*
682*bbaa8b60SDan Kruchinin  * Version 4 svc functions
683*bbaa8b60SDan Kruchinin  */
684*bbaa8b60SDan Kruchinin 
685*bbaa8b60SDan Kruchinin bool_t
686*bbaa8b60SDan Kruchinin nlm4_test_4_svc(nlm4_testargs *argp, nlm4_testres *resp, struct svc_req *sr)
687*bbaa8b60SDan Kruchinin {
688*bbaa8b60SDan Kruchinin 	nlm_do_test(argp, resp, sr, NULL);
689*bbaa8b60SDan Kruchinin 	return (TRUE);
690*bbaa8b60SDan Kruchinin }
691*bbaa8b60SDan Kruchinin 
692*bbaa8b60SDan Kruchinin /*
693*bbaa8b60SDan Kruchinin  * Callback functions for nlm4_lock_4_svc
694*bbaa8b60SDan Kruchinin  */
695*bbaa8b60SDan Kruchinin static bool_t nlm4_lock_4_reply(SVCXPRT *, nlm4_res *);
696*bbaa8b60SDan Kruchinin static enum clnt_stat nlm4_granted_4_cb(nlm4_testargs *, void *, CLIENT *);
697*bbaa8b60SDan Kruchinin 
698*bbaa8b60SDan Kruchinin bool_t
699*bbaa8b60SDan Kruchinin nlm4_lock_4_svc(nlm4_lockargs *argp, nlm4_res *resp,
700*bbaa8b60SDan Kruchinin     struct svc_req *sr)
701*bbaa8b60SDan Kruchinin {
702*bbaa8b60SDan Kruchinin 
703*bbaa8b60SDan Kruchinin 	/* NLM4_LOCK */
704*bbaa8b60SDan Kruchinin 	nlm_do_lock(argp, resp, sr,
705*bbaa8b60SDan Kruchinin 	    nlm4_lock_4_reply, NULL,
706*bbaa8b60SDan Kruchinin 	    nlm4_granted_4_cb);
707*bbaa8b60SDan Kruchinin 
708*bbaa8b60SDan Kruchinin 	/* above does its own reply */
709*bbaa8b60SDan Kruchinin 	return (FALSE);
710*bbaa8b60SDan Kruchinin }
711*bbaa8b60SDan Kruchinin 
712*bbaa8b60SDan Kruchinin static bool_t
713*bbaa8b60SDan Kruchinin nlm4_lock_4_reply(SVCXPRT *transp, nlm4_res *resp)
714*bbaa8b60SDan Kruchinin {
715*bbaa8b60SDan Kruchinin 	return (svc_sendreply(transp, xdr_nlm4_res, (char *)resp));
716*bbaa8b60SDan Kruchinin }
717*bbaa8b60SDan Kruchinin 
718*bbaa8b60SDan Kruchinin static enum clnt_stat
719*bbaa8b60SDan Kruchinin nlm4_granted_4_cb(nlm4_testargs *argp, void *resp, CLIENT *clnt)
720*bbaa8b60SDan Kruchinin {
721*bbaa8b60SDan Kruchinin 	nlm4_res res4;
722*bbaa8b60SDan Kruchinin 	int rv;
723*bbaa8b60SDan Kruchinin 
724*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
725*bbaa8b60SDan Kruchinin 	rv = nlm4_granted_4(argp, &res4, clnt);
726*bbaa8b60SDan Kruchinin 
727*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
728*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_res, (void *)&res4);
729*bbaa8b60SDan Kruchinin 	(void) resp;
730*bbaa8b60SDan Kruchinin 
731*bbaa8b60SDan Kruchinin 	return (rv);
732*bbaa8b60SDan Kruchinin }
733*bbaa8b60SDan Kruchinin 
734*bbaa8b60SDan Kruchinin bool_t
735*bbaa8b60SDan Kruchinin nlm4_cancel_4_svc(nlm4_cancargs *argp, nlm4_res *resp, struct svc_req *sr)
736*bbaa8b60SDan Kruchinin {
737*bbaa8b60SDan Kruchinin 	nlm_do_cancel(argp, resp, sr, NULL);
738*bbaa8b60SDan Kruchinin 	return (TRUE);
739*bbaa8b60SDan Kruchinin }
740*bbaa8b60SDan Kruchinin 
741*bbaa8b60SDan Kruchinin bool_t
742*bbaa8b60SDan Kruchinin nlm4_unlock_4_svc(nlm4_unlockargs *argp, nlm4_res *resp, struct svc_req *sr)
743*bbaa8b60SDan Kruchinin {
744*bbaa8b60SDan Kruchinin 	nlm_do_unlock(argp, resp, sr, NULL);
745*bbaa8b60SDan Kruchinin 	return (TRUE);
746*bbaa8b60SDan Kruchinin }
747*bbaa8b60SDan Kruchinin 
748*bbaa8b60SDan Kruchinin bool_t
749*bbaa8b60SDan Kruchinin nlm4_granted_4_svc(nlm4_testargs *argp, nlm4_res *resp, struct svc_req *sr)
750*bbaa8b60SDan Kruchinin {
751*bbaa8b60SDan Kruchinin 	nlm_do_granted(argp, resp, sr, NULL);
752*bbaa8b60SDan Kruchinin 	return (TRUE);
753*bbaa8b60SDan Kruchinin }
754*bbaa8b60SDan Kruchinin 
755*bbaa8b60SDan Kruchinin bool_t
756*bbaa8b60SDan Kruchinin nlm4_test_msg_4_svc(nlm4_testargs *argp, void *resp, struct svc_req *sr)
757*bbaa8b60SDan Kruchinin {
758*bbaa8b60SDan Kruchinin 	nlm4_testres res4;
759*bbaa8b60SDan Kruchinin 
760*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
761*bbaa8b60SDan Kruchinin 	nlm_do_test(argp, &res4, sr,
762*bbaa8b60SDan Kruchinin 	    nlm4_test_res_4);
763*bbaa8b60SDan Kruchinin 
764*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
765*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_testres, (void *)&res4);
766*bbaa8b60SDan Kruchinin 	(void) resp;
767*bbaa8b60SDan Kruchinin 
768*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
769*bbaa8b60SDan Kruchinin 	return (FALSE);
770*bbaa8b60SDan Kruchinin }
771*bbaa8b60SDan Kruchinin 
772*bbaa8b60SDan Kruchinin /*
773*bbaa8b60SDan Kruchinin  * Callback functions for nlm4_lock_msg_4_svc
774*bbaa8b60SDan Kruchinin  * (using the RPC client stubs directly)
775*bbaa8b60SDan Kruchinin  */
776*bbaa8b60SDan Kruchinin 
777*bbaa8b60SDan Kruchinin bool_t
778*bbaa8b60SDan Kruchinin nlm4_lock_msg_4_svc(nlm4_lockargs *argp, void *resp,
779*bbaa8b60SDan Kruchinin     struct svc_req *sr)
780*bbaa8b60SDan Kruchinin {
781*bbaa8b60SDan Kruchinin 	nlm4_res res4;
782*bbaa8b60SDan Kruchinin 
783*bbaa8b60SDan Kruchinin 	/* NLM4_LOCK_MSG */
784*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
785*bbaa8b60SDan Kruchinin 	nlm_do_lock(argp, &res4, sr,
786*bbaa8b60SDan Kruchinin 	    NULL, nlm4_lock_res_4,
787*bbaa8b60SDan Kruchinin 	    nlm4_granted_msg_4);
788*bbaa8b60SDan Kruchinin 
789*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
790*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_res, (void *)&res4);
791*bbaa8b60SDan Kruchinin 	(void) resp;
792*bbaa8b60SDan Kruchinin 
793*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
794*bbaa8b60SDan Kruchinin 	return (FALSE);
795*bbaa8b60SDan Kruchinin }
796*bbaa8b60SDan Kruchinin 
797*bbaa8b60SDan Kruchinin bool_t
798*bbaa8b60SDan Kruchinin nlm4_cancel_msg_4_svc(nlm4_cancargs *argp, void *resp, struct svc_req *sr)
799*bbaa8b60SDan Kruchinin {
800*bbaa8b60SDan Kruchinin 	nlm4_res res4;
801*bbaa8b60SDan Kruchinin 
802*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
803*bbaa8b60SDan Kruchinin 	nlm_do_cancel(argp, &res4, sr,
804*bbaa8b60SDan Kruchinin 	    nlm4_cancel_res_4);
805*bbaa8b60SDan Kruchinin 
806*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
807*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_res, (void *)&res4);
808*bbaa8b60SDan Kruchinin 	(void) resp;
809*bbaa8b60SDan Kruchinin 
810*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
811*bbaa8b60SDan Kruchinin 	return (FALSE);
812*bbaa8b60SDan Kruchinin }
813*bbaa8b60SDan Kruchinin 
814*bbaa8b60SDan Kruchinin bool_t
815*bbaa8b60SDan Kruchinin nlm4_unlock_msg_4_svc(nlm4_unlockargs *argp, void *resp, struct svc_req *sr)
816*bbaa8b60SDan Kruchinin {
817*bbaa8b60SDan Kruchinin 	nlm4_res res4;
818*bbaa8b60SDan Kruchinin 
819*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
820*bbaa8b60SDan Kruchinin 	nlm_do_unlock(argp, &res4, sr,
821*bbaa8b60SDan Kruchinin 	    nlm4_unlock_res_4);
822*bbaa8b60SDan Kruchinin 
823*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
824*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_res, (void *)&res4);
825*bbaa8b60SDan Kruchinin 	(void) resp;
826*bbaa8b60SDan Kruchinin 
827*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
828*bbaa8b60SDan Kruchinin 	return (FALSE);
829*bbaa8b60SDan Kruchinin }
830*bbaa8b60SDan Kruchinin 
831*bbaa8b60SDan Kruchinin bool_t
832*bbaa8b60SDan Kruchinin nlm4_granted_msg_4_svc(nlm4_testargs *argp, void *resp, struct svc_req *sr)
833*bbaa8b60SDan Kruchinin {
834*bbaa8b60SDan Kruchinin 	nlm4_res res4;
835*bbaa8b60SDan Kruchinin 
836*bbaa8b60SDan Kruchinin 	bzero(&res4, sizeof (res4));
837*bbaa8b60SDan Kruchinin 	nlm_do_granted(argp, &res4, sr,
838*bbaa8b60SDan Kruchinin 	    nlm4_granted_res_4);
839*bbaa8b60SDan Kruchinin 
840*bbaa8b60SDan Kruchinin 	/* NB: We have a result our caller will not free. */
841*bbaa8b60SDan Kruchinin 	xdr_free((xdrproc_t)xdr_nlm4_res, (void *)&res4);
842*bbaa8b60SDan Kruchinin 	(void) resp;
843*bbaa8b60SDan Kruchinin 
844*bbaa8b60SDan Kruchinin 	/* The _msg_ calls get no reply. */
845*bbaa8b60SDan Kruchinin 	return (FALSE);
846*bbaa8b60SDan Kruchinin }
847*bbaa8b60SDan Kruchinin 
848*bbaa8b60SDan Kruchinin /* ARGSUSED */
849*bbaa8b60SDan Kruchinin bool_t
850*bbaa8b60SDan Kruchinin nlm4_test_res_4_svc(nlm4_testres *argp, void *resp, struct svc_req *sr)
851*bbaa8b60SDan Kruchinin {
852*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
853*bbaa8b60SDan Kruchinin 	return (FALSE);
854*bbaa8b60SDan Kruchinin }
855*bbaa8b60SDan Kruchinin 
856*bbaa8b60SDan Kruchinin /* ARGSUSED */
857*bbaa8b60SDan Kruchinin bool_t
858*bbaa8b60SDan Kruchinin nlm4_lock_res_4_svc(nlm4_res *argp, void *resp, struct svc_req *sr)
859*bbaa8b60SDan Kruchinin {
860*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
861*bbaa8b60SDan Kruchinin 	return (FALSE);
862*bbaa8b60SDan Kruchinin }
863*bbaa8b60SDan Kruchinin 
864*bbaa8b60SDan Kruchinin /* ARGSUSED */
865*bbaa8b60SDan Kruchinin bool_t
866*bbaa8b60SDan Kruchinin nlm4_cancel_res_4_svc(nlm4_res *argp, void *resp, struct svc_req *sr)
867*bbaa8b60SDan Kruchinin {
868*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
869*bbaa8b60SDan Kruchinin 	return (FALSE);
870*bbaa8b60SDan Kruchinin }
871*bbaa8b60SDan Kruchinin 
872*bbaa8b60SDan Kruchinin /* ARGSUSED */
873*bbaa8b60SDan Kruchinin bool_t
874*bbaa8b60SDan Kruchinin nlm4_unlock_res_4_svc(nlm4_res *argp, void *resp, struct svc_req *sr)
875*bbaa8b60SDan Kruchinin {
876*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
877*bbaa8b60SDan Kruchinin 	return (FALSE);
878*bbaa8b60SDan Kruchinin }
879*bbaa8b60SDan Kruchinin 
880*bbaa8b60SDan Kruchinin /* ARGSUSED */
881*bbaa8b60SDan Kruchinin bool_t
882*bbaa8b60SDan Kruchinin nlm4_granted_res_4_svc(nlm4_res *argp, void *resp, struct svc_req *sr)
883*bbaa8b60SDan Kruchinin {
884*bbaa8b60SDan Kruchinin 	/* The _res_ calls get no reply. */
885*bbaa8b60SDan Kruchinin 	return (FALSE);
886*bbaa8b60SDan Kruchinin }
887*bbaa8b60SDan Kruchinin 
888*bbaa8b60SDan Kruchinin /* ARGSUSED */
889*bbaa8b60SDan Kruchinin bool_t
890*bbaa8b60SDan Kruchinin nlm4_share_4_svc(nlm4_shareargs *argp, nlm4_shareres *resp,
891*bbaa8b60SDan Kruchinin     struct svc_req *sr)
892*bbaa8b60SDan Kruchinin {
893*bbaa8b60SDan Kruchinin 	nlm_do_share(argp, resp, sr);
894*bbaa8b60SDan Kruchinin 	return (TRUE);
895*bbaa8b60SDan Kruchinin }
896*bbaa8b60SDan Kruchinin 
897*bbaa8b60SDan Kruchinin /* ARGSUSED */
898*bbaa8b60SDan Kruchinin bool_t
899*bbaa8b60SDan Kruchinin nlm4_unshare_4_svc(nlm4_shareargs *argp, nlm4_shareres *resp,
900*bbaa8b60SDan Kruchinin     struct svc_req *sr)
901*bbaa8b60SDan Kruchinin {
902*bbaa8b60SDan Kruchinin 	nlm_do_unshare(argp, resp, sr);
903*bbaa8b60SDan Kruchinin 	return (TRUE);
904*bbaa8b60SDan Kruchinin }
905*bbaa8b60SDan Kruchinin 
906*bbaa8b60SDan Kruchinin bool_t
907*bbaa8b60SDan Kruchinin nlm4_nm_lock_4_svc(nlm4_lockargs *argp, nlm4_res *resp, struct svc_req *sr)
908*bbaa8b60SDan Kruchinin {
909*bbaa8b60SDan Kruchinin 
910*bbaa8b60SDan Kruchinin 	/*
911*bbaa8b60SDan Kruchinin 	 * Don't allow blocking for non-monitored (nm_lock) calls.
912*bbaa8b60SDan Kruchinin 	 * These clients don't handle any callbacks, including
913*bbaa8b60SDan Kruchinin 	 * the granted call we make after a blocking lock.
914*bbaa8b60SDan Kruchinin 	 * Same reply callback as nlm4_lock_4_svc
915*bbaa8b60SDan Kruchinin 	 */
916*bbaa8b60SDan Kruchinin 	argp->block = FALSE;
917*bbaa8b60SDan Kruchinin 
918*bbaa8b60SDan Kruchinin 	/* NLM4_NM_LOCK */
919*bbaa8b60SDan Kruchinin 	nlm_do_lock(argp, resp, sr,
920*bbaa8b60SDan Kruchinin 	    nlm4_lock_4_reply, NULL,
921*bbaa8b60SDan Kruchinin 	    NULL); /* indicates non-monitored */
922*bbaa8b60SDan Kruchinin 
923*bbaa8b60SDan Kruchinin 	/* above does its own reply */
924*bbaa8b60SDan Kruchinin 	return (FALSE);
925*bbaa8b60SDan Kruchinin }
926*bbaa8b60SDan Kruchinin 
927*bbaa8b60SDan Kruchinin bool_t
928*bbaa8b60SDan Kruchinin nlm4_free_all_4_svc(nlm4_notify *argp, void *resp, struct svc_req *sr)
929*bbaa8b60SDan Kruchinin {
930*bbaa8b60SDan Kruchinin 	nlm_do_free_all(argp, resp, sr);
931*bbaa8b60SDan Kruchinin 	return (TRUE);
932*bbaa8b60SDan Kruchinin }
933