Print this page
Move CallBack Server thread creation, initial processing and destruction to RPC
Cleanup some RPC code.
Remove extraneous fields from nfs41_cb_info and clean up the code.
Change KM_SLEEP in mir_nfs41_callback_thread to KM_NOSLEEP.
Fix lint warnings
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/rpc/svc.h
+++ new/usr/src/uts/common/rpc/svc.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
|
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 - * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
22 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26 26 /* All Rights Reserved */
27 27 /*
28 28 * Portions of this source code were derived from Berkeley
29 29 * 4.3 BSD under license from the Regents of the University of
30 30 * California.
31 31 */
32 32
33 33 /*
34 34 * svc.h, Server-side remote procedure call interface.
35 35 */
36 36
37 37 #ifndef _RPC_SVC_H
38 38 #define _RPC_SVC_H
39 39
40 40 #include <rpc/rpc_com.h>
41 41 #include <rpc/rpc_msg.h>
42 42 #include <sys/tihdr.h>
43 43 #include <sys/poll.h>
44 44 #include <sys/tsol/label.h>
45 45
46 46 #ifdef _KERNEL
47 47 #include <rpc/svc_auth.h>
48 48 #include <sys/callb.h>
49 49 #include <rpc/rpc_tags.h>
50 50 #endif /* _KERNEL */
51 51
52 52 /*
53 53 * This interface must manage two items concerning remote procedure calling:
54 54 *
55 55 * 1) An arbitrary number of transport connections upon which rpc requests
56 56 * are received. They are created and registered by routines in svc_generic.c,
57 57 * svc_vc.c and svc_dg.c; they in turn call xprt_register and
58 58 * xprt_unregister.
59 59 *
60 60 * 2) An arbitrary number of locally registered services. Services are
61 61 * described by the following four data: program number, version number,
62 62 * "service dispatch" function, a transport handle, and a boolean that
63 63 * indicates whether or not the exported program should be registered with a
64 64 * local binder service; if true the program's number and version and the
65 65 * address from the transport handle are registered with the binder.
66 66 * These data are registered with rpcbind via svc_reg().
67 67 *
68 68 * A service's dispatch function is called whenever an rpc request comes in
69 69 * on a transport. The request's program and version numbers must match
70 70 * those of the registered service. The dispatch function is passed two
71 71 * parameters, struct svc_req * and SVCXPRT *, defined below.
72 72 */
73 73
74 74 #ifdef __cplusplus
75 75 extern "C" {
76 76 #endif
77 77
78 78 /*
79 79 * Server-side transport handles.
80 80 * The actual type definitions are below.
81 81 */
82 82 #ifdef _KERNEL
83 83 typedef struct __svcmasterxprt SVCMASTERXPRT; /* Master transport handle */
84 84 typedef struct __svcxprt SVCXPRT; /* Per-thread clone handle */
85 85 typedef struct __svcpool SVCPOOL; /* Kernel thread pool */
86 86 #else /* _KERNEL */
87 87 typedef struct __svcxprt SVCXPRT; /* Server transport handle */
88 88 #endif /* _KERNEL */
89 89
90 90 /*
91 91 * Prototype of error handler callback
92 92 */
93 93 #ifndef _KERNEL
94 94 typedef void (*svc_errorhandler_t)(const SVCXPRT* svc, const bool_t isAConn);
95 95 #endif
96 96
97 97 /*
98 98 * Service request.
99 99 *
100 100 * PSARC 2003/523 Contract Private Interface
101 101 * svc_req
102 102 * Changes must be reviewed by Solaris File Sharing
103 103 * Changes must be communicated to contract-2003-523@sun.com
104 104 */
105 105 struct svc_req {
106 106 rpcprog_t rq_prog; /* service program number */
107 107 rpcvers_t rq_vers; /* service protocol version */
108 108 rpcproc_t rq_proc; /* the desired procedure */
109 109 struct opaque_auth rq_cred; /* raw creds from the wire */
110 110 caddr_t rq_clntcred; /* read only cooked cred */
111 111 SVCXPRT *rq_xprt; /* associated transport */
112 112 bslabel_t *rq_label; /* TSOL label of the request */
113 113 };
114 114
115 115 #ifdef _KERNEL
116 116 struct dupreq {
117 117 uint32_t dr_xid;
118 118 rpcproc_t dr_proc;
119 119 rpcvers_t dr_vers;
120 120 rpcprog_t dr_prog;
121 121 struct netbuf dr_addr;
122 122 struct netbuf dr_resp;
123 123 void (*dr_resfree)();
124 124 int dr_status;
125 125 struct dupreq *dr_next;
126 126 struct dupreq *dr_chain;
127 127 };
128 128
129 129 /*
130 130 * States of requests for duplicate request caching.
131 131 */
132 132 #define DUP_NEW 0x00 /* new entry */
133 133 #define DUP_INPROGRESS 0x01 /* request already going */
134 134 #define DUP_DONE 0x02 /* request done */
135 135 #define DUP_DROP 0x03 /* request dropped */
136 136 #define DUP_ERROR 0x04 /* error in dup req cache */
137 137
138 138 /*
139 139 * Prototype for a service dispatch routine.
140 140 */
141 141 typedef void (SVC_DISPATCH)(struct svc_req *, SVCXPRT *);
142 142
143 143 /*
144 144 * The service provider callout.
145 145 * Each entry identifies a dispatch routine to be called
146 146 * for a given RPC program number and a version fitting
147 147 * into the registered range.
148 148 */
149 149 typedef struct {
150 150 rpcprog_t sc_prog; /* RPC Program number */
151 151 rpcvers_t sc_versmin; /* Min version number */
152 152 rpcvers_t sc_versmax; /* Max version number */
153 153 SVC_DISPATCH *sc_dispatch; /* Dispatch routine */
154 154 } SVC_CALLOUT;
155 155
156 156 /*
157 157 * Table of service provider `callouts' for an RPC
158 158 * transport handle. If sct_free is TRUE then transport
159 159 * destructor is supposed to deallocate this table.
160 160 */
161 161 typedef struct {
162 162 size_t sct_size; /* Number of entries */
163 163 bool_t sct_free; /* Deallocate if true */
164 164 SVC_CALLOUT *sct_sc; /* Callout entries */
165 165 } SVC_CALLOUT_TABLE;
166 166
167 167 struct svc_ops {
168 168 bool_t (*xp_recv)(SVCXPRT *, mblk_t *, struct rpc_msg *);
169 169 /* receive incoming requests */
170 170 bool_t (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t);
171 171 /* get arguments */
172 172 bool_t (*xp_reply)(SVCXPRT *, struct rpc_msg *);
173 173 /* send reply */
174 174 bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
175 175 /* free mem allocated for args */
176 176 void (*xp_destroy)(SVCMASTERXPRT *);
177 177 /* destroy this struct */
178 178 int (*xp_dup)(struct svc_req *, caddr_t, int,
179 179 struct dupreq **, bool_t *);
180 180 /* check for dup */
181 181 void (*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int);
182 182 /* mark dup entry as completed */
183 183 int32_t *(*xp_getres)(SVCXPRT *, int);
184 184 /* get pointer to response buffer */
185 185 void (*xp_freeres)(SVCXPRT *);
186 186 /* destroy pre-serialized response */
187 187 void (*xp_clone_destroy)(SVCXPRT *);
188 188 /* destroy a clone xprt */
189 189 void (*xp_start)(SVCMASTERXPRT *);
190 190 /* `ready-to-receive' */
191 191 int (*xp_ctl)(SVCXPRT *, int, void *);
192 192 /* kernel level control */
193 193 };
194 194
195 195 /*
196 196 * Kernel SVC Control Requests.
197 197 */
198 198 #define SVCCTL_SET_ASD 1
199 199 #define SVCCTL_GET_ASD 2
200 200 #define SVCCTL_SET_CBCONN 3
201 201 #define SVCCTL_SET_TAG 4
202 202 #define SVCCTL_SET_TAG_CLEAR 5
203 203 #define SVCCTL_CMP_TAG 6
204 204
205 205
206 206 #else /* _KERNEL */
207 207
208 208 /*
209 209 * Service control requests
210 210 */
211 211 #define SVCGET_VERSQUIET 1
212 212 #define SVCSET_VERSQUIET 2
213 213 #define SVCGET_XID 4
214 214 #define SVCSET_KEEPALIVE 5
215 215 #define SVCSET_CONNMAXREC 6
216 216 #define SVCGET_CONNMAXREC 7
217 217 #define SVCGET_RECVERRHANDLER 8
218 218 #define SVCSET_RECVERRHANDLER 9
219 219
220 220 enum xprt_stat {
221 221 XPRT_DIED,
222 222 XPRT_MOREREQS,
223 223 XPRT_IDLE
224 224 };
225 225
226 226 struct xp_ops {
227 227 #ifdef __STDC__
228 228 bool_t (*xp_recv)(SVCXPRT *, struct rpc_msg *);
229 229 /* receive incoming requests */
230 230 enum xprt_stat (*xp_stat)(SVCXPRT *);
231 231 /* get transport status */
232 232 bool_t (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t);
233 233 /* get arguments */
234 234 bool_t (*xp_reply)(SVCXPRT *, struct rpc_msg *);
235 235 /* send reply */
236 236 bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
237 237 /* free mem allocated for args */
238 238 void (*xp_destroy)(SVCXPRT *);
239 239 /* destroy this struct */
240 240 bool_t (*xp_control)(SVCXPRT *, const uint_t, void *);
241 241 /* catch-all control function */
242 242 #else /* __STDC__ */
243 243 bool_t (*xp_recv)(); /* receive incoming requests */
244 244 enum xprt_stat (*xp_stat)(); /* get transport status */
245 245 bool_t (*xp_getargs)(); /* get arguments */
246 246 bool_t (*xp_reply)(); /* send reply */
247 247 bool_t (*xp_freeargs)(); /* free mem allocated for args */
248 248 void (*xp_destroy)(); /* destroy this struct */
249 249 bool_t (*xp_control)(); /* catch-all control function */
250 250 #endif /* __STDC__ */
251 251 };
252 252 #endif /* _KERNEL */
253 253
254 254 #ifdef _KERNEL
255 255 /*
256 256 * SVCPOOL
257 257 * Kernel RPC server-side thread pool structure.
258 258 */
259 259 typedef struct __svcxprt_qnode __SVCXPRT_QNODE; /* Defined in svc.c */
260 260
261 261 struct __svcpool {
262 262 /*
263 263 * Thread pool variables.
264 264 *
265 265 * The pool's thread lock p_thread_lock protects:
266 266 * - p_threads, p_detached_threads, p_reserved_threads and p_closing
267 267 * The pool's request lock protects:
268 268 * - p_asleep, p_drowsy, p_reqs, p_walkers, p_req_cv.
269 269 * The following fields are `initialized constants':
270 270 * - p_id, p_stksize, p_timeout.
271 271 * Access to p_next and p_prev is protected by the pool
272 272 * list lock.
273 273 */
274 274 SVCPOOL *p_next; /* Next pool in the list */
275 275 SVCPOOL *p_prev; /* Prev pool in the list */
276 276 int p_id; /* Pool id */
277 277 int p_threads; /* Non-detached threads */
278 278 int p_detached_threads; /* Detached threads */
279 279 int p_maxthreads; /* Max threads in the pool */
280 280 int p_redline; /* `Redline' for the pool */
281 281 int p_reserved_threads; /* Reserved threads */
282 282 kmutex_t p_thread_lock; /* Thread lock */
283 283 int p_asleep; /* Asleep threads */
284 284 int p_drowsy; /* Drowsy flag */
285 285 kcondvar_t p_req_cv; /* svc_poll() sleep var. */
286 286 clock_t p_timeout; /* svc_poll() timeout */
287 287 kmutex_t p_req_lock; /* Request lock */
288 288 int p_reqs; /* Pending requests */
289 289 int p_walkers; /* Walking threads */
290 290 int p_max_same_xprt; /* Max reqs from the xprt */
291 291 int p_stksize; /* Stack size for svc_run */
292 292 bool_t p_closing : 1; /* Pool is closing */
293 293
294 294 /*
295 295 * Thread creator variables.
296 296 * The `creator signaled' flag is turned on when a signal is send
297 297 * to the creator thread (to create a new service thread). The
298 298 * creator clears when the thread is created. The protocol is not
299 299 * to signal the creator thread when the flag is on. However,
300 300 * a new thread should signal the creator if there are more
301 301 * requests in the queue.
302 302 *
303 303 * When the pool is closing (ie it has been already unregistered from
304 304 * the pool list) the last thread on the last transport should turn
305 305 * the p_creator_exit flag on. This tells the creator thread to
306 306 * free the pool structure and exit.
307 307 */
308 308 bool_t p_creator_signaled : 1; /* Create requested flag */
309 309 bool_t p_creator_exit : 1; /* If true creator exits */
310 310 kcondvar_t p_creator_cv; /* Creator cond. variable */
311 311 kmutex_t p_creator_lock; /* Creator lock */
312 312
313 313 /*
314 314 * Doubly linked list containing `registered' master transport handles.
315 315 * There is no special structure for a list node. Instead the
316 316 * SVCMASTERXPRT structure has the xp_next and xp_prev fields.
317 317 *
318 318 * The p_lrwlock protects access to xprt->xp_next and xprt->xp_prev.
319 319 * A service thread should also acquire a reader lock before accessing
320 320 * any transports it is no longer linked to (to prevent them from
321 321 * being destroyed).
322 322 *
323 323 * The list lock governs also the `pool is closing' flag.
324 324 */
325 325 size_t p_lcount; /* Current count */
326 326 SVCMASTERXPRT *p_lhead; /* List head */
327 327 krwlock_t p_lrwlock; /* R/W lock */
328 328
329 329 /*
330 330 * Circular linked list for the `xprt-ready' queue (FIFO).
331 331 * Must be initialized with svc_xprt_qinit() before it is used.
332 332 *
333 333 * The writer's end is protected by the pool's request lock
334 334 * (pool->p_req_lock). The reader's end is protected by q_end_lock.
335 335 *
336 336 * When the queue is full the p_qoverflow flag is raised. It stays
337 337 * on until all the pending request are drained.
338 338 */
339 339 size_t p_qsize; /* Number of queue nodes */
340 340 int p_qoverflow : 1; /* Overflow flag */
341 341 __SVCXPRT_QNODE *p_qbody; /* Queue body (array) */
342 342 __SVCXPRT_QNODE *p_qtop; /* Writer's end of FIFO */
343 343 __SVCXPRT_QNODE *p_qend; /* Reader's end of FIFO */
344 344 kmutex_t p_qend_lock; /* Reader's end lock */
345 345
346 346 /*
347 347 * Userspace thread creator variables.
348 348 * Thread creation is actually done in userland, via a thread
349 349 * that is parked in the kernel. When that thread is signaled,
350 350 * it returns back down to the daemon from whence it came and
351 351 * does the lwp create.
352 352 *
353 353 * A parallel "creator" thread runs in the kernel. That is the
354 354 * thread that will signal for the user thread to return to
355 355 * userland and do its work.
356 356 *
357 357 * Since the thread doesn't always exist (there could be a race
358 358 * if two threads are created in rapid succession), we set
359 359 * p_signal_create_thread to FALSE when we're ready to accept work.
360 360 *
361 361 * p_user_exit is set to true when the service pool is about
362 362 * to close. This is done so that the user creation thread
363 363 * can be informed and cleanup any userland state.
364 364 */
365 365
366 366 bool_t p_signal_create_thread : 1; /* Create requested flag */
367 367 bool_t p_user_exit : 1; /* If true creator exits */
368 368 bool_t p_user_waiting : 1; /* Thread waiting for work */
369 369 kcondvar_t p_user_cv; /* Creator cond. variable */
370 370 kmutex_t p_user_lock; /* Creator lock */
371 371 void (*p_offline)(); /* callout for unregister */
372 372 void (*p_shutdown)(); /* callout for shutdown */
373 373 };
374 374
375 375 /*
376 376 * Server side transport handle (SVCMASTERXPRT).
377 377 * xprt->xp_req_lock governs the following fields in xprt:
378 378 * xp_req_head, xp_req_tail.
379 379 * xprt->xp_thread_lock governs the following fields in xprt:
380 380 * xp_threads, xp_detached_threads.
381 381 *
382 382 * xp_req_tail is only valid if xp_req_head is non-NULL
383 383 *
384 384 * The xp_threads count is the number of attached threads. These threads
385 385 * are able to handle new requests, and it is expected that they will not
386 386 * block for a very long time handling a given request. The
387 387 * xp_detached_threads count is the number of threads that have detached
388 388 * themselves from the transport. These threads can block indefinitely
389 389 * while handling a request. Once they complete the request, they exit.
390 390 *
391 391 * A kernel service provider may register a callback function "closeproc"
392 392 * for a transport. When the transport is closing the last exiting attached
393 393 * thread - xp_threads goes to zero - it calls the callback function, passing
394 394 * it a reference to the transport. This call is made with xp_thread_lock
395 395 * held, so any cleanup bookkeeping it does should be done quickly.
396 396 *
397 397 * When the transport is closing the last exiting thread is supposed
398 398 * to destroy/free the data structure.
399 399 */
400 400 typedef struct __svcxprt_common {
401 401 struct file *xpc_fp;
402 402 struct svc_ops *xpc_ops;
403 403 queue_t *xpc_wq; /* queue to write onto */
404 404 cred_t *xpc_cred; /* cached cred 4 server's use */
405 405 int32_t xpc_type; /* transport type */
406 406 int xpc_msg_size; /* TSDU or TIDU size */
407 407 struct netbuf xpc_rtaddr; /* remote transport address */
408 408 struct netbuf xpc_lcladdr; /* local transport address */
409 409 void *xpc_tags; /* xprt's tag list */
410 410 SVC_CALLOUT_TABLE *xpc_sct;
411 411 } __SVCXPRT_COMMON;
412 412
413 413 #define xp_fp xp_xpc.xpc_fp
414 414 #define xp_ops xp_xpc.xpc_ops
415 415 #define xp_wq xp_xpc.xpc_wq
416 416 #define xp_cred xp_xpc.xpc_cred
417 417 #define xp_type xp_xpc.xpc_type
418 418 #define xp_msg_size xp_xpc.xpc_msg_size
419 419 #define xp_rtaddr xp_xpc.xpc_rtaddr
420 420 #define xp_lcladdr xp_xpc.xpc_lcladdr
421 421 #define xp_sct xp_xpc.xpc_sct
422 422 #define xp_tags xp_xpc.xpc_tags
423 423
424 424 struct __svcmasterxprt {
425 425 SVCMASTERXPRT *xp_next; /* Next transport in the list */
426 426 SVCMASTERXPRT *xp_prev; /* Prev transport in the list */
427 427 __SVCXPRT_COMMON xp_xpc; /* Fields common with the clone */
428 428 SVCPOOL *xp_pool; /* Pointer to the pool */
429 429 mblk_t *xp_req_head; /* Request queue head */
430 430 mblk_t *xp_req_tail; /* Request queue tail */
431 431 kmutex_t xp_req_lock; /* Request lock */
432 432 int xp_threads; /* Current num. of attached threads */
|
↓ open down ↓ |
400 lines elided |
↑ open up ↑ |
433 433 int xp_detached_threads; /* num. of detached threads */
434 434 kmutex_t xp_thread_lock; /* Thread count lock */
435 435 void (*xp_closeproc)(const SVCMASTERXPRT *);
436 436 /* optional; see comments above */
437 437 char *xp_netid; /* network token */
438 438 struct netbuf xp_addrmask; /* address mask */
439 439
440 440 caddr_t xp_p2; /* private: for use by svc ops */
441 441 };
442 442
443 -#define SVCCB_DEAD 1 /* This callback is dead, don't accept on it */
443 +#define SVCCB_NFS41_CB_THREAD_EXIT 0x01
444 444
445 445 typedef struct __svccb {
446 446 queue_t *r_q;
447 447 mblk_t *r_mp;
448 448 kmutex_t r_lock;
449 - kmutex_t r_mlock;
450 449 kcondvar_t r_cbwait;
450 + kcondvar_t r_cbexit;
451 451 int r_flags;
452 452 rpcprog_t r_prog;
453 + kthread_t *r_thread;
454 + SVC_DISPATCH *r_dispatch;
453 455 } SVCCB;
454 456
455 457 typedef struct __svccb_args {
456 458 SVCMASTERXPRT *xprt;
457 459 rpcprog_t prog;
458 460 rpcvers_t vers;
459 461 int family;
460 462 void *tag;
461 463 } SVCCB_ARGS;
462 464
465 +typedef struct __cbserver_args {
466 + SVC_DISPATCH *callback;
467 + rpcprog_t prog;
468 +} CBSERVER_ARGS;
463 469
464 470 /*
465 471 * Service thread `clone' transport handle (SVCXPRT)
466 472 *
467 473 * PSARC 2003/523 Contract Private Interface
468 474 * SVCXPRT
469 475 * Changes must be reviewed by Solaris File Sharing
470 476 * Changes must be communicated to contract-2003-523@sun.com
471 477 *
472 478 * The xp_p2buf buffer is used as the storage for a transport type
473 479 * specific structure. It is private for the svc ops for a given
474 480 * transport type.
475 481 */
476 482
477 483 #define SVC_P2LEN 128
478 484
479 485 struct __svcxprt {
480 486 __SVCXPRT_COMMON xp_xpc;
481 487 SVCMASTERXPRT *xp_master; /* back ptr to master */
482 488
483 489 /* The following fileds are on a per-thread basis */
484 490 callb_cpr_t *xp_cprp; /* unused padding for Contract */
485 491 bool_t xp_reserved : 1; /* is thread reserved? */
486 492 bool_t xp_detached : 1; /* is thread detached? */
487 493 int xp_same_xprt; /* Reqs from the same xprt */
488 494
489 495 /* The following fields are used on a per-request basis */
490 496 struct opaque_auth xp_verf; /* raw response verifier */
491 497 SVCAUTH xp_auth; /* auth flavor of current req */
492 498 void *xp_cookie; /* a cookie */
493 499 uint32_t xp_xid; /* id */
494 500 XDR xp_xdrin; /* input xdr stream */
495 501 XDR xp_xdrout; /* output xdr stream */
496 502
497 503 /* Private for svc ops */
498 504 char xp_p2buf[SVC_P2LEN]; /* udp_data or cots_data_t */
499 505 /* or clone_rdma_data_t */
500 506 void *xp_asd;
501 507 };
502 508 #else /* _KERNEL */
503 509 struct __svcxprt {
504 510 int xp_fd;
505 511 #define xp_sock xp_fd
506 512 ushort_t xp_port;
507 513 /*
508 514 * associated port number.
509 515 * Obsolete, but still used to
510 516 * specify whether rendezvouser
511 517 * or normal connection
512 518 */
513 519 struct xp_ops *xp_ops;
514 520 int xp_addrlen; /* length of remote addr. Obsoleted */
515 521 char *xp_tp; /* transport provider device name */
516 522 char *xp_netid; /* network token */
517 523 struct netbuf xp_ltaddr; /* local transport address */
518 524 struct netbuf xp_rtaddr; /* remote transport address */
519 525 char xp_raddr[16]; /* remote address. Now obsoleted */
520 526 struct opaque_auth xp_verf; /* raw response verifier */
521 527 caddr_t xp_p1; /* private: for use by svc ops */
522 528 caddr_t xp_p2; /* private: for use by svc ops */
523 529 caddr_t xp_p3; /* private: for use by svc lib */
524 530 int xp_type; /* transport type */
525 531 /*
526 532 * callback on client death
527 533 * First parameter is the current structure,
528 534 * Second parameter :
529 535 * - FALSE for the service listener
530 536 * - TRUE for a real connected socket
531 537 */
532 538 svc_errorhandler_t xp_closeclnt;
533 539 };
534 540
535 541 #endif /* _KERNEL */
536 542
537 543 /*
538 544 * Approved way of getting address of caller,
539 545 * address mask, and netid of transport.
540 546 */
541 547 #define svc_getrpccaller(x) (&(x)->xp_rtaddr)
542 548 #ifdef _KERNEL
543 549 #define svc_getendpoint(x) (&(x)->xp_lcladdr.buf)
544 550 #define svc_getcaller(x) (&(x)->xp_rtaddr.buf)
545 551 #define svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask)
546 552 #define svc_getnetid(x) ((x)->xp_master->xp_netid)
547 553 #endif /* _KERNEL */
548 554
549 555 /*
550 556 * Operations defined on an SVCXPRT handle
551 557 */
552 558
553 559 #ifdef _KERNEL
554 560 #define SVC_RECV(clone_xprt, mp, msg) \
555 561 (*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg))
556 562
557 563 /*
558 564 * PSARC 2003/523 Contract Private Interface
559 565 * SVC_GETARGS
560 566 * Changes must be reviewed by Solaris File Sharing
561 567 * Changes must be communicated to contract-2003-523@sun.com
562 568 */
563 569 #define SVC_GETARGS(clone_xprt, xargs, argsp) \
564 570 (*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp))
565 571
566 572 #define SVC_REPLY(clone_xprt, msg) \
567 573 (*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg))
568 574
569 575 #define SVC_FREEARGS(clone_xprt, xargs, argsp) \
570 576 (*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp))
571 577
572 578 #define SVC_GETRES(clone_xprt, size) \
573 579 (*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size))
574 580
575 581 #define SVC_FREERES(clone_xprt) \
576 582 (*(clone_xprt)->xp_ops->xp_freeres)(clone_xprt)
577 583
578 584 #define SVC_DESTROY(xprt) \
579 585 (*(xprt)->xp_ops->xp_destroy)(xprt)
580 586
581 587 /*
582 588 * PSARC 2003/523 Contract Private Interfaces
583 589 * SVC_DUP, SVC_DUPDONE, SVC_DUP_EXT, SVC_DUPDONE_EXT
584 590 * Changes must be reviewed by Solaris File Sharing
585 591 * Changes must be communicated to contract-2003-523@sun.com
586 592 *
587 593 * SVC_DUP and SVC_DUPDONE are defined here for backward compatibility.
588 594 */
589 595 #define SVC_DUP_EXT(clone_xprt, req, res, size, drpp, dupcachedp) \
590 596 (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, dupcachedp)
591 597
592 598 #define SVC_DUPDONE_EXT(clone_xprt, dr, res, resfree, size, status) \
593 599 (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, resfree, size, status)
594 600
595 601 #define SVC_DUP(clone_xprt, req, res, size, drpp) \
596 602 (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, NULL)
597 603
598 604 #define SVC_DUPDONE(clone_xprt, dr, res, size, status) \
599 605 (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, NULL, size, status)
600 606
601 607 #define SVC_CLONE_DESTROY(clone_xprt) \
602 608 (*(clone_xprt)->xp_ops->xp_clone_destroy)(clone_xprt)
603 609
604 610
605 611 #define SVC_START(xprt) \
606 612 (*(xprt)->xp_ops->xp_start)(xprt)
607 613
608 614 #define SVC_CTL(clone_xprt, rq, arg) \
609 615 (*(clone_xprt)->xp_ops->xp_ctl)((clone_xprt), (rq), (arg))
610 616
611 617 #else /* _KERNEL */
612 618
613 619 #define SVC_RECV(xprt, msg) \
614 620 (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
615 621 #define svc_recv(xprt, msg) \
616 622 (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
617 623
618 624 #define SVC_STAT(xprt) \
619 625 (*(xprt)->xp_ops->xp_stat)(xprt)
620 626 #define svc_stat(xprt) \
621 627 (*(xprt)->xp_ops->xp_stat)(xprt)
622 628
623 629 #define SVC_GETARGS(xprt, xargs, argsp) \
624 630 (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
625 631 #define svc_getargs(xprt, xargs, argsp) \
626 632 (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
627 633
628 634 #define SVC_REPLY(xprt, msg) \
629 635 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
630 636 #define svc_reply(xprt, msg) \
631 637 (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
632 638
633 639 #define SVC_FREEARGS(xprt, xargs, argsp) \
634 640 (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
635 641 #define svc_freeargs(xprt, xargs, argsp) \
636 642 (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
637 643
638 644 #define SVC_GETRES(xprt, size) \
639 645 (*(xprt)->xp_ops->xp_getres)((xprt), (size))
640 646 #define svc_getres(xprt, size) \
641 647 (*(xprt)->xp_ops->xp_getres)((xprt), (size))
642 648
643 649 #define SVC_FREERES(xprt) \
644 650 (*(xprt)->xp_ops->xp_freeres)(xprt)
645 651 #define svc_freeres(xprt) \
646 652 (*(xprt)->xp_ops->xp_freeres)(xprt)
647 653
648 654 #define SVC_DESTROY(xprt) \
649 655 (*(xprt)->xp_ops->xp_destroy)(xprt)
650 656 #define svc_destroy(xprt) \
651 657 (*(xprt)->xp_ops->xp_destroy)(xprt)
652 658
653 659 /*
654 660 * PSARC 2003/523 Contract Private Interface
655 661 * SVC_CONTROL
656 662 * Changes must be reviewed by Solaris File Sharing
657 663 * Changes must be communicated to contract-2003-523@sun.com
658 664 */
659 665 #define SVC_CONTROL(xprt, rq, in) \
660 666 (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in))
661 667 #endif /* _KERNEL */
662 668
663 669 /*
664 670 * Pool id's reserved for NFS, NLM, the NFSv4 callback program and DSERV.
665 671 */
666 672 #define NFS_SVCPOOL_ID 0x01
667 673 #define NLM_SVCPOOL_ID 0x02
668 674 #define NFS_CB_SVCPOOL_ID 0x03
669 675 #define RDC_SVCPOOL_ID 0x05 /* SNDR, PSARC 2001/699 */
670 676 #define DSERV_SVCPOOL_ID 0x06
671 677 #define UNIQUE_SVCPOOL_ID 0x07 /* MUST be largest value here */
672 678
673 679 struct svcpool_args {
674 680 uint32_t id; /* Pool id */
675 681 uint32_t maxthreads; /* Max threads in the pool */
676 682 uint32_t redline; /* `Redline' for the pool */
677 683 uint32_t qsize; /* `xprt-ready' queue size */
678 684 uint32_t timeout; /* svc_poll() timeout */
679 685 uint32_t stksize; /* svc_run() stack size */
680 686 uint32_t max_same_xprt; /* Max reqs from the same xprt */
681 687 };
682 688
683 689
684 690 #ifdef _KERNEL
685 691 /*
686 692 * Transport registration and thread pool creation.
687 693 */
688 694 extern int svc_xprt_register(SVCMASTERXPRT *, int);
689 695 extern void svc_xprt_unregister(SVCMASTERXPRT *);
690 696 extern int svc_pool_create(struct svcpool_args *);
691 697 extern int svc_wait(int);
692 698 extern int svc_do_run(int);
693 699 #define SVCPSET_SHUTDOWN_PROC 1
694 700 #define SVCPSET_UNREGISTER_PROC 2
695 701 extern int svc_pool_control(int, int, void *);
696 702 #else /* _KERNEL */
697 703 #ifdef __STDC__
698 704 extern bool_t rpc_reg(const rpcprog_t, const rpcvers_t, const rpcproc_t,
699 705 char *(*)(char *), const xdrproc_t, const xdrproc_t,
700 706 const char *);
701 707
702 708 /*
703 709 * Service registration
704 710 *
705 711 * svc_reg(xprt, prog, vers, dispatch, nconf)
706 712 * const SVCXPRT *xprt;
707 713 * const rpcprog_t prog;
708 714 * const rpcvers_t vers;
709 715 * const void (*dispatch)();
710 716 * const struct netconfig *nconf;
711 717 */
712 718 extern bool_t svc_reg(const SVCXPRT *, const rpcprog_t, const rpcvers_t,
713 719 void (*)(struct svc_req *, SVCXPRT *),
714 720 const struct netconfig *);
715 721
716 722 /*
717 723 * Service authentication registration
718 724 *
719 725 * svc_auth_reg(cred_flavor, handler)
720 726 * int cred_flavor;
721 727 * enum auth_stat (*handler)();
722 728 */
723 729 extern int svc_auth_reg(int, enum auth_stat (*)());
724 730
725 731 /*
726 732 * Service un-registration
727 733 *
728 734 * svc_unreg(prog, vers)
729 735 * const rpcprog_t prog;
730 736 * const rpcvers_t vers;
731 737 */
732 738 extern void svc_unreg(const rpcprog_t, const rpcvers_t);
733 739
734 740 /*
735 741 * Transport registration/unregistration.
736 742 *
737 743 * xprt_register(xprt)
738 744 * const SVCXPRT *xprt;
739 745 *
740 746 * xprt_unregister(xprt)
741 747 * const SVCXPRT *xprt;
742 748 */
743 749 extern void xprt_register(const SVCXPRT *);
744 750 extern void xprt_unregister(const SVCXPRT *);
745 751 #else /* __STDC__ */
746 752 extern bool_t rpc_reg();
747 753 extern bool_t svc_reg();
748 754 extern bool_t svc_auth_reg();
749 755 extern void svc_unreg();
750 756 extern void xprt_register();
751 757 extern void xprt_unregister();
752 758 #endif /* __STDC__ */
753 759 #endif /* _KERNEL */
754 760
755 761
756 762 /*
757 763 * When the service routine is called, it must first check to see if it
758 764 * knows about the procedure; if not, it should call svcerr_noproc
759 765 * and return. If so, it should deserialize its arguments via
760 766 * SVC_GETARGS (defined above). If the deserialization does not work,
761 767 * svcerr_decode should be called followed by a return. Successful
762 768 * decoding of the arguments should be followed the execution of the
763 769 * procedure's code and a call to svc_sendreply.
764 770 *
765 771 * Also, if the service refuses to execute the procedure due to too-
766 772 * weak authentication parameters, svcerr_weakauth should be called.
767 773 * Note: do not confuse access-control failure with weak authentication!
768 774 *
769 775 * NB: In pure implementations of rpc, the caller always waits for a reply
770 776 * msg. This message is sent when svc_sendreply is called.
771 777 * Therefore pure service implementations should always call
772 778 * svc_sendreply even if the function logically returns void; use
773 779 * xdr.h - xdr_void for the xdr routine. HOWEVER, connectionful rpc allows
774 780 * for the abuse of pure rpc via batched calling or pipelining. In the
775 781 * case of a batched call, svc_sendreply should NOT be called since
776 782 * this would send a return message, which is what batching tries to avoid.
777 783 * It is the service/protocol writer's responsibility to know which calls are
778 784 * batched and which are not. Warning: responding to batch calls may
779 785 * deadlock the caller and server processes!
780 786 */
781 787 #ifdef __STDC__
782 788 extern bool_t svc_sendreply(const SVCXPRT *, const xdrproc_t, const caddr_t);
783 789 extern void svcerr_decode(const SVCXPRT *);
784 790 extern void svcerr_weakauth(const SVCXPRT *);
785 791 extern void svcerr_noproc(const SVCXPRT *);
786 792 extern SVCXPRT *svc_clone_init(void);
787 793 extern void svc_init_clone_xprt(SVCXPRT *, queue_t *);
788 794 extern void svcerr_progvers(const SVCXPRT *, const rpcvers_t,
789 795 const rpcvers_t);
790 796 extern void svcerr_auth(const SVCXPRT *, const enum auth_stat);
791 797 extern void svcerr_noprog(const SVCXPRT *);
792 798 extern void svcerr_systemerr(const SVCXPRT *);
793 799 extern void svcerr_badcred(const SVCXPRT *);
794 800 #else /* __STDC__ */
795 801 extern bool_t svc_sendreply();
796 802 extern void svcerr_decode();
797 803 extern void svcerr_weakauth();
798 804 extern void svcerr_noproc();
799 805 extern void svc_init_clone_xprt();
800 806 extern SVCXPRT *svc_clone_init();
801 807 extern void svcerr_progvers();
802 808 extern void svcerr_auth();
803 809 extern void svcerr_noprog();
804 810 extern void svcerr_systemerr();
805 811 extern void svcerr_badcred();
806 812 #endif /* __STDC__ */
807 813
808 814 #ifdef _KERNEL
809 815 /*
810 816 * Kernel RPC functions.
811 817 */
812 818 extern void svc_init(void);
813 819 extern void svc_cots_init(void);
814 820 extern void svc_clts_init(void);
815 821 extern void mt_kstat_init(void);
816 822 extern void mt_kstat_fini(void);
817 823 extern int svc_tli_kcreate(struct file *, uint_t, char *,
818 824 struct netbuf *, SVCMASTERXPRT **,
819 825 SVC_CALLOUT_TABLE *,
820 826 void (*closeproc)(const SVCMASTERXPRT *),
821 827 int, bool_t);
822 828 extern int svc_clts_kcreate(struct file *, uint_t, struct T_info_ack *,
823 829 SVCMASTERXPRT **);
824 830 extern int svc_cots_kcreate(struct file *, uint_t, struct T_info_ack *,
825 831 SVCMASTERXPRT **);
826 832 extern void svc_queuereq(queue_t *, mblk_t *);
827 833 extern void svc_queueclean(queue_t *);
828 834 extern void svc_queueclose(queue_t *);
829 835 extern int svc_reserve_thread(SVCXPRT *);
830 836 extern void svc_unreserve_thread(SVCXPRT *);
831 837 extern callb_cpr_t *svc_detach_thread(SVCXPRT *);
832 838
833 839 /*
834 840 * For RDMA based kRPC.
835 841 * "rdma_xprt_record" is a reference to master transport handles
836 842 * in kRPC thread pools. This is an easy way of tracking and shuting
837 843 * down rdma based kRPC transports on demand.
838 844 * "rdma_xprt_group" is a list of RDMA based mster transport handles
839 845 * or records in a kRPC thread pool.
840 846 */
841 847 typedef struct rdma_xprt_record rdma_xprt_record_t;
842 848 struct rdma_xprt_record {
843 849 int rtr_type; /* Type of rdma; IB/VI/RDDP */
844 850 SVCMASTERXPRT *rtr_xprt_ptr; /* Ptr to master xprt handle */
845 851 rdma_xprt_record_t *rtr_next; /* Ptr to next record */
846 852 };
847 853
848 854 typedef struct {
849 855 int rtg_count; /* Number transport records */
850 856 int rtg_poolid; /* Pool Id for this group */
851 857 rdma_xprt_record_t *rtg_listhead; /* Head of the records list */
852 858 } rdma_xprt_group_t;
853 859
854 860 extern int svc_rdma_kcreate(char *, SVC_CALLOUT_TABLE *, int,
855 861 rdma_xprt_group_t *);
856 862 extern void svc_rdma_kstop(SVCMASTERXPRT *);
857 863 extern void svc_rdma_kdestroy(SVCMASTERXPRT *);
858 864 extern void rdma_stop(rdma_xprt_group_t);
859 865
860 866 /*
861 867 * GSS cleanup method.
862 868 */
863 869 extern void rpc_gss_cleanup(SVCXPRT *);
864 870 #else /* _KERNEL */
865 871 /*
866 872 * Lowest level dispatching -OR- who owns this process anyway.
867 873 * Somebody has to wait for incoming requests and then call the correct
868 874 * service routine. The routine svc_run does infinite waiting; i.e.,
869 875 * svc_run never returns.
870 876 * Since another (co-existant) package may wish to selectively wait for
871 877 * incoming calls or other events outside of the rpc architecture, the
872 878 * routine svc_getreq_poll is provided. It must be passed pollfds, the
873 879 * "in-place" results of a poll call (see poll, section 2).
874 880 */
875 881
876 882 /*
877 883 * Global keeper of rpc service descriptors in use
878 884 * dynamic; must be inspected before each call to select or poll
879 885 */
880 886 extern pollfd_t *svc_pollfd;
881 887 extern int svc_max_pollfd;
882 888 extern fd_set svc_fdset;
883 889 #if !defined(_LP64) && FD_SETSIZE > 1024
884 890 extern fd_set _new_svc_fdset;
885 891 #ifdef __PRAGMA_REDEFINE_EXTNAME
886 892 #pragma redefine_extname svc_fdset _new_svc_fdset
887 893 #else /* __PRAGMA_REDEFINE_EXTNAME */
888 894 #define svc_fdset _new_svc_fdset
889 895 #endif /* __PRAGMA_REDEFINE_EXTNAME */
890 896 #endif /* LP64 && FD_SETSIZE > 1024 */
891 897 #define svc_fds svc_fdset.fds_bits[0] /* compatibility */
892 898
893 899 /*
894 900 * A small program implemented by the svc_rpc implementation itself.
895 901 * Also see clnt.h for protocol numbers.
896 902 */
897 903 #ifdef __STDC__
898 904 extern void svc_getreq(int);
899 905 extern void svc_getreq_common(const int);
900 906 extern void svc_getreqset(fd_set *); /* takes fdset instead of int */
901 907 extern void svc_getreq_poll(struct pollfd *, const int);
902 908 extern void svc_run(void);
903 909 extern void svc_exit(void);
904 910 #else /* __STDC__ */
905 911 extern void rpctest_service();
906 912 extern void svc_getreqset();
907 913 extern void svc_getreq();
908 914 extern void svc_getreq_common();
909 915 extern void svc_getreqset(); /* takes fdset instead of int */
910 916 extern void svc_getreq_poll();
911 917 extern void svc_run();
912 918 extern void svc_exit();
913 919 #endif /* __STDC__ */
914 920
915 921 /*
916 922 * Functions used to manage user file descriptors
917 923 */
918 924 typedef int svc_input_id_t;
919 925 typedef void (*svc_callback_t)(svc_input_id_t id, int fd,
920 926 unsigned int events, void* cookie);
921 927
922 928 #ifdef __STDC__
923 929 extern svc_input_id_t svc_add_input(int fd, unsigned int events,
924 930 svc_callback_t user_callback,
925 931 void* cookie);
926 932 extern int svc_remove_input(svc_input_id_t id);
927 933 #else /* __STDC__ */
928 934 extern svc_input_id_t svc_add_input();
929 935 extern int svc_remove_input();
930 936 #endif
931 937
932 938 /*
933 939 * These are the existing service side transport implementations.
934 940 *
935 941 * Transport independent svc_create routine.
936 942 */
937 943 #ifdef __STDC__
938 944 extern int svc_create(void (*)(struct svc_req *, SVCXPRT *),
939 945 const rpcprog_t, const rpcvers_t,
940 946 const char *);
941 947 /*
942 948 * void (*dispatch)(); -- dispatch routine
943 949 * const rpcprog_t prognum; -- program number
944 950 * const rpcvers_t versnum; -- version number
945 951 * const char *nettype; -- network type
946 952 */
947 953
948 954 /*
949 955 * Generic server creation routine. It takes a netconfig structure
950 956 * instead of a nettype.
951 957 */
952 958 extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
953 959 const rpcprog_t, const rpcvers_t,
954 960 const struct netconfig *);
955 961 /*
956 962 * void (*dispatch)(); -- dispatch routine
957 963 * const rpcprog_t prognum; -- program number
958 964 * const rpcvers_t versnum; -- version number
959 965 * const struct netconfig *nconf; -- netconfig structure
960 966 */
961 967
962 968 /*
963 969 * Generic TLI create routine
964 970 */
965 971 extern SVCXPRT *svc_tli_create(const int, const struct netconfig *,
966 972 const struct t_bind *, const uint_t,
967 973 const uint_t);
968 974 /*
969 975 * const int fd; -- connection end point
970 976 * const struct netconfig *nconf; -- netconfig structure
971 977 * const struct t_bind *bindaddr; -- local bind address
972 978 * const uint_t sendsz; -- max sendsize
973 979 * const uint_t recvsz; -- max recvsize
974 980 */
975 981
976 982 /*
977 983 * Connectionless and connectionful create routines.
978 984 */
979 985 extern SVCXPRT *svc_vc_create(const int, const uint_t, const uint_t);
980 986 /*
981 987 * const int fd; -- open connection end point
982 988 * const uint_t sendsize; -- max send size
983 989 * const uint_t recvsize; -- max recv size
984 990 */
985 991
986 992 extern SVCXPRT *svc_dg_create(const int, const uint_t, const uint_t);
987 993 /*
988 994 * const int fd; -- open connection
989 995 * const uint_t sendsize; -- max send size
990 996 * const uint_t recvsize; -- max recv size
991 997 */
992 998
993 999 /*
994 1000 * the routine takes any *open* TLI file
995 1001 * descriptor as its first input and is used for open connections.
996 1002 */
997 1003 extern SVCXPRT *svc_fd_create(const int, const uint_t, const uint_t);
998 1004 /*
999 1005 * const int fd; -- open connection end point
1000 1006 * const uint_t sendsize; -- max send size
1001 1007 * const uint_t recvsize; -- max recv size
1002 1008 */
1003 1009
1004 1010 /*
1005 1011 * Memory based rpc (for speed check and testing)
1006 1012 */
1007 1013 extern SVCXPRT *svc_raw_create(void);
1008 1014
1009 1015 /*
1010 1016 * Creation of service over doors transport.
1011 1017 */
1012 1018 extern SVCXPRT *svc_door_create(void (*)(struct svc_req *, SVCXPRT *),
1013 1019 const rpcprog_t, const rpcvers_t,
1014 1020 const uint_t);
1015 1021 /*
1016 1022 * void (*dispatch)(); -- dispatch routine
1017 1023 * const rpcprog_t prognum; -- program number
1018 1024 * const rpcvers_t versnum; -- version number
1019 1025 * const uint_t sendsize; -- send buffer size
1020 1026 */
1021 1027
1022 1028 /*
1023 1029 * Service control interface
1024 1030 */
1025 1031 extern bool_t svc_control(SVCXPRT *, const uint_t, void *);
1026 1032 /*
1027 1033 * SVCXPRT *svc; -- service to manipulate
1028 1034 * const uint_t req; -- request
1029 1035 * void *info; -- argument to request
1030 1036 */
1031 1037
1032 1038 /*
1033 1039 * svc_dg_enable_cache() enables the cache on dg transports.
1034 1040 */
1035 1041 extern int svc_dg_enablecache(SVCXPRT *, const uint_t);
1036 1042 #else /* __STDC__ */
1037 1043 extern int svc_create();
1038 1044 extern SVCXPRT *svc_tp_create();
1039 1045 extern SVCXPRT *svc_tli_create();
1040 1046 extern SVCXPRT *svc_vc_create();
1041 1047 extern SVCXPRT *svc_dg_create();
1042 1048 extern SVCXPRT *svc_fd_create();
1043 1049 extern SVCXPRT *svc_raw_create();
1044 1050 extern SVCXPRT *svc_door_create();
1045 1051 extern int svc_dg_enablecache();
1046 1052 #endif /* __STDC__ */
1047 1053
1048 1054 extern boolean_t is_multilevel(rpcprog_t);
1049 1055
1050 1056 #ifdef PORTMAP
1051 1057 /* For backward compatibility */
1052 1058 #include <rpc/svc_soc.h>
1053 1059 #endif /* PORTMAP */
1054 1060
1055 1061 /*
1056 1062 * For user level MT hot server functions
1057 1063 */
1058 1064
1059 1065 /*
1060 1066 * Different MT modes
1061 1067 */
1062 1068 #define RPC_SVC_MT_NONE 0 /* default, single-threaded */
1063 1069 #define RPC_SVC_MT_AUTO 1 /* automatic MT mode */
1064 1070 #define RPC_SVC_MT_USER 2 /* user MT mode */
1065 1071
1066 1072 #ifdef __STDC__
1067 1073 extern void svc_done(SVCXPRT *);
1068 1074 #else
1069 1075 extern void svc_done();
1070 1076 #endif /* __STDC__ */
1071 1077
1072 1078 /*
1073 1079 * Obtaining local credentials.
1074 1080 */
1075 1081 typedef struct __svc_local_cred_t {
1076 1082 uid_t euid; /* effective uid */
1077 1083 gid_t egid; /* effective gid */
1078 1084 uid_t ruid; /* real uid */
1079 1085 gid_t rgid; /* real gid */
1080 1086 pid_t pid; /* caller's pid, or -1 if not available */
1081 1087 } svc_local_cred_t;
1082 1088
1083 1089 #ifdef __STDC__
1084 1090 struct ucred_s;
1085 1091 extern void svc_fd_negotiate_ucred(int);
1086 1092 extern int svc_getcallerucred(const SVCXPRT *, struct ucred_s **);
1087 1093 extern bool_t svc_get_local_cred(SVCXPRT *, svc_local_cred_t *);
1088 1094 #else
1089 1095 extern void svc_fd_negotiate_ucred();
1090 1096 extern int svc_getcallerucred();
1091 1097 extern bool_t svc_get_local_cred();
1092 1098 #endif /* __STDC__ */
1093 1099
1094 1100 /*
1095 1101 * Private interfaces and structures for user level duplicate request caching.
1096 1102 * The interfaces and data structures are not committed and subject to
1097 1103 * change in future releases. Currently only intended for use by automountd.
1098 1104 */
1099 1105 struct dupreq {
1100 1106 uint32_t dr_xid;
1101 1107 rpcproc_t dr_proc;
1102 1108 rpcvers_t dr_vers;
1103 1109 rpcprog_t dr_prog;
1104 1110 struct netbuf dr_addr;
1105 1111 struct netbuf dr_resp;
1106 1112 int dr_status;
1107 1113 time_t dr_time;
1108 1114 uint_t dr_hash;
1109 1115 struct dupreq *dr_next;
1110 1116 struct dupreq *dr_prev;
1111 1117 struct dupreq *dr_chain;
1112 1118 struct dupreq *dr_prevchain;
1113 1119 };
1114 1120
1115 1121 /*
1116 1122 * The fixedtime state is defined if we want to expand the routines to
1117 1123 * handle and encompass fixed size caches.
1118 1124 */
1119 1125 #define DUPCACHE_FIXEDTIME 0
1120 1126
1121 1127 /*
1122 1128 * States of requests for duplicate request caching.
1123 1129 * These are the same as defined for the kernel.
1124 1130 */
1125 1131 #define DUP_NEW 0x00 /* new entry */
1126 1132 #define DUP_INPROGRESS 0x01 /* request already going */
1127 1133 #define DUP_DONE 0x02 /* request done */
1128 1134 #define DUP_DROP 0x03 /* request dropped */
1129 1135 #define DUP_ERROR 0x04 /* error in dup req cache */
1130 1136
1131 1137 #ifdef __STDC__
1132 1138 extern bool_t __svc_dupcache_init(void *, int, char **);
1133 1139 extern int __svc_dup(struct svc_req *, caddr_t *, uint_t *, char *);
1134 1140 extern int __svc_dupdone(struct svc_req *, caddr_t, uint_t, int, char *);
1135 1141 extern bool_t __svc_vc_dupcache_init(SVCXPRT *, void *, int);
1136 1142 extern int __svc_vc_dup(struct svc_req *, caddr_t *, uint_t *);
1137 1143 extern int __svc_vc_dupdone(struct svc_req *, caddr_t, uint_t, int);
1138 1144 #else
1139 1145 extern bool_t __svc_dupcache_init();
1140 1146 extern int __svc_dup();
1141 1147 extern int __svc_dupdone();
1142 1148 extern bool_t __svc_vc_dupcache_init();
1143 1149 extern int __svc_vc_dup();
1144 1150 extern int __svc_vc_dupdone();
1145 1151 #endif /* __STDC__ */
1146 1152 #endif /* _KERNEL */
1147 1153
1148 1154 #ifdef __cplusplus
1149 1155 }
1150 1156 #endif
1151 1157
1152 1158 #endif /* !_RPC_SVC_H */
|
↓ open down ↓ |
680 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX