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 2008 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_DEAD      1       /* This callback is dead, don't accept on it */
 444 
 445 typedef struct __svccb {
 446         queue_t         *r_q;
 447         mblk_t          *r_mp;
 448         kmutex_t        r_lock;
 449         kmutex_t        r_mlock;
 450         kcondvar_t      r_cbwait;

 451         int             r_flags;
 452         rpcprog_t       r_prog;


 453 } SVCCB;
 454 
 455 typedef struct __svccb_args {
 456         SVCMASTERXPRT *xprt;
 457         rpcprog_t prog;
 458         rpcvers_t vers;
 459         int family;
 460         void *tag;
 461 } SVCCB_ARGS;
 462 




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