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

   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  26 /* All Rights Reserved */
  27 /*
  28  * Portions of this source code were derived from Berkeley
  29  * 4.3 BSD under license from the Regents of the University of
  30  * California.
  31  */
  32 
  33 /*
  34  * svc.h, Server-side remote procedure call interface.
  35  */
  36 
  37 #ifndef _RPC_SVC_H
  38 #define _RPC_SVC_H
  39 
  40 #include <rpc/rpc_com.h>
  41 #include <rpc/rpc_msg.h>
  42 #include <sys/tihdr.h>
  43 #include <sys/poll.h>
  44 #include <sys/tsol/label.h>
  45 
  46 #ifdef  _KERNEL
  47 #include <rpc/svc_auth.h>
  48 #include <sys/callb.h>
  49 #include <rpc/rpc_tags.h>
  50 #endif  /* _KERNEL */
  51 
  52 /*
  53  * This interface must manage two items concerning remote procedure calling:
  54  *
  55  * 1) An arbitrary number of transport connections upon which rpc requests
  56  * are received. They are created and registered by routines in svc_generic.c,
  57  * svc_vc.c and svc_dg.c; they in turn call xprt_register and
  58  * xprt_unregister.
  59  *
  60  * 2) An arbitrary number of locally registered services.  Services are
  61  * described by the following four data: program number, version number,
  62  * "service dispatch" function, a transport handle, and a boolean that
  63  * indicates whether or not the exported program should be registered with a
  64  * local binder service;  if true the program's number and version and the
  65  * address from the transport handle are registered with the binder.
  66  * These data are registered with rpcbind via svc_reg().
  67  *
  68  * A service's dispatch function is called whenever an rpc request comes in
  69  * on a transport.  The request's program and version numbers must match
  70  * those of the registered service.  The dispatch function is passed two
  71  * parameters, struct svc_req * and SVCXPRT *, defined below.
  72  */
  73 
  74 #ifdef __cplusplus
  75 extern "C" {
  76 #endif
  77 
  78 /*
  79  * Server-side transport handles.
  80  * The actual type definitions are below.
  81  */
  82 #ifdef  _KERNEL
  83 typedef struct __svcmasterxprt  SVCMASTERXPRT;  /* Master transport handle */
  84 typedef struct __svcxprt        SVCXPRT;        /* Per-thread clone handle */
  85 typedef struct __svcpool        SVCPOOL;        /* Kernel thread pool      */
  86 #else   /* _KERNEL */
  87 typedef struct __svcxprt        SVCXPRT;        /* Server transport handle */
  88 #endif  /* _KERNEL */
  89 
  90 /*
  91  *  Prototype of error handler callback
  92  */
  93 #ifndef _KERNEL
  94 typedef void (*svc_errorhandler_t)(const SVCXPRT* svc, const bool_t isAConn);
  95 #endif
  96 
  97 /*
  98  * Service request.
  99  *
 100  * PSARC 2003/523 Contract Private Interface
 101  * svc_req
 102  * Changes must be reviewed by Solaris File Sharing
 103  * Changes must be communicated to contract-2003-523@sun.com
 104  */
 105 struct svc_req {
 106         rpcprog_t       rq_prog;        /* service program number */
 107         rpcvers_t       rq_vers;        /* service protocol version */
 108         rpcproc_t       rq_proc;        /* the desired procedure */
 109         struct opaque_auth rq_cred;     /* raw creds from the wire */
 110         caddr_t         rq_clntcred;    /* read only cooked cred */
 111         SVCXPRT         *rq_xprt;       /* associated transport */
 112         bslabel_t       *rq_label;      /* TSOL label of the request */
 113 };
 114 
 115 #ifdef _KERNEL
 116 struct dupreq {
 117         uint32_t        dr_xid;
 118         rpcproc_t       dr_proc;
 119         rpcvers_t       dr_vers;
 120         rpcprog_t       dr_prog;
 121         struct netbuf   dr_addr;
 122         struct netbuf   dr_resp;
 123         void            (*dr_resfree)();
 124         int             dr_status;
 125         struct dupreq   *dr_next;
 126         struct dupreq   *dr_chain;
 127 };
 128 
 129 /*
 130  * States of requests for duplicate request caching.
 131  */
 132 #define DUP_NEW                 0x00    /* new entry */
 133 #define DUP_INPROGRESS          0x01    /* request already going */
 134 #define DUP_DONE                0x02    /* request done */
 135 #define DUP_DROP                0x03    /* request dropped */
 136 #define DUP_ERROR               0x04    /* error in dup req cache */
 137 
 138 /*
 139  * Prototype for a service dispatch routine.
 140  */
 141 typedef void (SVC_DISPATCH)(struct svc_req *, SVCXPRT *);
 142 
 143 /*
 144  * The service provider callout.
 145  * Each entry identifies a dispatch routine to be called
 146  * for a given RPC program number and a version fitting
 147  * into the registered range.
 148  */
 149 typedef struct {
 150         rpcprog_t       sc_prog;        /* RPC Program number */
 151         rpcvers_t       sc_versmin;     /* Min version number */
 152         rpcvers_t       sc_versmax;     /* Max version number */
 153         SVC_DISPATCH    *sc_dispatch;   /* Dispatch routine   */
 154 } SVC_CALLOUT;
 155 
 156 /*
 157  * Table of service provider `callouts' for an RPC
 158  * transport handle. If sct_free is TRUE then transport
 159  * destructor is supposed to deallocate this table.
 160  */
 161 typedef struct {
 162         size_t          sct_size;       /* Number of entries  */
 163         bool_t          sct_free;       /* Deallocate if true */
 164         SVC_CALLOUT     *sct_sc;        /* Callout entries    */
 165 } SVC_CALLOUT_TABLE;
 166 
 167 struct svc_ops {
 168         bool_t  (*xp_recv)(SVCXPRT *, mblk_t *, struct rpc_msg *);
 169                 /* receive incoming requests */
 170         bool_t  (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t);
 171                 /* get arguments */
 172         bool_t  (*xp_reply)(SVCXPRT *, struct rpc_msg *);
 173                 /* send reply */
 174         bool_t  (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
 175                 /* free mem allocated for args */
 176         void    (*xp_destroy)(SVCMASTERXPRT *);
 177                 /* destroy this struct */
 178         int     (*xp_dup)(struct svc_req *, caddr_t, int,
 179                                 struct dupreq **, bool_t *);
 180                 /* check for dup */
 181         void    (*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int);
 182                 /* mark dup entry as completed */
 183         int32_t *(*xp_getres)(SVCXPRT *, int);
 184                 /* get pointer to response buffer */
 185         void    (*xp_freeres)(SVCXPRT *);
 186                 /* destroy pre-serialized response */
 187         void    (*xp_clone_destroy)(SVCXPRT *);
 188                 /* destroy a clone xprt */
 189         void    (*xp_start)(SVCMASTERXPRT *);
 190                 /* `ready-to-receive' */
 191         int     (*xp_ctl)(SVCXPRT *, int, void *);
 192                 /* kernel level control */
 193 };
 194 
 195 /*
 196  * Kernel SVC Control Requests.
 197  */
 198 #define SVCCTL_SET_ASD          1
 199 #define SVCCTL_GET_ASD          2
 200 #define SVCCTL_SET_CBCONN       3
 201 #define SVCCTL_SET_TAG          4
 202 #define SVCCTL_SET_TAG_CLEAR    5
 203 #define SVCCTL_CMP_TAG          6
 204 
 205 
 206 #else   /* _KERNEL */
 207 
 208 /*
 209  *      Service control requests
 210  */
 211 #define SVCGET_VERSQUIET        1
 212 #define SVCSET_VERSQUIET        2
 213 #define SVCGET_XID              4
 214 #define SVCSET_KEEPALIVE        5
 215 #define SVCSET_CONNMAXREC       6
 216 #define SVCGET_CONNMAXREC       7
 217 #define SVCGET_RECVERRHANDLER   8
 218 #define SVCSET_RECVERRHANDLER   9
 219 
 220 enum xprt_stat {
 221         XPRT_DIED,
 222         XPRT_MOREREQS,
 223         XPRT_IDLE
 224 };
 225 
 226 struct xp_ops {
 227 #ifdef  __STDC__
 228         bool_t  (*xp_recv)(SVCXPRT *, struct rpc_msg *);
 229                 /* receive incoming requests */
 230         enum xprt_stat (*xp_stat)(SVCXPRT *);
 231                 /* get transport status */
 232         bool_t  (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t);
 233                 /* get arguments */
 234         bool_t  (*xp_reply)(SVCXPRT *,  struct rpc_msg *);
 235                 /* send reply */
 236         bool_t  (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
 237                 /* free mem allocated for args */
 238         void    (*xp_destroy)(SVCXPRT *);
 239                 /* destroy this struct */
 240         bool_t  (*xp_control)(SVCXPRT *, const uint_t,  void *);
 241                 /* catch-all control function */
 242 #else   /* __STDC__ */
 243         bool_t  (*xp_recv)(); /* receive incoming requests */
 244         enum xprt_stat (*xp_stat)(); /* get transport status */
 245         bool_t  (*xp_getargs)(); /* get arguments */
 246         bool_t  (*xp_reply)(); /* send reply */
 247         bool_t  (*xp_freeargs)(); /* free mem allocated for args */
 248         void    (*xp_destroy)(); /* destroy this struct */
 249         bool_t  (*xp_control)(); /* catch-all control function */
 250 #endif  /* __STDC__ */
 251 };
 252 #endif  /* _KERNEL */
 253 
 254 #ifdef  _KERNEL
 255 /*
 256  * SVCPOOL
 257  * Kernel RPC server-side thread pool structure.
 258  */
 259 typedef struct __svcxprt_qnode __SVCXPRT_QNODE; /* Defined in svc.c */
 260 
 261 struct __svcpool {
 262         /*
 263          * Thread pool variables.
 264          *
 265          * The pool's thread lock p_thread_lock protects:
 266          * - p_threads, p_detached_threads, p_reserved_threads and p_closing
 267          * The pool's request lock protects:
 268          * - p_asleep, p_drowsy, p_reqs, p_walkers, p_req_cv.
 269          * The following fields are `initialized constants':
 270          * - p_id, p_stksize, p_timeout.
 271          * Access to p_next and p_prev is protected by the pool
 272          * list lock.
 273          */
 274         SVCPOOL         *p_next;                /* Next pool in the list  */
 275         SVCPOOL         *p_prev;                /* Prev pool in the list  */
 276         int             p_id;                   /* Pool id                */
 277         int             p_threads;              /* Non-detached threads   */
 278         int             p_detached_threads;     /* Detached threads       */
 279         int             p_maxthreads;           /* Max threads in the pool */
 280         int             p_redline;              /* `Redline' for the pool */
 281         int             p_reserved_threads;     /* Reserved threads       */
 282         kmutex_t        p_thread_lock;          /* Thread lock            */
 283         int             p_asleep;               /* Asleep threads         */
 284         int             p_drowsy;               /* Drowsy flag            */
 285         kcondvar_t      p_req_cv;               /* svc_poll() sleep var.  */
 286         clock_t         p_timeout;              /* svc_poll() timeout     */
 287         kmutex_t        p_req_lock;             /* Request lock           */
 288         int             p_reqs;                 /* Pending requests       */
 289         int             p_walkers;              /* Walking threads        */
 290         int             p_max_same_xprt;        /* Max reqs from the xprt */
 291         int             p_stksize;              /* Stack size for svc_run */
 292         bool_t          p_closing : 1;          /* Pool is closing        */
 293 
 294         /*
 295          * Thread creator variables.
 296          * The `creator signaled' flag is turned on when a signal is send
 297          * to the creator thread (to create a new service thread). The
 298          * creator clears when the thread is created. The protocol is not
 299          * to signal the creator thread when the flag is on. However,
 300          * a new thread should signal the creator if there are more
 301          * requests in the queue.
 302          *
 303          * When the pool is closing (ie it has been already unregistered from
 304          * the pool list) the last thread on the last transport should turn
 305          * the p_creator_exit flag on. This tells the creator thread to
 306          * free the pool structure and exit.
 307          */
 308         bool_t          p_creator_signaled : 1; /* Create requested flag  */
 309         bool_t          p_creator_exit : 1;     /* If true creator exits  */
 310         kcondvar_t      p_creator_cv;           /* Creator cond. variable */
 311         kmutex_t        p_creator_lock;         /* Creator lock           */
 312 
 313         /*
 314          * Doubly linked list containing `registered' master transport handles.
 315          * There is no special structure for a list node. Instead the
 316          * SVCMASTERXPRT structure has the xp_next and xp_prev fields.
 317          *
 318          * The p_lrwlock protects access to xprt->xp_next and xprt->xp_prev.
 319          * A service thread should also acquire a reader lock before accessing
 320          * any transports it is no longer linked to (to prevent them from
 321          * being destroyed).
 322          *
 323          * The list lock governs also the `pool is closing' flag.
 324          */
 325         size_t          p_lcount;               /* Current count          */
 326         SVCMASTERXPRT   *p_lhead;               /* List head              */
 327         krwlock_t       p_lrwlock;              /* R/W lock               */
 328 
 329         /*
 330          * Circular linked list for the `xprt-ready' queue (FIFO).
 331          * Must be initialized with svc_xprt_qinit() before it is used.
 332          *
 333          * The writer's end is protected by the pool's request lock
 334          * (pool->p_req_lock). The reader's end is protected by q_end_lock.
 335          *
 336          * When the queue is full the p_qoverflow flag is raised. It stays
 337          * on until all the pending request are drained.
 338          */
 339         size_t          p_qsize;                /* Number of queue nodes  */
 340         int             p_qoverflow : 1;        /* Overflow flag          */
 341         __SVCXPRT_QNODE *p_qbody;               /* Queue body (array)     */
 342         __SVCXPRT_QNODE *p_qtop;                /* Writer's end of FIFO   */
 343         __SVCXPRT_QNODE *p_qend;                /* Reader's end of FIFO   */
 344         kmutex_t        p_qend_lock;            /* Reader's end lock      */
 345 
 346         /*
 347          * Userspace thread creator variables.
 348          * Thread creation is actually done in userland, via a thread
 349          * that is parked in the kernel. When that thread is signaled,
 350          * it returns back down to the daemon from whence it came and
 351          * does the lwp create.
 352          *
 353          * A parallel "creator" thread runs in the kernel. That is the
 354          * thread that will signal for the user thread to return to
 355          * userland and do its work.
 356          *
 357          * Since the thread doesn't always exist (there could be a race
 358          * if two threads are created in rapid succession), we set
 359          * p_signal_create_thread to FALSE when we're ready to accept work.
 360          *
 361          * p_user_exit is set to true when the service pool is about
 362          * to close. This is done so that the user creation thread
 363          * can be informed and cleanup any userland state.
 364          */
 365 
 366         bool_t          p_signal_create_thread : 1; /* Create requested flag  */
 367         bool_t          p_user_exit : 1;        /* If true creator exits  */
 368         bool_t          p_user_waiting : 1;     /* Thread waiting for work */
 369         kcondvar_t      p_user_cv;              /* Creator cond. variable */
 370         kmutex_t        p_user_lock;            /* Creator lock           */
 371         void            (*p_offline)();         /* callout for unregister */
 372         void            (*p_shutdown)();        /* callout for shutdown */
 373 };
 374 
 375 /*
 376  * Server side transport handle (SVCMASTERXPRT).
 377  * xprt->xp_req_lock governs the following fields in xprt:
 378  *              xp_req_head, xp_req_tail.
 379  * xprt->xp_thread_lock governs the following fields in xprt:
 380  *              xp_threads, xp_detached_threads.
 381  *
 382  * xp_req_tail is only valid if xp_req_head is non-NULL
 383  *
 384  * The xp_threads count is the number of attached threads.  These threads
 385  * are able to handle new requests, and it is expected that they will not
 386  * block for a very long time handling a given request. The
 387  * xp_detached_threads count is the number of threads that have detached
 388  * themselves from the transport. These threads can block indefinitely
 389  * while handling a request.  Once they complete the request, they exit.
 390  *
 391  * A kernel service provider may register a callback function "closeproc"
 392  * for a transport.  When the transport is closing the last exiting attached
 393  * thread - xp_threads goes to zero - it calls the callback function, passing
 394  * it a reference to the transport.  This call is made with xp_thread_lock
 395  * held, so any cleanup bookkeeping it does should be done quickly.
 396  *
 397  * When the transport is closing the last exiting thread is supposed
 398  * to destroy/free the data structure.
 399  */
 400 typedef struct __svcxprt_common {
 401         struct file             *xpc_fp;
 402         struct svc_ops          *xpc_ops;
 403         queue_t                 *xpc_wq;        /* queue to write onto */
 404         cred_t                  *xpc_cred;      /* cached cred 4 server's use */
 405         int32_t                  xpc_type;      /* transport type */
 406         int                      xpc_msg_size;  /* TSDU or TIDU size */
 407         struct netbuf           xpc_rtaddr;     /* remote transport address */
 408         struct netbuf           xpc_lcladdr;    /* local transport address */
 409         void                    *xpc_tags;      /* xprt's tag list */
 410         SVC_CALLOUT_TABLE       *xpc_sct;
 411 } __SVCXPRT_COMMON;
 412 
 413 #define xp_fp           xp_xpc.xpc_fp
 414 #define xp_ops          xp_xpc.xpc_ops
 415 #define xp_wq           xp_xpc.xpc_wq
 416 #define xp_cred         xp_xpc.xpc_cred
 417 #define xp_type         xp_xpc.xpc_type
 418 #define xp_msg_size     xp_xpc.xpc_msg_size
 419 #define xp_rtaddr       xp_xpc.xpc_rtaddr
 420 #define xp_lcladdr      xp_xpc.xpc_lcladdr
 421 #define xp_sct          xp_xpc.xpc_sct
 422 #define xp_tags         xp_xpc.xpc_tags
 423 
 424 struct __svcmasterxprt {
 425         SVCMASTERXPRT   *xp_next;       /* Next transport in the list   */
 426         SVCMASTERXPRT   *xp_prev;       /* Prev transport in the list   */
 427         __SVCXPRT_COMMON xp_xpc;        /* Fields common with the clone */
 428         SVCPOOL         *xp_pool;       /* Pointer to the pool          */
 429         mblk_t          *xp_req_head;   /* Request queue head           */
 430         mblk_t          *xp_req_tail;   /* Request queue tail           */
 431         kmutex_t        xp_req_lock;    /* Request lock                 */
 432         int             xp_threads;     /* Current num. of attached threads */
 433         int             xp_detached_threads; /* num. of detached threads */
 434         kmutex_t        xp_thread_lock; /* Thread count lock            */
 435         void            (*xp_closeproc)(const SVCMASTERXPRT *);
 436                                         /* optional; see comments above */
 437         char            *xp_netid;      /* network token                */
 438         struct netbuf   xp_addrmask;    /* address mask                 */
 439 
 440         caddr_t         xp_p2;          /* private: for use by svc ops  */
 441 };
 442 
 443 #define SVCCB_NFS41_CB_THREAD_EXIT      0x01
 444 
 445 typedef struct __svccb {
 446         queue_t         *r_q;
 447         mblk_t          *r_mp;
 448         kmutex_t        r_lock;

 449         kcondvar_t      r_cbwait;
 450         kcondvar_t      r_cbexit;
 451         int             r_flags;
 452         rpcprog_t       r_prog;
 453         kthread_t       *r_thread;
 454         SVC_DISPATCH    *r_dispatch;
 455 } SVCCB;
 456 
 457 typedef struct __svccb_args {
 458         SVCMASTERXPRT *xprt;
 459         rpcprog_t prog;
 460         rpcvers_t vers;
 461         int family;
 462         void *tag;
 463 } SVCCB_ARGS;
 464 
 465 typedef struct __cbserver_args {
 466         SVC_DISPATCH    *callback;
 467         rpcprog_t       prog;
 468 } CBSERVER_ARGS;
 469 
 470 /*
 471  * Service thread `clone' transport handle (SVCXPRT)
 472  *
 473  * PSARC 2003/523 Contract Private Interface
 474  * SVCXPRT
 475  * Changes must be reviewed by Solaris File Sharing
 476  * Changes must be communicated to contract-2003-523@sun.com
 477  *
 478  * The xp_p2buf buffer is used as the storage for a transport type
 479  * specific structure. It is private for the svc ops for a given
 480  * transport type.
 481  */
 482 
 483 #define SVC_P2LEN   128
 484 
 485 struct __svcxprt {
 486         __SVCXPRT_COMMON xp_xpc;
 487         SVCMASTERXPRT   *xp_master;     /* back ptr to master           */
 488 
 489         /* The following fileds are on a per-thread basis */
 490         callb_cpr_t     *xp_cprp;       /* unused padding for Contract  */
 491         bool_t          xp_reserved : 1; /* is thread reserved?         */
 492         bool_t          xp_detached : 1; /* is thread detached?         */
 493         int             xp_same_xprt;   /* Reqs from the same xprt      */
 494 
 495         /* The following fields are used on a per-request basis */
 496         struct opaque_auth xp_verf;     /* raw response verifier        */
 497         SVCAUTH         xp_auth;        /* auth flavor of current req   */
 498         void            *xp_cookie;     /* a cookie                     */
 499         uint32_t        xp_xid;         /* id                           */
 500         XDR             xp_xdrin;       /* input xdr stream             */
 501         XDR             xp_xdrout;      /* output xdr stream            */
 502 
 503         /* Private for svc ops */
 504         char            xp_p2buf[SVC_P2LEN]; /* udp_data or cots_data_t */
 505                                                 /* or clone_rdma_data_t */
 506         void            *xp_asd;
 507 };
 508 #else   /* _KERNEL */
 509 struct __svcxprt {
 510         int             xp_fd;
 511 #define xp_sock         xp_fd
 512         ushort_t        xp_port;
 513         /*
 514          * associated port number.
 515          * Obsolete, but still used to
 516          * specify whether rendezvouser
 517          * or normal connection
 518          */
 519         struct  xp_ops  *xp_ops;
 520         int             xp_addrlen;     /* length of remote addr. Obsoleted */
 521         char            *xp_tp;         /* transport provider device name */
 522         char            *xp_netid;      /* network token */
 523         struct netbuf   xp_ltaddr;      /* local transport address */
 524         struct netbuf   xp_rtaddr;      /* remote transport address */
 525         char            xp_raddr[16];   /* remote address. Now obsoleted */
 526         struct opaque_auth xp_verf;     /* raw response verifier */
 527         caddr_t         xp_p1;          /* private: for use by svc ops */
 528         caddr_t         xp_p2;          /* private: for use by svc ops */
 529         caddr_t         xp_p3;          /* private: for use by svc lib */
 530         int             xp_type;        /* transport type */
 531         /*
 532          * callback on client death
 533          * First parameter is the current structure,
 534          * Second parameter :
 535          *      - FALSE for the service listener
 536          *      - TRUE for a real connected socket
 537          */
 538         svc_errorhandler_t xp_closeclnt;
 539 };
 540 
 541 #endif  /* _KERNEL */
 542 
 543 /*
 544  *  Approved way of getting address of caller,
 545  *  address mask, and netid of transport.
 546  */
 547 #define svc_getrpccaller(x) (&(x)->xp_rtaddr)
 548 #ifdef _KERNEL
 549 #define svc_getendpoint(x) (&(x)->xp_lcladdr.buf)
 550 #define svc_getcaller(x) (&(x)->xp_rtaddr.buf)
 551 #define svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask)
 552 #define svc_getnetid(x) ((x)->xp_master->xp_netid)
 553 #endif  /* _KERNEL */
 554 
 555 /*
 556  * Operations defined on an SVCXPRT handle
 557  */
 558 
 559 #ifdef  _KERNEL
 560 #define SVC_RECV(clone_xprt, mp, msg) \
 561         (*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg))
 562 
 563 /*
 564  * PSARC 2003/523 Contract Private Interface
 565  * SVC_GETARGS
 566  * Changes must be reviewed by Solaris File Sharing
 567  * Changes must be communicated to contract-2003-523@sun.com
 568  */
 569 #define SVC_GETARGS(clone_xprt, xargs, argsp) \
 570         (*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp))
 571 
 572 #define SVC_REPLY(clone_xprt, msg) \
 573         (*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg))
 574 
 575 #define SVC_FREEARGS(clone_xprt, xargs, argsp) \
 576         (*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp))
 577 
 578 #define SVC_GETRES(clone_xprt, size) \
 579         (*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size))
 580 
 581 #define SVC_FREERES(clone_xprt) \
 582         (*(clone_xprt)->xp_ops->xp_freeres)(clone_xprt)
 583 
 584 #define SVC_DESTROY(xprt) \
 585         (*(xprt)->xp_ops->xp_destroy)(xprt)
 586 
 587 /*
 588  * PSARC 2003/523 Contract Private Interfaces
 589  * SVC_DUP, SVC_DUPDONE, SVC_DUP_EXT, SVC_DUPDONE_EXT
 590  * Changes must be reviewed by Solaris File Sharing
 591  * Changes must be communicated to contract-2003-523@sun.com
 592  *
 593  * SVC_DUP and SVC_DUPDONE are defined here for backward compatibility.
 594  */
 595 #define SVC_DUP_EXT(clone_xprt, req, res, size, drpp, dupcachedp) \
 596         (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, dupcachedp)
 597 
 598 #define SVC_DUPDONE_EXT(clone_xprt, dr, res, resfree, size, status) \
 599         (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, resfree, size, status)
 600 
 601 #define SVC_DUP(clone_xprt, req, res, size, drpp) \
 602         (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, NULL)
 603 
 604 #define SVC_DUPDONE(clone_xprt, dr, res, size, status) \
 605         (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, NULL, size, status)
 606 
 607 #define SVC_CLONE_DESTROY(clone_xprt) \
 608         (*(clone_xprt)->xp_ops->xp_clone_destroy)(clone_xprt)
 609 
 610 
 611 #define SVC_START(xprt) \
 612         (*(xprt)->xp_ops->xp_start)(xprt)
 613 
 614 #define SVC_CTL(clone_xprt, rq, arg) \
 615         (*(clone_xprt)->xp_ops->xp_ctl)((clone_xprt), (rq), (arg))
 616 
 617 #else   /* _KERNEL */
 618 
 619 #define SVC_RECV(xprt, msg) \
 620         (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
 621 #define svc_recv(xprt, msg) \
 622         (*(xprt)->xp_ops->xp_recv)((xprt), (msg))
 623 
 624 #define SVC_STAT(xprt) \
 625         (*(xprt)->xp_ops->xp_stat)(xprt)
 626 #define svc_stat(xprt) \
 627         (*(xprt)->xp_ops->xp_stat)(xprt)
 628 
 629 #define SVC_GETARGS(xprt, xargs, argsp) \
 630         (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
 631 #define svc_getargs(xprt, xargs, argsp) \
 632         (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
 633 
 634 #define SVC_REPLY(xprt, msg) \
 635         (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
 636 #define svc_reply(xprt, msg) \
 637         (*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
 638 
 639 #define SVC_FREEARGS(xprt, xargs, argsp) \
 640         (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
 641 #define svc_freeargs(xprt, xargs, argsp) \
 642         (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
 643 
 644 #define SVC_GETRES(xprt, size) \
 645         (*(xprt)->xp_ops->xp_getres)((xprt), (size))
 646 #define svc_getres(xprt, size) \
 647         (*(xprt)->xp_ops->xp_getres)((xprt), (size))
 648 
 649 #define SVC_FREERES(xprt) \
 650         (*(xprt)->xp_ops->xp_freeres)(xprt)
 651 #define svc_freeres(xprt) \
 652         (*(xprt)->xp_ops->xp_freeres)(xprt)
 653 
 654 #define SVC_DESTROY(xprt) \
 655         (*(xprt)->xp_ops->xp_destroy)(xprt)
 656 #define svc_destroy(xprt) \
 657         (*(xprt)->xp_ops->xp_destroy)(xprt)
 658 
 659 /*
 660  * PSARC 2003/523 Contract Private Interface
 661  * SVC_CONTROL
 662  * Changes must be reviewed by Solaris File Sharing
 663  * Changes must be communicated to contract-2003-523@sun.com
 664  */
 665 #define SVC_CONTROL(xprt, rq, in) \
 666         (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in))
 667 #endif  /* _KERNEL */
 668 
 669 /*
 670  * Pool id's reserved for NFS, NLM, the NFSv4 callback program and DSERV.
 671  */
 672 #define NFS_SVCPOOL_ID          0x01
 673 #define NLM_SVCPOOL_ID          0x02
 674 #define NFS_CB_SVCPOOL_ID       0x03
 675 #define RDC_SVCPOOL_ID          0x05    /* SNDR, PSARC 2001/699 */
 676 #define DSERV_SVCPOOL_ID        0x06
 677 #define UNIQUE_SVCPOOL_ID       0x07    /* MUST be largest value here */
 678 
 679 struct svcpool_args {
 680         uint32_t        id;             /* Pool id */
 681         uint32_t        maxthreads;     /* Max threads in the pool */
 682         uint32_t        redline;        /* `Redline' for the pool */
 683         uint32_t        qsize;          /* `xprt-ready' queue size */
 684         uint32_t        timeout;        /* svc_poll() timeout */
 685         uint32_t        stksize;        /* svc_run() stack size */
 686         uint32_t        max_same_xprt;  /* Max reqs from the same xprt */
 687 };
 688 
 689 
 690 #ifdef  _KERNEL
 691 /*
 692  * Transport registration and thread pool creation.
 693  */
 694 extern int      svc_xprt_register(SVCMASTERXPRT *, int);
 695 extern void     svc_xprt_unregister(SVCMASTERXPRT *);
 696 extern int      svc_pool_create(struct svcpool_args *);
 697 extern int      svc_wait(int);
 698 extern int      svc_do_run(int);
 699 #define SVCPSET_SHUTDOWN_PROC   1
 700 #define SVCPSET_UNREGISTER_PROC 2
 701 extern int      svc_pool_control(int, int, void *);
 702 #else   /* _KERNEL */
 703 #ifdef  __STDC__
 704 extern bool_t   rpc_reg(const rpcprog_t, const rpcvers_t, const rpcproc_t,
 705                         char *(*)(char *), const xdrproc_t, const xdrproc_t,
 706                         const char *);
 707 
 708 /*
 709  * Service registration
 710  *
 711  * svc_reg(xprt, prog, vers, dispatch, nconf)
 712  *      const SVCXPRT *xprt;
 713  *      const rpcprog_t prog;
 714  *      const rpcvers_t vers;
 715  *      const void (*dispatch)();
 716  *      const struct netconfig *nconf;
 717  */
 718 extern bool_t   svc_reg(const SVCXPRT *, const rpcprog_t, const rpcvers_t,
 719                         void (*)(struct svc_req *, SVCXPRT *),
 720                         const struct netconfig *);
 721 
 722 /*
 723  * Service authentication registration
 724  *
 725  * svc_auth_reg(cred_flavor, handler)
 726  *    int cred_flavor;
 727  *    enum auth_stat (*handler)();
 728  */
 729 extern int      svc_auth_reg(int, enum auth_stat (*)());
 730 
 731 /*
 732  * Service un-registration
 733  *
 734  * svc_unreg(prog, vers)
 735  *      const rpcprog_t prog;
 736  *      const rpcvers_t vers;
 737  */
 738 extern void     svc_unreg(const rpcprog_t, const rpcvers_t);
 739 
 740 /*
 741  * Transport registration/unregistration.
 742  *
 743  * xprt_register(xprt)
 744  *      const SVCXPRT *xprt;
 745  *
 746  * xprt_unregister(xprt)
 747  *      const SVCXPRT *xprt;
 748  */
 749 extern void     xprt_register(const SVCXPRT *);
 750 extern void     xprt_unregister(const SVCXPRT *);
 751 #else   /* __STDC__ */
 752 extern bool_t   rpc_reg();
 753 extern bool_t   svc_reg();
 754 extern bool_t   svc_auth_reg();
 755 extern void     svc_unreg();
 756 extern void     xprt_register();
 757 extern void     xprt_unregister();
 758 #endif /* __STDC__ */
 759 #endif  /* _KERNEL */
 760 
 761 
 762 /*
 763  * When the service routine is called, it must first check to see if it
 764  * knows about the procedure;  if not, it should call svcerr_noproc
 765  * and return.  If so, it should deserialize its arguments via
 766  * SVC_GETARGS (defined above).  If the deserialization does not work,
 767  * svcerr_decode should be called followed by a return.  Successful
 768  * decoding of the arguments should be followed the execution of the
 769  * procedure's code and a call to svc_sendreply.
 770  *
 771  * Also, if the service refuses to execute the procedure due to too-
 772  * weak authentication parameters, svcerr_weakauth should be called.
 773  * Note: do not confuse access-control failure with weak authentication!
 774  *
 775  * NB: In pure implementations of rpc, the caller always waits for a reply
 776  * msg.  This message is sent when svc_sendreply is called.
 777  * Therefore pure service implementations should always call
 778  * svc_sendreply even if the function logically returns void;  use
 779  * xdr.h - xdr_void for the xdr routine.  HOWEVER, connectionful rpc allows
 780  * for the abuse of pure rpc via batched calling or pipelining.  In the
 781  * case of a batched call, svc_sendreply should NOT be called since
 782  * this would send a return message, which is what batching tries to avoid.
 783  * It is the service/protocol writer's responsibility to know which calls are
 784  * batched and which are not.  Warning: responding to batch calls may
 785  * deadlock the caller and server processes!
 786  */
 787 #ifdef  __STDC__
 788 extern bool_t   svc_sendreply(const SVCXPRT *, const xdrproc_t, const caddr_t);
 789 extern void     svcerr_decode(const SVCXPRT *);
 790 extern void     svcerr_weakauth(const SVCXPRT *);
 791 extern void     svcerr_noproc(const SVCXPRT *);
 792 extern SVCXPRT *svc_clone_init(void);
 793 extern void     svc_init_clone_xprt(SVCXPRT *, queue_t *);
 794 extern void     svcerr_progvers(const SVCXPRT *, const rpcvers_t,
 795     const rpcvers_t);
 796 extern void     svcerr_auth(const SVCXPRT *, const enum auth_stat);
 797 extern void     svcerr_noprog(const SVCXPRT *);
 798 extern void     svcerr_systemerr(const SVCXPRT *);
 799 extern void     svcerr_badcred(const SVCXPRT *);
 800 #else   /* __STDC__ */
 801 extern bool_t   svc_sendreply();
 802 extern void     svcerr_decode();
 803 extern void     svcerr_weakauth();
 804 extern void     svcerr_noproc();
 805 extern void     svc_init_clone_xprt();
 806 extern SVCXPRT *svc_clone_init();
 807 extern void     svcerr_progvers();
 808 extern void     svcerr_auth();
 809 extern void     svcerr_noprog();
 810 extern void     svcerr_systemerr();
 811 extern void     svcerr_badcred();
 812 #endif  /* __STDC__ */
 813 
 814 #ifdef  _KERNEL
 815 /*
 816  * Kernel RPC functions.
 817  */
 818 extern void     svc_init(void);
 819 extern void     svc_cots_init(void);
 820 extern void     svc_clts_init(void);
 821 extern void     mt_kstat_init(void);
 822 extern void     mt_kstat_fini(void);
 823 extern int      svc_tli_kcreate(struct file *, uint_t, char *,
 824                                 struct netbuf *, SVCMASTERXPRT **,
 825                                 SVC_CALLOUT_TABLE *,
 826                                 void (*closeproc)(const SVCMASTERXPRT *),
 827                                 int, bool_t);
 828 extern int      svc_clts_kcreate(struct file *, uint_t, struct T_info_ack *,
 829                                 SVCMASTERXPRT **);
 830 extern int      svc_cots_kcreate(struct file *, uint_t, struct T_info_ack *,
 831                                 SVCMASTERXPRT **);
 832 extern void     svc_queuereq(queue_t *, mblk_t *);
 833 extern void     svc_queueclean(queue_t *);
 834 extern void     svc_queueclose(queue_t *);
 835 extern int      svc_reserve_thread(SVCXPRT *);
 836 extern void     svc_unreserve_thread(SVCXPRT *);
 837 extern callb_cpr_t *svc_detach_thread(SVCXPRT *);
 838 
 839 /*
 840  * For RDMA based kRPC.
 841  * "rdma_xprt_record" is a reference to master transport handles
 842  * in kRPC thread pools. This is an easy way of tracking and shuting
 843  * down rdma based kRPC transports on demand.
 844  * "rdma_xprt_group" is a list of RDMA based mster transport handles
 845  * or records in a kRPC thread pool.
 846  */
 847 typedef struct rdma_xprt_record         rdma_xprt_record_t;
 848 struct rdma_xprt_record {
 849         int                     rtr_type;       /* Type of rdma; IB/VI/RDDP */
 850         SVCMASTERXPRT           *rtr_xprt_ptr;  /* Ptr to master xprt handle */
 851         rdma_xprt_record_t      *rtr_next;      /* Ptr to next record */
 852 };
 853 
 854 typedef struct {
 855         int                     rtg_count;      /* Number transport records */
 856         int                     rtg_poolid;     /* Pool Id for this group */
 857         rdma_xprt_record_t      *rtg_listhead;  /* Head of the records list */
 858 } rdma_xprt_group_t;
 859 
 860 extern int      svc_rdma_kcreate(char *, SVC_CALLOUT_TABLE *, int,
 861                         rdma_xprt_group_t *);
 862 extern void     svc_rdma_kstop(SVCMASTERXPRT *);
 863 extern void     svc_rdma_kdestroy(SVCMASTERXPRT *);
 864 extern void     rdma_stop(rdma_xprt_group_t);
 865 
 866 /*
 867  * GSS cleanup method.
 868  */
 869 extern void     rpc_gss_cleanup(SVCXPRT *);
 870 #else   /* _KERNEL */
 871 /*
 872  * Lowest level dispatching -OR- who owns this process anyway.
 873  * Somebody has to wait for incoming requests and then call the correct
 874  * service routine.  The routine svc_run does infinite waiting; i.e.,
 875  * svc_run never returns.
 876  * Since another (co-existant) package may wish to selectively wait for
 877  * incoming calls or other events outside of the rpc architecture, the
 878  * routine svc_getreq_poll is provided.  It must be passed pollfds, the
 879  * "in-place" results of a poll call (see poll, section 2).
 880  */
 881 
 882 /*
 883  * Global keeper of rpc service descriptors in use
 884  * dynamic; must be inspected before each call to select or poll
 885  */
 886 extern pollfd_t *svc_pollfd;
 887 extern int      svc_max_pollfd;
 888 extern fd_set   svc_fdset;
 889 #if !defined(_LP64) && FD_SETSIZE > 1024
 890 extern fd_set   _new_svc_fdset;
 891 #ifdef __PRAGMA_REDEFINE_EXTNAME
 892 #pragma redefine_extname        svc_fdset       _new_svc_fdset
 893 #else   /* __PRAGMA_REDEFINE_EXTNAME */
 894 #define svc_fdset       _new_svc_fdset
 895 #endif  /* __PRAGMA_REDEFINE_EXTNAME */
 896 #endif  /* LP64 && FD_SETSIZE > 1024 */
 897 #define svc_fds svc_fdset.fds_bits[0]   /* compatibility */
 898 
 899 /*
 900  * A small program implemented by the svc_rpc implementation itself.
 901  * Also see clnt.h for protocol numbers.
 902  */
 903 #ifdef __STDC__
 904 extern void     svc_getreq(int);
 905 extern void     svc_getreq_common(const int);
 906 extern void     svc_getreqset(fd_set *); /* takes fdset instead of int */
 907 extern void     svc_getreq_poll(struct pollfd *, const int);
 908 extern void     svc_run(void);
 909 extern void     svc_exit(void);
 910 #else   /* __STDC__ */
 911 extern void     rpctest_service();
 912 extern void     svc_getreqset();
 913 extern void     svc_getreq();
 914 extern void     svc_getreq_common();
 915 extern void     svc_getreqset();         /* takes fdset instead of int */
 916 extern void     svc_getreq_poll();
 917 extern void     svc_run();
 918 extern void     svc_exit();
 919 #endif  /* __STDC__ */
 920 
 921 /*
 922  *  Functions used to manage user file descriptors
 923  */
 924 typedef int svc_input_id_t;
 925 typedef void (*svc_callback_t)(svc_input_id_t id, int fd,
 926                                 unsigned int events, void* cookie);
 927 
 928 #ifdef __STDC__
 929 extern svc_input_id_t svc_add_input(int fd, unsigned int events,
 930                                 svc_callback_t user_callback,
 931                                 void* cookie);
 932 extern int svc_remove_input(svc_input_id_t id);
 933 #else   /* __STDC__ */
 934 extern svc_input_id_t svc_add_input();
 935 extern int      svc_remove_input();
 936 #endif
 937 
 938 /*
 939  * These are the existing service side transport implementations.
 940  *
 941  * Transport independent svc_create routine.
 942  */
 943 #ifdef __STDC__
 944 extern int      svc_create(void (*)(struct svc_req *, SVCXPRT *),
 945                                 const rpcprog_t, const rpcvers_t,
 946                                 const char *);
 947         /*
 948          *      void (*dispatch)();             -- dispatch routine
 949          *      const rpcprog_t prognum;        -- program number
 950          *      const rpcvers_t versnum;        -- version number
 951          *      const char *nettype;            -- network type
 952          */
 953 
 954 /*
 955  * Generic server creation routine. It takes a netconfig structure
 956  * instead of a nettype.
 957  */
 958 extern SVCXPRT  *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
 959                                 const rpcprog_t, const rpcvers_t,
 960                                 const struct netconfig *);
 961         /*
 962          * void (*dispatch)();                  -- dispatch routine
 963          * const rpcprog_t prognum;             -- program number
 964          * const rpcvers_t versnum;             -- version number
 965          * const struct netconfig *nconf;       -- netconfig structure
 966          */
 967 
 968 /*
 969  * Generic TLI create routine
 970  */
 971 extern  SVCXPRT *svc_tli_create(const int, const struct netconfig *,
 972                                 const struct t_bind *, const uint_t,
 973                                 const uint_t);
 974         /*
 975          *      const int fd;                   -- connection end point
 976          *      const struct netconfig *nconf;  -- netconfig structure
 977          *      const struct t_bind *bindaddr;  -- local bind address
 978          *      const uint_t sendsz;            -- max sendsize
 979          *      const uint_t recvsz;            -- max recvsize
 980          */
 981 
 982 /*
 983  * Connectionless and connectionful create routines.
 984  */
 985 extern SVCXPRT  *svc_vc_create(const int, const uint_t, const uint_t);
 986         /*
 987          *      const int fd;                   -- open connection end point
 988          *      const uint_t sendsize;          -- max send size
 989          *      const uint_t recvsize;          -- max recv size
 990          */
 991 
 992 extern SVCXPRT  *svc_dg_create(const int, const uint_t, const uint_t);
 993         /*
 994          * const int fd;                        -- open connection
 995          * const uint_t sendsize;               -- max send size
 996          * const uint_t recvsize;               -- max recv size
 997          */
 998 
 999 /*
1000  * the routine takes any *open* TLI file
1001  * descriptor as its first input and is used for open connections.
1002  */
1003 extern  SVCXPRT *svc_fd_create(const int, const uint_t, const uint_t);
1004         /*
1005          *      const int fd;                   -- open connection end point
1006          *      const uint_t sendsize;          -- max send size
1007          *      const uint_t recvsize;          -- max recv size
1008          */
1009 
1010 /*
1011  * Memory based rpc (for speed check and testing)
1012  */
1013 extern SVCXPRT  *svc_raw_create(void);
1014 
1015 /*
1016  * Creation of service over doors transport.
1017  */
1018 extern SVCXPRT  *svc_door_create(void (*)(struct svc_req *, SVCXPRT *),
1019                                 const rpcprog_t, const rpcvers_t,
1020                                 const uint_t);
1021         /*
1022          *      void (*dispatch)();             -- dispatch routine
1023          *      const rpcprog_t prognum;        -- program number
1024          *      const rpcvers_t versnum;        -- version number
1025          *      const uint_t sendsize;          -- send buffer size
1026          */
1027 
1028 /*
1029  * Service control interface
1030  */
1031 extern  bool_t  svc_control(SVCXPRT *, const uint_t, void *);
1032         /*
1033          *      SVCXPRT *svc;                   -- service to manipulate
1034          *      const uint_t req;               -- request
1035          *      void *info;                     -- argument to request
1036          */
1037 
1038 /*
1039  * svc_dg_enable_cache() enables the cache on dg transports.
1040  */
1041 extern int svc_dg_enablecache(SVCXPRT *, const uint_t);
1042 #else   /* __STDC__ */
1043 extern int      svc_create();
1044 extern SVCXPRT  *svc_tp_create();
1045 extern SVCXPRT  *svc_tli_create();
1046 extern SVCXPRT  *svc_vc_create();
1047 extern SVCXPRT  *svc_dg_create();
1048 extern SVCXPRT  *svc_fd_create();
1049 extern SVCXPRT  *svc_raw_create();
1050 extern SVCXPRT  *svc_door_create();
1051 extern int svc_dg_enablecache();
1052 #endif  /* __STDC__ */
1053 
1054 extern boolean_t is_multilevel(rpcprog_t);
1055 
1056 #ifdef  PORTMAP
1057 /* For backward compatibility */
1058 #include <rpc/svc_soc.h>
1059 #endif  /* PORTMAP */
1060 
1061 /*
1062  * For user level MT hot server functions
1063  */
1064 
1065 /*
1066  * Different MT modes
1067  */
1068 #define RPC_SVC_MT_NONE         0       /* default, single-threaded */
1069 #define RPC_SVC_MT_AUTO         1       /* automatic MT mode */
1070 #define RPC_SVC_MT_USER         2       /* user MT mode */
1071 
1072 #ifdef  __STDC__
1073 extern void     svc_done(SVCXPRT *);
1074 #else
1075 extern void     svc_done();
1076 #endif  /* __STDC__ */
1077 
1078 /*
1079  * Obtaining local credentials.
1080  */
1081 typedef struct __svc_local_cred_t {
1082         uid_t   euid;   /* effective uid */
1083         gid_t   egid;   /* effective gid */
1084         uid_t   ruid;   /* real uid */
1085         gid_t   rgid;   /* real gid */
1086         pid_t   pid;    /* caller's pid, or -1 if not available */
1087 } svc_local_cred_t;
1088 
1089 #ifdef __STDC__
1090 struct ucred_s;
1091 extern void     svc_fd_negotiate_ucred(int);
1092 extern int      svc_getcallerucred(const SVCXPRT *, struct ucred_s **);
1093 extern bool_t   svc_get_local_cred(SVCXPRT *, svc_local_cred_t *);
1094 #else
1095 extern void     svc_fd_negotiate_ucred();
1096 extern int      svc_getcallerucred();
1097 extern bool_t   svc_get_local_cred();
1098 #endif  /* __STDC__ */
1099 
1100 /*
1101  * Private interfaces and structures for user level duplicate request caching.
1102  * The interfaces and data structures are not committed and subject to
1103  * change in future releases. Currently only intended for use by automountd.
1104  */
1105 struct dupreq {
1106         uint32_t        dr_xid;
1107         rpcproc_t       dr_proc;
1108         rpcvers_t       dr_vers;
1109         rpcprog_t       dr_prog;
1110         struct netbuf   dr_addr;
1111         struct netbuf   dr_resp;
1112         int             dr_status;
1113         time_t          dr_time;
1114         uint_t          dr_hash;
1115         struct dupreq   *dr_next;
1116         struct dupreq   *dr_prev;
1117         struct dupreq   *dr_chain;
1118         struct dupreq   *dr_prevchain;
1119 };
1120 
1121 /*
1122  * The fixedtime state is defined if we want to expand the routines to
1123  * handle and encompass fixed size caches.
1124  */
1125 #define DUPCACHE_FIXEDTIME      0
1126 
1127 /*
1128  * States of requests for duplicate request caching.
1129  * These are the same as defined for the kernel.
1130  */
1131 #define DUP_NEW                 0x00    /* new entry */
1132 #define DUP_INPROGRESS          0x01    /* request already going */
1133 #define DUP_DONE                0x02    /* request done */
1134 #define DUP_DROP                0x03    /* request dropped */
1135 #define DUP_ERROR               0x04    /* error in dup req cache */
1136 
1137 #ifdef __STDC__
1138 extern bool_t   __svc_dupcache_init(void *, int, char **);
1139 extern int      __svc_dup(struct svc_req *, caddr_t *, uint_t *, char *);
1140 extern int      __svc_dupdone(struct svc_req *, caddr_t, uint_t, int, char *);
1141 extern bool_t   __svc_vc_dupcache_init(SVCXPRT *, void *, int);
1142 extern int      __svc_vc_dup(struct svc_req *, caddr_t *, uint_t *);
1143 extern int      __svc_vc_dupdone(struct svc_req *, caddr_t, uint_t, int);
1144 #else
1145 extern bool_t   __svc_dupcache_init();
1146 extern int      __svc_dup();
1147 extern int      __svc_dupdone();
1148 extern bool_t   __svc_vc_dupcache_init();
1149 extern int      __svc_vc_dup();
1150 extern int      __svc_vc_dupdone();
1151 #endif  /* __STDC__ */
1152 #endif  /* _KERNEL */
1153 
1154 #ifdef  __cplusplus
1155 }
1156 #endif
1157 
1158 #endif  /* !_RPC_SVC_H */
--- EOF ---