17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 545916cd2Sjpk * Common Development and Distribution License (the "License"). 645916cd2Sjpk * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 220a4b0810SKaren Rochford * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 23*2695d4f4SMarcel Telka * Copyright 2013 Nexenta Systems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 267c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 277c478bd9Sstevel@tonic-gate /* 287c478bd9Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 297c478bd9Sstevel@tonic-gate * 4.3 BSD under license from the Regents of the University of 307c478bd9Sstevel@tonic-gate * California. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * svc.h, Server-side remote procedure call interface. 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifndef _RPC_SVC_H 387c478bd9Sstevel@tonic-gate #define _RPC_SVC_H 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #include <rpc/rpc_com.h> 417c478bd9Sstevel@tonic-gate #include <rpc/rpc_msg.h> 427c478bd9Sstevel@tonic-gate #include <sys/tihdr.h> 437c478bd9Sstevel@tonic-gate #include <sys/poll.h> 4445916cd2Sjpk #include <sys/tsol/label.h> 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #ifdef _KERNEL 477c478bd9Sstevel@tonic-gate #include <rpc/svc_auth.h> 487c478bd9Sstevel@tonic-gate #include <sys/callb.h> 497c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * This interface must manage two items concerning remote procedure calling: 537c478bd9Sstevel@tonic-gate * 547c478bd9Sstevel@tonic-gate * 1) An arbitrary number of transport connections upon which rpc requests 557c478bd9Sstevel@tonic-gate * are received. They are created and registered by routines in svc_generic.c, 567c478bd9Sstevel@tonic-gate * svc_vc.c and svc_dg.c; they in turn call xprt_register and 577c478bd9Sstevel@tonic-gate * xprt_unregister. 587c478bd9Sstevel@tonic-gate * 597c478bd9Sstevel@tonic-gate * 2) An arbitrary number of locally registered services. Services are 607c478bd9Sstevel@tonic-gate * described by the following four data: program number, version number, 617c478bd9Sstevel@tonic-gate * "service dispatch" function, a transport handle, and a boolean that 627c478bd9Sstevel@tonic-gate * indicates whether or not the exported program should be registered with a 637c478bd9Sstevel@tonic-gate * local binder service; if true the program's number and version and the 647c478bd9Sstevel@tonic-gate * address from the transport handle are registered with the binder. 657c478bd9Sstevel@tonic-gate * These data are registered with rpcbind via svc_reg(). 667c478bd9Sstevel@tonic-gate * 677c478bd9Sstevel@tonic-gate * A service's dispatch function is called whenever an rpc request comes in 687c478bd9Sstevel@tonic-gate * on a transport. The request's program and version numbers must match 697c478bd9Sstevel@tonic-gate * those of the registered service. The dispatch function is passed two 707c478bd9Sstevel@tonic-gate * parameters, struct svc_req * and SVCXPRT *, defined below. 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #ifdef __cplusplus 747c478bd9Sstevel@tonic-gate extern "C" { 757c478bd9Sstevel@tonic-gate #endif 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * Server-side transport handles. 797c478bd9Sstevel@tonic-gate * The actual type definitions are below. 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate #ifdef _KERNEL 827c478bd9Sstevel@tonic-gate typedef struct __svcmasterxprt SVCMASTERXPRT; /* Master transport handle */ 837c478bd9Sstevel@tonic-gate typedef struct __svcxprt SVCXPRT; /* Per-thread clone handle */ 847c478bd9Sstevel@tonic-gate typedef struct __svcpool SVCPOOL; /* Kernel thread pool */ 857c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 867c478bd9Sstevel@tonic-gate typedef struct __svcxprt SVCXPRT; /* Server transport handle */ 877c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * Prototype of error handler callback 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate #ifndef _KERNEL 937c478bd9Sstevel@tonic-gate typedef void (*svc_errorhandler_t)(const SVCXPRT* svc, const bool_t isAConn); 947c478bd9Sstevel@tonic-gate #endif 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * Service request. 987c478bd9Sstevel@tonic-gate * 997c478bd9Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 1007c478bd9Sstevel@tonic-gate * svc_req 1017c478bd9Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 1027c478bd9Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate struct svc_req { 1057c478bd9Sstevel@tonic-gate rpcprog_t rq_prog; /* service program number */ 1067c478bd9Sstevel@tonic-gate rpcvers_t rq_vers; /* service protocol version */ 1077c478bd9Sstevel@tonic-gate rpcproc_t rq_proc; /* the desired procedure */ 1087c478bd9Sstevel@tonic-gate struct opaque_auth rq_cred; /* raw creds from the wire */ 1097c478bd9Sstevel@tonic-gate caddr_t rq_clntcred; /* read only cooked cred */ 1107c478bd9Sstevel@tonic-gate SVCXPRT *rq_xprt; /* associated transport */ 11145916cd2Sjpk bslabel_t *rq_label; /* TSOL label of the request */ 1127c478bd9Sstevel@tonic-gate }; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1157c478bd9Sstevel@tonic-gate struct dupreq { 1167c478bd9Sstevel@tonic-gate uint32_t dr_xid; 1177c478bd9Sstevel@tonic-gate rpcproc_t dr_proc; 1187c478bd9Sstevel@tonic-gate rpcvers_t dr_vers; 1197c478bd9Sstevel@tonic-gate rpcprog_t dr_prog; 1207c478bd9Sstevel@tonic-gate struct netbuf dr_addr; 1217c478bd9Sstevel@tonic-gate struct netbuf dr_resp; 1227c478bd9Sstevel@tonic-gate void (*dr_resfree)(); 1237c478bd9Sstevel@tonic-gate int dr_status; 1247c478bd9Sstevel@tonic-gate struct dupreq *dr_next; 1257c478bd9Sstevel@tonic-gate struct dupreq *dr_chain; 1267c478bd9Sstevel@tonic-gate }; 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* 1297c478bd9Sstevel@tonic-gate * States of requests for duplicate request caching. 1307c478bd9Sstevel@tonic-gate */ 1317c478bd9Sstevel@tonic-gate #define DUP_NEW 0x00 /* new entry */ 1327c478bd9Sstevel@tonic-gate #define DUP_INPROGRESS 0x01 /* request already going */ 1337c478bd9Sstevel@tonic-gate #define DUP_DONE 0x02 /* request done */ 1347c478bd9Sstevel@tonic-gate #define DUP_DROP 0x03 /* request dropped */ 1357c478bd9Sstevel@tonic-gate #define DUP_ERROR 0x04 /* error in dup req cache */ 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* 1387c478bd9Sstevel@tonic-gate * Prototype for a service dispatch routine. 1397c478bd9Sstevel@tonic-gate */ 1407c478bd9Sstevel@tonic-gate typedef void (SVC_DISPATCH)(struct svc_req *, SVCXPRT *); 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * The service provider callout. 1447c478bd9Sstevel@tonic-gate * Each entry identifies a dispatch routine to be called 1457c478bd9Sstevel@tonic-gate * for a given RPC program number and a version fitting 1467c478bd9Sstevel@tonic-gate * into the registered range. 1477c478bd9Sstevel@tonic-gate */ 1487c478bd9Sstevel@tonic-gate typedef struct { 1497c478bd9Sstevel@tonic-gate rpcprog_t sc_prog; /* RPC Program number */ 1507c478bd9Sstevel@tonic-gate rpcvers_t sc_versmin; /* Min version number */ 1517c478bd9Sstevel@tonic-gate rpcvers_t sc_versmax; /* Max version number */ 1527c478bd9Sstevel@tonic-gate SVC_DISPATCH *sc_dispatch; /* Dispatch routine */ 1537c478bd9Sstevel@tonic-gate } SVC_CALLOUT; 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate /* 1567c478bd9Sstevel@tonic-gate * Table of service provider `callouts' for an RPC 1577c478bd9Sstevel@tonic-gate * transport handle. If sct_free is TRUE then transport 1587c478bd9Sstevel@tonic-gate * destructor is supposed to deallocate this table. 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate typedef struct { 1617c478bd9Sstevel@tonic-gate size_t sct_size; /* Number of entries */ 1627c478bd9Sstevel@tonic-gate bool_t sct_free; /* Deallocate if true */ 1637c478bd9Sstevel@tonic-gate SVC_CALLOUT *sct_sc; /* Callout entries */ 1647c478bd9Sstevel@tonic-gate } SVC_CALLOUT_TABLE; 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate struct svc_ops { 1677c478bd9Sstevel@tonic-gate bool_t (*xp_recv)(SVCXPRT *, mblk_t *, struct rpc_msg *); 1687c478bd9Sstevel@tonic-gate /* receive incoming requests */ 1697c478bd9Sstevel@tonic-gate bool_t (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t); 1707c478bd9Sstevel@tonic-gate /* get arguments */ 1717c478bd9Sstevel@tonic-gate bool_t (*xp_reply)(SVCXPRT *, struct rpc_msg *); 1727c478bd9Sstevel@tonic-gate /* send reply */ 1737c478bd9Sstevel@tonic-gate bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t); 1747c478bd9Sstevel@tonic-gate /* free mem allocated for args */ 1757c478bd9Sstevel@tonic-gate void (*xp_destroy)(SVCMASTERXPRT *); 1767c478bd9Sstevel@tonic-gate /* destroy this struct */ 1777c478bd9Sstevel@tonic-gate int (*xp_dup)(struct svc_req *, caddr_t, int, 1787c478bd9Sstevel@tonic-gate struct dupreq **, bool_t *); 1797c478bd9Sstevel@tonic-gate /* check for dup */ 1807c478bd9Sstevel@tonic-gate void (*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int); 1817c478bd9Sstevel@tonic-gate /* mark dup entry as completed */ 1827c478bd9Sstevel@tonic-gate int32_t *(*xp_getres)(SVCXPRT *, int); 1837c478bd9Sstevel@tonic-gate /* get pointer to response buffer */ 1847c478bd9Sstevel@tonic-gate void (*xp_freeres)(SVCXPRT *); 1857c478bd9Sstevel@tonic-gate /* destroy pre-serialized response */ 1867c478bd9Sstevel@tonic-gate void (*xp_clone_destroy)(SVCXPRT *); 1877c478bd9Sstevel@tonic-gate /* destroy a clone xprt */ 1887c478bd9Sstevel@tonic-gate void (*xp_start)(SVCMASTERXPRT *); 1897c478bd9Sstevel@tonic-gate /* `ready-to-receive' */ 19060536ef9SKaren Rochford void (*xp_clone_xprt)(SVCXPRT *, SVCXPRT *); 19160536ef9SKaren Rochford /* transport specific clone function */ 1920a4b0810SKaren Rochford void (*xp_tattrs) (SVCXPRT *, int, void **); 1937c478bd9Sstevel@tonic-gate }; 1940a4b0810SKaren Rochford 1950a4b0810SKaren Rochford #define SVC_TATTR_ADDRMASK 1 1960a4b0810SKaren Rochford 1977c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 1987c478bd9Sstevel@tonic-gate /* 1997c478bd9Sstevel@tonic-gate * Service control requests 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate #define SVCGET_VERSQUIET 1 2027c478bd9Sstevel@tonic-gate #define SVCSET_VERSQUIET 2 2037c478bd9Sstevel@tonic-gate #define SVCGET_XID 4 2047c478bd9Sstevel@tonic-gate #define SVCSET_KEEPALIVE 5 2057c478bd9Sstevel@tonic-gate #define SVCSET_CONNMAXREC 6 2067c478bd9Sstevel@tonic-gate #define SVCGET_CONNMAXREC 7 2077c478bd9Sstevel@tonic-gate #define SVCGET_RECVERRHANDLER 8 2087c478bd9Sstevel@tonic-gate #define SVCSET_RECVERRHANDLER 9 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate enum xprt_stat { 2117c478bd9Sstevel@tonic-gate XPRT_DIED, 2127c478bd9Sstevel@tonic-gate XPRT_MOREREQS, 2137c478bd9Sstevel@tonic-gate XPRT_IDLE 2147c478bd9Sstevel@tonic-gate }; 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate struct xp_ops { 2177c478bd9Sstevel@tonic-gate #ifdef __STDC__ 2187c478bd9Sstevel@tonic-gate bool_t (*xp_recv)(SVCXPRT *, struct rpc_msg *); 2197c478bd9Sstevel@tonic-gate /* receive incoming requests */ 2207c478bd9Sstevel@tonic-gate enum xprt_stat (*xp_stat)(SVCXPRT *); 2217c478bd9Sstevel@tonic-gate /* get transport status */ 2227c478bd9Sstevel@tonic-gate bool_t (*xp_getargs)(SVCXPRT *, xdrproc_t, caddr_t); 2237c478bd9Sstevel@tonic-gate /* get arguments */ 2247c478bd9Sstevel@tonic-gate bool_t (*xp_reply)(SVCXPRT *, struct rpc_msg *); 2257c478bd9Sstevel@tonic-gate /* send reply */ 2267c478bd9Sstevel@tonic-gate bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t); 2277c478bd9Sstevel@tonic-gate /* free mem allocated for args */ 2287c478bd9Sstevel@tonic-gate void (*xp_destroy)(SVCXPRT *); 2297c478bd9Sstevel@tonic-gate /* destroy this struct */ 2307c478bd9Sstevel@tonic-gate bool_t (*xp_control)(SVCXPRT *, const uint_t, void *); 2317c478bd9Sstevel@tonic-gate /* catch-all control function */ 2327c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 2337c478bd9Sstevel@tonic-gate bool_t (*xp_recv)(); /* receive incoming requests */ 2347c478bd9Sstevel@tonic-gate enum xprt_stat (*xp_stat)(); /* get transport status */ 2357c478bd9Sstevel@tonic-gate bool_t (*xp_getargs)(); /* get arguments */ 2367c478bd9Sstevel@tonic-gate bool_t (*xp_reply)(); /* send reply */ 2377c478bd9Sstevel@tonic-gate bool_t (*xp_freeargs)(); /* free mem allocated for args */ 2387c478bd9Sstevel@tonic-gate void (*xp_destroy)(); /* destroy this struct */ 2397c478bd9Sstevel@tonic-gate bool_t (*xp_control)(); /* catch-all control function */ 2407c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 2417c478bd9Sstevel@tonic-gate }; 2427c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2457c478bd9Sstevel@tonic-gate /* 2467c478bd9Sstevel@tonic-gate * SVCPOOL 2477c478bd9Sstevel@tonic-gate * Kernel RPC server-side thread pool structure. 2487c478bd9Sstevel@tonic-gate */ 2497c478bd9Sstevel@tonic-gate typedef struct __svcxprt_qnode __SVCXPRT_QNODE; /* Defined in svc.c */ 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate struct __svcpool { 2527c478bd9Sstevel@tonic-gate /* 2537c478bd9Sstevel@tonic-gate * Thread pool variables. 2547c478bd9Sstevel@tonic-gate * 2557c478bd9Sstevel@tonic-gate * The pool's thread lock p_thread_lock protects: 2567c478bd9Sstevel@tonic-gate * - p_threads, p_detached_threads, p_reserved_threads and p_closing 2577c478bd9Sstevel@tonic-gate * The pool's request lock protects: 258*2695d4f4SMarcel Telka * - p_asleep, p_drowsy, p_reqs, p_size, p_walkers, p_req_cv. 2597c478bd9Sstevel@tonic-gate * The following fields are `initialized constants': 2607c478bd9Sstevel@tonic-gate * - p_id, p_stksize, p_timeout. 2617c478bd9Sstevel@tonic-gate * Access to p_next and p_prev is protected by the pool 2627c478bd9Sstevel@tonic-gate * list lock. 2637c478bd9Sstevel@tonic-gate */ 2647c478bd9Sstevel@tonic-gate SVCPOOL *p_next; /* Next pool in the list */ 2657c478bd9Sstevel@tonic-gate SVCPOOL *p_prev; /* Prev pool in the list */ 2667c478bd9Sstevel@tonic-gate int p_id; /* Pool id */ 2677c478bd9Sstevel@tonic-gate int p_threads; /* Non-detached threads */ 2687c478bd9Sstevel@tonic-gate int p_detached_threads; /* Detached threads */ 2697c478bd9Sstevel@tonic-gate int p_maxthreads; /* Max threads in the pool */ 2707c478bd9Sstevel@tonic-gate int p_redline; /* `Redline' for the pool */ 2717c478bd9Sstevel@tonic-gate int p_reserved_threads; /* Reserved threads */ 2727c478bd9Sstevel@tonic-gate kmutex_t p_thread_lock; /* Thread lock */ 2737c478bd9Sstevel@tonic-gate int p_asleep; /* Asleep threads */ 2747c478bd9Sstevel@tonic-gate int p_drowsy; /* Drowsy flag */ 2757c478bd9Sstevel@tonic-gate kcondvar_t p_req_cv; /* svc_poll() sleep var. */ 2767c478bd9Sstevel@tonic-gate clock_t p_timeout; /* svc_poll() timeout */ 2777c478bd9Sstevel@tonic-gate kmutex_t p_req_lock; /* Request lock */ 2787c478bd9Sstevel@tonic-gate int p_reqs; /* Pending requests */ 2797c478bd9Sstevel@tonic-gate int p_walkers; /* Walking threads */ 2807c478bd9Sstevel@tonic-gate int p_max_same_xprt; /* Max reqs from the xprt */ 2817c478bd9Sstevel@tonic-gate int p_stksize; /* Stack size for svc_run */ 2827c478bd9Sstevel@tonic-gate bool_t p_closing : 1; /* Pool is closing */ 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate /* 2857c478bd9Sstevel@tonic-gate * Thread creator variables. 2867c478bd9Sstevel@tonic-gate * The `creator signaled' flag is turned on when a signal is send 2877c478bd9Sstevel@tonic-gate * to the creator thread (to create a new service thread). The 2887c478bd9Sstevel@tonic-gate * creator clears when the thread is created. The protocol is not 2897c478bd9Sstevel@tonic-gate * to signal the creator thread when the flag is on. However, 2907c478bd9Sstevel@tonic-gate * a new thread should signal the creator if there are more 2917c478bd9Sstevel@tonic-gate * requests in the queue. 2927c478bd9Sstevel@tonic-gate * 2937c478bd9Sstevel@tonic-gate * When the pool is closing (ie it has been already unregistered from 2947c478bd9Sstevel@tonic-gate * the pool list) the last thread on the last transport should turn 2957c478bd9Sstevel@tonic-gate * the p_creator_exit flag on. This tells the creator thread to 2967c478bd9Sstevel@tonic-gate * free the pool structure and exit. 2977c478bd9Sstevel@tonic-gate */ 2987c478bd9Sstevel@tonic-gate bool_t p_creator_signaled : 1; /* Create requested flag */ 2997c478bd9Sstevel@tonic-gate bool_t p_creator_exit : 1; /* If true creator exits */ 3007c478bd9Sstevel@tonic-gate kcondvar_t p_creator_cv; /* Creator cond. variable */ 3017c478bd9Sstevel@tonic-gate kmutex_t p_creator_lock; /* Creator lock */ 3027c478bd9Sstevel@tonic-gate 3037c478bd9Sstevel@tonic-gate /* 3047c478bd9Sstevel@tonic-gate * Doubly linked list containing `registered' master transport handles. 3057c478bd9Sstevel@tonic-gate * There is no special structure for a list node. Instead the 3067c478bd9Sstevel@tonic-gate * SVCMASTERXPRT structure has the xp_next and xp_prev fields. 3077c478bd9Sstevel@tonic-gate * 3087c478bd9Sstevel@tonic-gate * The p_lrwlock protects access to xprt->xp_next and xprt->xp_prev. 3097c478bd9Sstevel@tonic-gate * A service thread should also acquire a reader lock before accessing 3107c478bd9Sstevel@tonic-gate * any transports it is no longer linked to (to prevent them from 3117c478bd9Sstevel@tonic-gate * being destroyed). 3127c478bd9Sstevel@tonic-gate * 3137c478bd9Sstevel@tonic-gate * The list lock governs also the `pool is closing' flag. 3147c478bd9Sstevel@tonic-gate */ 3157c478bd9Sstevel@tonic-gate size_t p_lcount; /* Current count */ 3167c478bd9Sstevel@tonic-gate SVCMASTERXPRT *p_lhead; /* List head */ 3177c478bd9Sstevel@tonic-gate krwlock_t p_lrwlock; /* R/W lock */ 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate /* 3207c478bd9Sstevel@tonic-gate * Circular linked list for the `xprt-ready' queue (FIFO). 3217c478bd9Sstevel@tonic-gate * Must be initialized with svc_xprt_qinit() before it is used. 3227c478bd9Sstevel@tonic-gate * 3237c478bd9Sstevel@tonic-gate * The writer's end is protected by the pool's request lock 3247c478bd9Sstevel@tonic-gate * (pool->p_req_lock). The reader's end is protected by q_end_lock. 3257c478bd9Sstevel@tonic-gate * 3267c478bd9Sstevel@tonic-gate * When the queue is full the p_qoverflow flag is raised. It stays 3277c478bd9Sstevel@tonic-gate * on until all the pending request are drained. 3287c478bd9Sstevel@tonic-gate */ 3297c478bd9Sstevel@tonic-gate size_t p_qsize; /* Number of queue nodes */ 3307c478bd9Sstevel@tonic-gate int p_qoverflow : 1; /* Overflow flag */ 3317c478bd9Sstevel@tonic-gate __SVCXPRT_QNODE *p_qbody; /* Queue body (array) */ 3327c478bd9Sstevel@tonic-gate __SVCXPRT_QNODE *p_qtop; /* Writer's end of FIFO */ 3337c478bd9Sstevel@tonic-gate __SVCXPRT_QNODE *p_qend; /* Reader's end of FIFO */ 3347c478bd9Sstevel@tonic-gate kmutex_t p_qend_lock; /* Reader's end lock */ 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate /* 3377c478bd9Sstevel@tonic-gate * Userspace thread creator variables. 3387c478bd9Sstevel@tonic-gate * Thread creation is actually done in userland, via a thread 3397c478bd9Sstevel@tonic-gate * that is parked in the kernel. When that thread is signaled, 3407c478bd9Sstevel@tonic-gate * it returns back down to the daemon from whence it came and 3417c478bd9Sstevel@tonic-gate * does the lwp create. 3427c478bd9Sstevel@tonic-gate * 3437c478bd9Sstevel@tonic-gate * A parallel "creator" thread runs in the kernel. That is the 3447c478bd9Sstevel@tonic-gate * thread that will signal for the user thread to return to 3457c478bd9Sstevel@tonic-gate * userland and do its work. 3467c478bd9Sstevel@tonic-gate * 3477c478bd9Sstevel@tonic-gate * Since the thread doesn't always exist (there could be a race 3487c478bd9Sstevel@tonic-gate * if two threads are created in rapid succession), we set 3497c478bd9Sstevel@tonic-gate * p_signal_create_thread to FALSE when we're ready to accept work. 3507c478bd9Sstevel@tonic-gate * 3517c478bd9Sstevel@tonic-gate * p_user_exit is set to true when the service pool is about 3527c478bd9Sstevel@tonic-gate * to close. This is done so that the user creation thread 3537c478bd9Sstevel@tonic-gate * can be informed and cleanup any userland state. 3547c478bd9Sstevel@tonic-gate */ 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate bool_t p_signal_create_thread : 1; /* Create requested flag */ 3577c478bd9Sstevel@tonic-gate bool_t p_user_exit : 1; /* If true creator exits */ 3587c478bd9Sstevel@tonic-gate bool_t p_user_waiting : 1; /* Thread waiting for work */ 3597c478bd9Sstevel@tonic-gate kcondvar_t p_user_cv; /* Creator cond. variable */ 3607c478bd9Sstevel@tonic-gate kmutex_t p_user_lock; /* Creator lock */ 3617c478bd9Sstevel@tonic-gate void (*p_offline)(); /* callout for unregister */ 3627c478bd9Sstevel@tonic-gate void (*p_shutdown)(); /* callout for shutdown */ 363*2695d4f4SMarcel Telka 364*2695d4f4SMarcel Telka size_t p_size; /* Total size of queued msgs */ 3657c478bd9Sstevel@tonic-gate }; 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate /* 3687c478bd9Sstevel@tonic-gate * Server side transport handle (SVCMASTERXPRT). 3697c478bd9Sstevel@tonic-gate * xprt->xp_req_lock governs the following fields in xprt: 3707c478bd9Sstevel@tonic-gate * xp_req_head, xp_req_tail. 3717c478bd9Sstevel@tonic-gate * xprt->xp_thread_lock governs the following fields in xprt: 3727c478bd9Sstevel@tonic-gate * xp_threads, xp_detached_threads. 3737c478bd9Sstevel@tonic-gate * 3747c478bd9Sstevel@tonic-gate * xp_req_tail is only valid if xp_req_head is non-NULL 3757c478bd9Sstevel@tonic-gate * 3767c478bd9Sstevel@tonic-gate * The xp_threads count is the number of attached threads. These threads 3777c478bd9Sstevel@tonic-gate * are able to handle new requests, and it is expected that they will not 3787c478bd9Sstevel@tonic-gate * block for a very long time handling a given request. The 3797c478bd9Sstevel@tonic-gate * xp_detached_threads count is the number of threads that have detached 3807c478bd9Sstevel@tonic-gate * themselves from the transport. These threads can block indefinitely 3817c478bd9Sstevel@tonic-gate * while handling a request. Once they complete the request, they exit. 3827c478bd9Sstevel@tonic-gate * 3837c478bd9Sstevel@tonic-gate * A kernel service provider may register a callback function "closeproc" 3847c478bd9Sstevel@tonic-gate * for a transport. When the transport is closing the last exiting attached 3857c478bd9Sstevel@tonic-gate * thread - xp_threads goes to zero - it calls the callback function, passing 3867c478bd9Sstevel@tonic-gate * it a reference to the transport. This call is made with xp_thread_lock 3877c478bd9Sstevel@tonic-gate * held, so any cleanup bookkeeping it does should be done quickly. 3887c478bd9Sstevel@tonic-gate * 3897c478bd9Sstevel@tonic-gate * When the transport is closing the last exiting thread is supposed 3907c478bd9Sstevel@tonic-gate * to destroy/free the data structure. 3917c478bd9Sstevel@tonic-gate */ 3927c478bd9Sstevel@tonic-gate typedef struct __svcxprt_common { 3937c478bd9Sstevel@tonic-gate struct file *xpc_fp; 3947c478bd9Sstevel@tonic-gate struct svc_ops *xpc_ops; 3957c478bd9Sstevel@tonic-gate queue_t *xpc_wq; /* queue to write onto */ 3967c478bd9Sstevel@tonic-gate cred_t *xpc_cred; /* cached cred for server to use */ 3977c478bd9Sstevel@tonic-gate int32_t xpc_type; /* transport type */ 3987c478bd9Sstevel@tonic-gate int xpc_msg_size; /* TSDU or TIDU size */ 3997c478bd9Sstevel@tonic-gate struct netbuf xpc_rtaddr; /* remote transport address */ 400e810a982Svv149972 struct netbuf xpc_lcladdr; /* local transport address */ 4017523bef8SSiddheshwar Mahesh char *xpc_netid; /* network token */ 4027c478bd9Sstevel@tonic-gate SVC_CALLOUT_TABLE *xpc_sct; 4037c478bd9Sstevel@tonic-gate } __SVCXPRT_COMMON; 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate #define xp_fp xp_xpc.xpc_fp 4067c478bd9Sstevel@tonic-gate #define xp_ops xp_xpc.xpc_ops 4077c478bd9Sstevel@tonic-gate #define xp_wq xp_xpc.xpc_wq 4087c478bd9Sstevel@tonic-gate #define xp_cred xp_xpc.xpc_cred 4097c478bd9Sstevel@tonic-gate #define xp_type xp_xpc.xpc_type 4107c478bd9Sstevel@tonic-gate #define xp_msg_size xp_xpc.xpc_msg_size 4117c478bd9Sstevel@tonic-gate #define xp_rtaddr xp_xpc.xpc_rtaddr 412e810a982Svv149972 #define xp_lcladdr xp_xpc.xpc_lcladdr 4137c478bd9Sstevel@tonic-gate #define xp_sct xp_xpc.xpc_sct 4147523bef8SSiddheshwar Mahesh #define xp_netid xp_xpc.xpc_netid 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate struct __svcmasterxprt { 4177c478bd9Sstevel@tonic-gate SVCMASTERXPRT *xp_next; /* Next transport in the list */ 4187c478bd9Sstevel@tonic-gate SVCMASTERXPRT *xp_prev; /* Prev transport in the list */ 4197c478bd9Sstevel@tonic-gate __SVCXPRT_COMMON xp_xpc; /* Fields common with the clone */ 4207c478bd9Sstevel@tonic-gate SVCPOOL *xp_pool; /* Pointer to the pool */ 4217c478bd9Sstevel@tonic-gate mblk_t *xp_req_head; /* Request queue head */ 4227c478bd9Sstevel@tonic-gate mblk_t *xp_req_tail; /* Request queue tail */ 4237c478bd9Sstevel@tonic-gate kmutex_t xp_req_lock; /* Request lock */ 4247c478bd9Sstevel@tonic-gate int xp_threads; /* Current num. of attached threads */ 4257c478bd9Sstevel@tonic-gate int xp_detached_threads; /* num. of detached threads */ 4267c478bd9Sstevel@tonic-gate kmutex_t xp_thread_lock; /* Thread count lock */ 4277c478bd9Sstevel@tonic-gate void (*xp_closeproc)(const SVCMASTERXPRT *); 4287c478bd9Sstevel@tonic-gate /* optional; see comments above */ 4297c478bd9Sstevel@tonic-gate struct netbuf xp_addrmask; /* address mask */ 4307c478bd9Sstevel@tonic-gate 4317c478bd9Sstevel@tonic-gate caddr_t xp_p2; /* private: for use by svc ops */ 432*2695d4f4SMarcel Telka 433*2695d4f4SMarcel Telka int xp_full : 1; /* xprt is full */ 434*2695d4f4SMarcel Telka int xp_enable : 1; /* xprt needs to be enabled */ 435*2695d4f4SMarcel Telka int xp_reqs; /* number of requests queued */ 436*2695d4f4SMarcel Telka size_t xp_size; /* total size of queued msgs */ 4377c478bd9Sstevel@tonic-gate }; 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate /* 4407c478bd9Sstevel@tonic-gate * Service thread `clone' transport handle (SVCXPRT) 4417c478bd9Sstevel@tonic-gate * 4427c478bd9Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 4437c478bd9Sstevel@tonic-gate * SVCXPRT 4447c478bd9Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 4457c478bd9Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 4467c478bd9Sstevel@tonic-gate * 4477c478bd9Sstevel@tonic-gate * The xp_p2buf buffer is used as the storage for a transport type 4487c478bd9Sstevel@tonic-gate * specific structure. It is private for the svc ops for a given 4497c478bd9Sstevel@tonic-gate * transport type. 4507c478bd9Sstevel@tonic-gate */ 4517c478bd9Sstevel@tonic-gate 4520a701b1eSRobert Gordon #define SVC_P2LEN 128 4537c478bd9Sstevel@tonic-gate 4547c478bd9Sstevel@tonic-gate struct __svcxprt { 4557c478bd9Sstevel@tonic-gate __SVCXPRT_COMMON xp_xpc; 4567c478bd9Sstevel@tonic-gate SVCMASTERXPRT *xp_master; /* back ptr to master */ 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate /* The following fileds are on a per-thread basis */ 4597c478bd9Sstevel@tonic-gate callb_cpr_t *xp_cprp; /* unused padding for Contract */ 4607c478bd9Sstevel@tonic-gate bool_t xp_reserved : 1; /* is thread reserved? */ 4617c478bd9Sstevel@tonic-gate bool_t xp_detached : 1; /* is thread detached? */ 4627c478bd9Sstevel@tonic-gate int xp_same_xprt; /* Reqs from the same xprt */ 4637c478bd9Sstevel@tonic-gate 4647c478bd9Sstevel@tonic-gate /* The following fields are used on a per-request basis */ 4657c478bd9Sstevel@tonic-gate struct opaque_auth xp_verf; /* raw response verifier */ 4667c478bd9Sstevel@tonic-gate SVCAUTH xp_auth; /* auth flavor of current req */ 4677c478bd9Sstevel@tonic-gate void *xp_cookie; /* a cookie */ 4687c478bd9Sstevel@tonic-gate uint32_t xp_xid; /* id */ 4697c478bd9Sstevel@tonic-gate XDR xp_xdrin; /* input xdr stream */ 4707c478bd9Sstevel@tonic-gate XDR xp_xdrout; /* output xdr stream */ 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate /* Private for svc ops */ 4737c478bd9Sstevel@tonic-gate char xp_p2buf[SVC_P2LEN]; /* udp_data or cots_data_t */ 4747c478bd9Sstevel@tonic-gate /* or clone_rdma_data_t */ 4757c478bd9Sstevel@tonic-gate }; 4767c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 4777c478bd9Sstevel@tonic-gate struct __svcxprt { 4787c478bd9Sstevel@tonic-gate int xp_fd; 4797c478bd9Sstevel@tonic-gate #define xp_sock xp_fd 4807c478bd9Sstevel@tonic-gate ushort_t xp_port; 4817c478bd9Sstevel@tonic-gate /* 4827c478bd9Sstevel@tonic-gate * associated port number. 4837c478bd9Sstevel@tonic-gate * Obsolete, but still used to 4847c478bd9Sstevel@tonic-gate * specify whether rendezvouser 4857c478bd9Sstevel@tonic-gate * or normal connection 4867c478bd9Sstevel@tonic-gate */ 4877c478bd9Sstevel@tonic-gate struct xp_ops *xp_ops; 4887c478bd9Sstevel@tonic-gate int xp_addrlen; /* length of remote addr. Obsoleted */ 4897c478bd9Sstevel@tonic-gate char *xp_tp; /* transport provider device name */ 4907c478bd9Sstevel@tonic-gate char *xp_netid; /* network token */ 4917c478bd9Sstevel@tonic-gate struct netbuf xp_ltaddr; /* local transport address */ 4927c478bd9Sstevel@tonic-gate struct netbuf xp_rtaddr; /* remote transport address */ 4937c478bd9Sstevel@tonic-gate char xp_raddr[16]; /* remote address. Now obsoleted */ 4947c478bd9Sstevel@tonic-gate struct opaque_auth xp_verf; /* raw response verifier */ 4957c478bd9Sstevel@tonic-gate caddr_t xp_p1; /* private: for use by svc ops */ 4967c478bd9Sstevel@tonic-gate caddr_t xp_p2; /* private: for use by svc ops */ 4977c478bd9Sstevel@tonic-gate caddr_t xp_p3; /* private: for use by svc lib */ 4987c478bd9Sstevel@tonic-gate int xp_type; /* transport type */ 4997c478bd9Sstevel@tonic-gate /* 5007c478bd9Sstevel@tonic-gate * callback on client death 5017c478bd9Sstevel@tonic-gate * First parameter is the current structure, 5027c478bd9Sstevel@tonic-gate * Second parameter : 5037c478bd9Sstevel@tonic-gate * - FALSE for the service listener 5047c478bd9Sstevel@tonic-gate * - TRUE for a real connected socket 5057c478bd9Sstevel@tonic-gate */ 5067c478bd9Sstevel@tonic-gate svc_errorhandler_t xp_closeclnt; 5077c478bd9Sstevel@tonic-gate }; 5087c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 5097c478bd9Sstevel@tonic-gate 5107c478bd9Sstevel@tonic-gate /* 5117c478bd9Sstevel@tonic-gate * Approved way of getting address of caller, 5127c478bd9Sstevel@tonic-gate * address mask, and netid of transport. 5137c478bd9Sstevel@tonic-gate */ 5147c478bd9Sstevel@tonic-gate #define svc_getrpccaller(x) (&(x)->xp_rtaddr) 5157c478bd9Sstevel@tonic-gate #ifdef _KERNEL 5167c478bd9Sstevel@tonic-gate #define svc_getcaller(x) (&(x)->xp_rtaddr.buf) 5177c478bd9Sstevel@tonic-gate #define svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask) 5187523bef8SSiddheshwar Mahesh #define svc_getnetid(x) ((x)->xp_netid) 5197c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate /* 5227c478bd9Sstevel@tonic-gate * Operations defined on an SVCXPRT handle 5237c478bd9Sstevel@tonic-gate */ 5247c478bd9Sstevel@tonic-gate 5257c478bd9Sstevel@tonic-gate #ifdef _KERNEL 52660536ef9SKaren Rochford 5270a4b0810SKaren Rochford #define SVC_GETADDRMASK(clone_xprt, attrflag, tattr) \ 5280a4b0810SKaren Rochford (*(clone_xprt)->xp_ops->xp_tattrs)((clone_xprt), (attrflag), (tattr)) 5290a4b0810SKaren Rochford 53060536ef9SKaren Rochford #define SVC_CLONE_XPRT(src_xprt, dst_xprt) \ 53160536ef9SKaren Rochford if ((src_xprt)->xp_ops->xp_clone_xprt) \ 53260536ef9SKaren Rochford (*(src_xprt)->xp_ops->xp_clone_xprt) \ 53360536ef9SKaren Rochford (src_xprt, dst_xprt) 53460536ef9SKaren Rochford 5357c478bd9Sstevel@tonic-gate #define SVC_RECV(clone_xprt, mp, msg) \ 5367c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg)) 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate /* 5397c478bd9Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 5407c478bd9Sstevel@tonic-gate * SVC_GETARGS 5417c478bd9Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 5427c478bd9Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 5437c478bd9Sstevel@tonic-gate */ 5447c478bd9Sstevel@tonic-gate #define SVC_GETARGS(clone_xprt, xargs, argsp) \ 5457c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp)) 5467c478bd9Sstevel@tonic-gate 5477c478bd9Sstevel@tonic-gate #define SVC_REPLY(clone_xprt, msg) \ 5487c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg)) 5497c478bd9Sstevel@tonic-gate 5507c478bd9Sstevel@tonic-gate #define SVC_FREEARGS(clone_xprt, xargs, argsp) \ 5517c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp)) 5527c478bd9Sstevel@tonic-gate 5537c478bd9Sstevel@tonic-gate #define SVC_GETRES(clone_xprt, size) \ 5547c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size)) 5557c478bd9Sstevel@tonic-gate 5567c478bd9Sstevel@tonic-gate #define SVC_FREERES(clone_xprt) \ 5577c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_freeres)(clone_xprt) 5587c478bd9Sstevel@tonic-gate 5597c478bd9Sstevel@tonic-gate #define SVC_DESTROY(xprt) \ 5607c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_destroy)(xprt) 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate /* 5637c478bd9Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interfaces 5647c478bd9Sstevel@tonic-gate * SVC_DUP, SVC_DUPDONE, SVC_DUP_EXT, SVC_DUPDONE_EXT 5657c478bd9Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 5667c478bd9Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 5677c478bd9Sstevel@tonic-gate * 5687c478bd9Sstevel@tonic-gate * SVC_DUP and SVC_DUPDONE are defined here for backward compatibility. 5697c478bd9Sstevel@tonic-gate */ 5707c478bd9Sstevel@tonic-gate #define SVC_DUP_EXT(clone_xprt, req, res, size, drpp, dupcachedp) \ 5717c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, dupcachedp) 5727c478bd9Sstevel@tonic-gate 5737c478bd9Sstevel@tonic-gate #define SVC_DUPDONE_EXT(clone_xprt, dr, res, resfree, size, status) \ 5747c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, resfree, size, status) 5757c478bd9Sstevel@tonic-gate 5767c478bd9Sstevel@tonic-gate #define SVC_DUP(clone_xprt, req, res, size, drpp) \ 5777c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_dup)(req, res, size, drpp, NULL) 5787c478bd9Sstevel@tonic-gate 5797c478bd9Sstevel@tonic-gate #define SVC_DUPDONE(clone_xprt, dr, res, size, status) \ 5807c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_dupdone)(dr, res, NULL, size, status) 5817c478bd9Sstevel@tonic-gate 5827c478bd9Sstevel@tonic-gate #define SVC_CLONE_DESTROY(clone_xprt) \ 5837c478bd9Sstevel@tonic-gate (*(clone_xprt)->xp_ops->xp_clone_destroy)(clone_xprt) 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate 5867c478bd9Sstevel@tonic-gate #define SVC_START(xprt) \ 5877c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_start)(xprt) 5887c478bd9Sstevel@tonic-gate 5897c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate #define SVC_RECV(xprt, msg) \ 5927c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 5937c478bd9Sstevel@tonic-gate #define svc_recv(xprt, msg) \ 5947c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) 5957c478bd9Sstevel@tonic-gate 5967c478bd9Sstevel@tonic-gate #define SVC_STAT(xprt) \ 5977c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_stat)(xprt) 5987c478bd9Sstevel@tonic-gate #define svc_stat(xprt) \ 5997c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_stat)(xprt) 6007c478bd9Sstevel@tonic-gate 6017c478bd9Sstevel@tonic-gate #define SVC_GETARGS(xprt, xargs, argsp) \ 6027c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) 6037c478bd9Sstevel@tonic-gate #define svc_getargs(xprt, xargs, argsp) \ 6047c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) 6057c478bd9Sstevel@tonic-gate 6067c478bd9Sstevel@tonic-gate #define SVC_REPLY(xprt, msg) \ 6077c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 6087c478bd9Sstevel@tonic-gate #define svc_reply(xprt, msg) \ 6097c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) 6107c478bd9Sstevel@tonic-gate 6117c478bd9Sstevel@tonic-gate #define SVC_FREEARGS(xprt, xargs, argsp) \ 6127c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) 6137c478bd9Sstevel@tonic-gate #define svc_freeargs(xprt, xargs, argsp) \ 6147c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) 6157c478bd9Sstevel@tonic-gate 6167c478bd9Sstevel@tonic-gate #define SVC_GETRES(xprt, size) \ 6177c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_getres)((xprt), (size)) 6187c478bd9Sstevel@tonic-gate #define svc_getres(xprt, size) \ 6197c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_getres)((xprt), (size)) 6207c478bd9Sstevel@tonic-gate 6217c478bd9Sstevel@tonic-gate #define SVC_FREERES(xprt) \ 6227c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_freeres)(xprt) 6237c478bd9Sstevel@tonic-gate #define svc_freeres(xprt) \ 6247c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_freeres)(xprt) 6257c478bd9Sstevel@tonic-gate 6267c478bd9Sstevel@tonic-gate #define SVC_DESTROY(xprt) \ 6277c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_destroy)(xprt) 6287c478bd9Sstevel@tonic-gate #define svc_destroy(xprt) \ 6297c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_destroy)(xprt) 6307c478bd9Sstevel@tonic-gate 6317c478bd9Sstevel@tonic-gate /* 6327c478bd9Sstevel@tonic-gate * PSARC 2003/523 Contract Private Interface 6337c478bd9Sstevel@tonic-gate * SVC_CONTROL 6347c478bd9Sstevel@tonic-gate * Changes must be reviewed by Solaris File Sharing 6357c478bd9Sstevel@tonic-gate * Changes must be communicated to contract-2003-523@sun.com 6367c478bd9Sstevel@tonic-gate */ 6377c478bd9Sstevel@tonic-gate #define SVC_CONTROL(xprt, rq, in) \ 6387c478bd9Sstevel@tonic-gate (*(xprt)->xp_ops->xp_control)((xprt), (rq), (in)) 6397c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 6407c478bd9Sstevel@tonic-gate 6417c478bd9Sstevel@tonic-gate /* 6427c478bd9Sstevel@tonic-gate * Pool id's reserved for NFS, NLM, and the NFSv4 callback program. 6437c478bd9Sstevel@tonic-gate */ 6447c478bd9Sstevel@tonic-gate #define NFS_SVCPOOL_ID 0x01 6457c478bd9Sstevel@tonic-gate #define NLM_SVCPOOL_ID 0x02 6467c478bd9Sstevel@tonic-gate #define NFS_CB_SVCPOOL_ID 0x03 6477c478bd9Sstevel@tonic-gate #define RDC_SVCPOOL_ID 0x05 /* SNDR, PSARC 2001/699 */ 6487c478bd9Sstevel@tonic-gate 6497c478bd9Sstevel@tonic-gate struct svcpool_args { 6507c478bd9Sstevel@tonic-gate uint32_t id; /* Pool id */ 6517c478bd9Sstevel@tonic-gate uint32_t maxthreads; /* Max threads in the pool */ 6527c478bd9Sstevel@tonic-gate uint32_t redline; /* `Redline' for the pool */ 6537c478bd9Sstevel@tonic-gate uint32_t qsize; /* `xprt-ready' queue size */ 6547c478bd9Sstevel@tonic-gate uint32_t timeout; /* svc_poll() timeout */ 6557c478bd9Sstevel@tonic-gate uint32_t stksize; /* svc_run() stack size */ 6567c478bd9Sstevel@tonic-gate uint32_t max_same_xprt; /* Max reqs from the same xprt */ 6577c478bd9Sstevel@tonic-gate }; 6587c478bd9Sstevel@tonic-gate 6597c478bd9Sstevel@tonic-gate 6607c478bd9Sstevel@tonic-gate #ifdef _KERNEL 6617c478bd9Sstevel@tonic-gate /* 6627c478bd9Sstevel@tonic-gate * Transport registration and thread pool creation. 6637c478bd9Sstevel@tonic-gate */ 6647c478bd9Sstevel@tonic-gate extern int svc_xprt_register(SVCMASTERXPRT *, int); 6657c478bd9Sstevel@tonic-gate extern void svc_xprt_unregister(SVCMASTERXPRT *); 6667c478bd9Sstevel@tonic-gate extern int svc_pool_create(struct svcpool_args *); 6677c478bd9Sstevel@tonic-gate extern int svc_wait(int); 6687c478bd9Sstevel@tonic-gate extern int svc_do_run(int); 6697c478bd9Sstevel@tonic-gate #define SVCPSET_SHUTDOWN_PROC 1 6707c478bd9Sstevel@tonic-gate #define SVCPSET_UNREGISTER_PROC 2 6717c478bd9Sstevel@tonic-gate extern int svc_pool_control(int, int, void *); 6727c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 6737c478bd9Sstevel@tonic-gate #ifdef __STDC__ 6747c478bd9Sstevel@tonic-gate extern bool_t rpc_reg(const rpcprog_t, const rpcvers_t, const rpcproc_t, 6757c478bd9Sstevel@tonic-gate char *(*)(char *), const xdrproc_t, const xdrproc_t, 6767c478bd9Sstevel@tonic-gate const char *); 6777c478bd9Sstevel@tonic-gate 6787c478bd9Sstevel@tonic-gate /* 6797c478bd9Sstevel@tonic-gate * Service registration 6807c478bd9Sstevel@tonic-gate * 6817c478bd9Sstevel@tonic-gate * svc_reg(xprt, prog, vers, dispatch, nconf) 6827c478bd9Sstevel@tonic-gate * const SVCXPRT *xprt; 6837c478bd9Sstevel@tonic-gate * const rpcprog_t prog; 6847c478bd9Sstevel@tonic-gate * const rpcvers_t vers; 6857c478bd9Sstevel@tonic-gate * const void (*dispatch)(); 6867c478bd9Sstevel@tonic-gate * const struct netconfig *nconf; 6877c478bd9Sstevel@tonic-gate */ 6887c478bd9Sstevel@tonic-gate extern bool_t svc_reg(const SVCXPRT *, const rpcprog_t, const rpcvers_t, 6897c478bd9Sstevel@tonic-gate void (*)(struct svc_req *, SVCXPRT *), 6907c478bd9Sstevel@tonic-gate const struct netconfig *); 6917c478bd9Sstevel@tonic-gate 6927c478bd9Sstevel@tonic-gate /* 6937c478bd9Sstevel@tonic-gate * Service authentication registration 6947c478bd9Sstevel@tonic-gate * 6957c478bd9Sstevel@tonic-gate * svc_auth_reg(cred_flavor, handler) 6967c478bd9Sstevel@tonic-gate * int cred_flavor; 6977c478bd9Sstevel@tonic-gate * enum auth_stat (*handler)(); 6987c478bd9Sstevel@tonic-gate */ 6997c478bd9Sstevel@tonic-gate extern int svc_auth_reg(int, enum auth_stat (*)()); 7007c478bd9Sstevel@tonic-gate 7017c478bd9Sstevel@tonic-gate /* 7027c478bd9Sstevel@tonic-gate * Service un-registration 7037c478bd9Sstevel@tonic-gate * 7047c478bd9Sstevel@tonic-gate * svc_unreg(prog, vers) 7057c478bd9Sstevel@tonic-gate * const rpcprog_t prog; 7067c478bd9Sstevel@tonic-gate * const rpcvers_t vers; 7077c478bd9Sstevel@tonic-gate */ 7087c478bd9Sstevel@tonic-gate extern void svc_unreg(const rpcprog_t, const rpcvers_t); 7097c478bd9Sstevel@tonic-gate 7107c478bd9Sstevel@tonic-gate /* 7117c478bd9Sstevel@tonic-gate * Transport registration/unregistration. 7127c478bd9Sstevel@tonic-gate * 7137c478bd9Sstevel@tonic-gate * xprt_register(xprt) 7147c478bd9Sstevel@tonic-gate * const SVCXPRT *xprt; 7157c478bd9Sstevel@tonic-gate * 7167c478bd9Sstevel@tonic-gate * xprt_unregister(xprt) 7177c478bd9Sstevel@tonic-gate * const SVCXPRT *xprt; 7187c478bd9Sstevel@tonic-gate */ 7197c478bd9Sstevel@tonic-gate extern void xprt_register(const SVCXPRT *); 7207c478bd9Sstevel@tonic-gate extern void xprt_unregister(const SVCXPRT *); 7217c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 7227c478bd9Sstevel@tonic-gate extern bool_t rpc_reg(); 7237c478bd9Sstevel@tonic-gate extern bool_t svc_reg(); 7247c478bd9Sstevel@tonic-gate extern bool_t svc_auth_reg(); 7257c478bd9Sstevel@tonic-gate extern void svc_unreg(); 7267c478bd9Sstevel@tonic-gate extern void xprt_register(); 7277c478bd9Sstevel@tonic-gate extern void xprt_unregister(); 7287c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 7297c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 7307c478bd9Sstevel@tonic-gate 7317c478bd9Sstevel@tonic-gate 7327c478bd9Sstevel@tonic-gate /* 7337c478bd9Sstevel@tonic-gate * When the service routine is called, it must first check to see if it 7347c478bd9Sstevel@tonic-gate * knows about the procedure; if not, it should call svcerr_noproc 7357c478bd9Sstevel@tonic-gate * and return. If so, it should deserialize its arguments via 7367c478bd9Sstevel@tonic-gate * SVC_GETARGS (defined above). If the deserialization does not work, 7377c478bd9Sstevel@tonic-gate * svcerr_decode should be called followed by a return. Successful 7387c478bd9Sstevel@tonic-gate * decoding of the arguments should be followed the execution of the 7397c478bd9Sstevel@tonic-gate * procedure's code and a call to svc_sendreply. 7407c478bd9Sstevel@tonic-gate * 7417c478bd9Sstevel@tonic-gate * Also, if the service refuses to execute the procedure due to too- 7427c478bd9Sstevel@tonic-gate * weak authentication parameters, svcerr_weakauth should be called. 7437c478bd9Sstevel@tonic-gate * Note: do not confuse access-control failure with weak authentication! 7447c478bd9Sstevel@tonic-gate * 7457c478bd9Sstevel@tonic-gate * NB: In pure implementations of rpc, the caller always waits for a reply 7467c478bd9Sstevel@tonic-gate * msg. This message is sent when svc_sendreply is called. 7477c478bd9Sstevel@tonic-gate * Therefore pure service implementations should always call 7487c478bd9Sstevel@tonic-gate * svc_sendreply even if the function logically returns void; use 7497c478bd9Sstevel@tonic-gate * xdr.h - xdr_void for the xdr routine. HOWEVER, connectionful rpc allows 7507c478bd9Sstevel@tonic-gate * for the abuse of pure rpc via batched calling or pipelining. In the 7517c478bd9Sstevel@tonic-gate * case of a batched call, svc_sendreply should NOT be called since 7527c478bd9Sstevel@tonic-gate * this would send a return message, which is what batching tries to avoid. 7537c478bd9Sstevel@tonic-gate * It is the service/protocol writer's responsibility to know which calls are 7547c478bd9Sstevel@tonic-gate * batched and which are not. Warning: responding to batch calls may 7557c478bd9Sstevel@tonic-gate * deadlock the caller and server processes! 7567c478bd9Sstevel@tonic-gate */ 7577c478bd9Sstevel@tonic-gate #ifdef __STDC__ 7587c478bd9Sstevel@tonic-gate extern bool_t svc_sendreply(const SVCXPRT *, const xdrproc_t, const caddr_t); 7597c478bd9Sstevel@tonic-gate extern void svcerr_decode(const SVCXPRT *); 7607c478bd9Sstevel@tonic-gate extern void svcerr_weakauth(const SVCXPRT *); 7617c478bd9Sstevel@tonic-gate extern void svcerr_noproc(const SVCXPRT *); 7627c478bd9Sstevel@tonic-gate extern void svcerr_progvers(const SVCXPRT *, const rpcvers_t, 7637c478bd9Sstevel@tonic-gate const rpcvers_t); 7647c478bd9Sstevel@tonic-gate extern void svcerr_auth(const SVCXPRT *, const enum auth_stat); 7657c478bd9Sstevel@tonic-gate extern void svcerr_noprog(const SVCXPRT *); 7667c478bd9Sstevel@tonic-gate extern void svcerr_systemerr(const SVCXPRT *); 7672e9d26a4Srmesta extern void svcerr_badcred(const SVCXPRT *); 7687c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 7697c478bd9Sstevel@tonic-gate extern bool_t svc_sendreply(); 7707c478bd9Sstevel@tonic-gate extern void svcerr_decode(); 7717c478bd9Sstevel@tonic-gate extern void svcerr_weakauth(); 7727c478bd9Sstevel@tonic-gate extern void svcerr_noproc(); 7737c478bd9Sstevel@tonic-gate extern void svcerr_progvers(); 7747c478bd9Sstevel@tonic-gate extern void svcerr_auth(); 7757c478bd9Sstevel@tonic-gate extern void svcerr_noprog(); 7767c478bd9Sstevel@tonic-gate extern void svcerr_systemerr(); 7772e9d26a4Srmesta extern void svcerr_badcred(); 7787c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 7797c478bd9Sstevel@tonic-gate 7807c478bd9Sstevel@tonic-gate #ifdef _KERNEL 7817c478bd9Sstevel@tonic-gate /* 7827c478bd9Sstevel@tonic-gate * Kernel RPC functions. 7837c478bd9Sstevel@tonic-gate */ 7847c478bd9Sstevel@tonic-gate extern void svc_init(void); 7857c478bd9Sstevel@tonic-gate extern void svc_cots_init(void); 7867c478bd9Sstevel@tonic-gate extern void svc_clts_init(void); 7877c478bd9Sstevel@tonic-gate extern void mt_kstat_init(void); 7887c478bd9Sstevel@tonic-gate extern void mt_kstat_fini(void); 7897c478bd9Sstevel@tonic-gate extern int svc_tli_kcreate(struct file *, uint_t, char *, 7907c478bd9Sstevel@tonic-gate struct netbuf *, SVCMASTERXPRT **, 7917c478bd9Sstevel@tonic-gate SVC_CALLOUT_TABLE *, 7927c478bd9Sstevel@tonic-gate void (*closeproc)(const SVCMASTERXPRT *), 7937c478bd9Sstevel@tonic-gate int, bool_t); 7947c478bd9Sstevel@tonic-gate extern int svc_clts_kcreate(struct file *, uint_t, struct T_info_ack *, 7957c478bd9Sstevel@tonic-gate SVCMASTERXPRT **); 7967c478bd9Sstevel@tonic-gate extern int svc_cots_kcreate(struct file *, uint_t, struct T_info_ack *, 7977c478bd9Sstevel@tonic-gate SVCMASTERXPRT **); 798*2695d4f4SMarcel Telka extern bool_t svc_queuereq(queue_t *, mblk_t *, bool_t); 7997c478bd9Sstevel@tonic-gate extern void svc_queueclean(queue_t *); 8007c478bd9Sstevel@tonic-gate extern void svc_queueclose(queue_t *); 8017c478bd9Sstevel@tonic-gate extern int svc_reserve_thread(SVCXPRT *); 8027c478bd9Sstevel@tonic-gate extern void svc_unreserve_thread(SVCXPRT *); 8037c478bd9Sstevel@tonic-gate extern callb_cpr_t *svc_detach_thread(SVCXPRT *); 8047c478bd9Sstevel@tonic-gate 8057c478bd9Sstevel@tonic-gate /* 8067c478bd9Sstevel@tonic-gate * For RDMA based kRPC. 8077c478bd9Sstevel@tonic-gate * "rdma_xprt_record" is a reference to master transport handles 8087c478bd9Sstevel@tonic-gate * in kRPC thread pools. This is an easy way of tracking and shuting 8097c478bd9Sstevel@tonic-gate * down rdma based kRPC transports on demand. 8107c478bd9Sstevel@tonic-gate * "rdma_xprt_group" is a list of RDMA based mster transport handles 8117c478bd9Sstevel@tonic-gate * or records in a kRPC thread pool. 8127c478bd9Sstevel@tonic-gate */ 8137c478bd9Sstevel@tonic-gate typedef struct rdma_xprt_record rdma_xprt_record_t; 8147c478bd9Sstevel@tonic-gate struct rdma_xprt_record { 8157c478bd9Sstevel@tonic-gate int rtr_type; /* Type of rdma; IB/VI/RDDP */ 8167c478bd9Sstevel@tonic-gate SVCMASTERXPRT *rtr_xprt_ptr; /* Ptr to master xprt handle */ 8177c478bd9Sstevel@tonic-gate rdma_xprt_record_t *rtr_next; /* Ptr to next record */ 8187c478bd9Sstevel@tonic-gate }; 8197c478bd9Sstevel@tonic-gate 8207c478bd9Sstevel@tonic-gate typedef struct { 8217c478bd9Sstevel@tonic-gate int rtg_count; /* Number transport records */ 8227c478bd9Sstevel@tonic-gate int rtg_poolid; /* Pool Id for this group */ 8237c478bd9Sstevel@tonic-gate rdma_xprt_record_t *rtg_listhead; /* Head of the records list */ 8247c478bd9Sstevel@tonic-gate } rdma_xprt_group_t; 8257c478bd9Sstevel@tonic-gate 8267c478bd9Sstevel@tonic-gate extern int svc_rdma_kcreate(char *, SVC_CALLOUT_TABLE *, int, 8277c478bd9Sstevel@tonic-gate rdma_xprt_group_t *); 8287c478bd9Sstevel@tonic-gate extern void svc_rdma_kstop(SVCMASTERXPRT *); 8297c478bd9Sstevel@tonic-gate extern void svc_rdma_kdestroy(SVCMASTERXPRT *); 83051f34d4bSRajkumar Sivaprakasam extern void rdma_stop(rdma_xprt_group_t *); 8317c478bd9Sstevel@tonic-gate 8327c478bd9Sstevel@tonic-gate /* 8337c478bd9Sstevel@tonic-gate * GSS cleanup method. 8347c478bd9Sstevel@tonic-gate */ 8357c478bd9Sstevel@tonic-gate extern void rpc_gss_cleanup(SVCXPRT *); 8367c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 8377c478bd9Sstevel@tonic-gate /* 8387c478bd9Sstevel@tonic-gate * Lowest level dispatching -OR- who owns this process anyway. 8397c478bd9Sstevel@tonic-gate * Somebody has to wait for incoming requests and then call the correct 8407c478bd9Sstevel@tonic-gate * service routine. The routine svc_run does infinite waiting; i.e., 8417c478bd9Sstevel@tonic-gate * svc_run never returns. 8427c478bd9Sstevel@tonic-gate * Since another (co-existant) package may wish to selectively wait for 8437c478bd9Sstevel@tonic-gate * incoming calls or other events outside of the rpc architecture, the 8447c478bd9Sstevel@tonic-gate * routine svc_getreq_poll is provided. It must be passed pollfds, the 8457c478bd9Sstevel@tonic-gate * "in-place" results of a poll call (see poll, section 2). 8467c478bd9Sstevel@tonic-gate */ 8477c478bd9Sstevel@tonic-gate 8487c478bd9Sstevel@tonic-gate /* 8497c478bd9Sstevel@tonic-gate * Global keeper of rpc service descriptors in use 8507c478bd9Sstevel@tonic-gate * dynamic; must be inspected before each call to select or poll 8517c478bd9Sstevel@tonic-gate */ 8527c478bd9Sstevel@tonic-gate extern pollfd_t *svc_pollfd; 8537c478bd9Sstevel@tonic-gate extern int svc_max_pollfd; 8547c478bd9Sstevel@tonic-gate extern fd_set svc_fdset; 8557c478bd9Sstevel@tonic-gate #if !defined(_LP64) && FD_SETSIZE > 1024 8567c478bd9Sstevel@tonic-gate extern fd_set _new_svc_fdset; 8577c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 8587c478bd9Sstevel@tonic-gate #pragma redefine_extname svc_fdset _new_svc_fdset 8597c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 8607c478bd9Sstevel@tonic-gate #define svc_fdset _new_svc_fdset 8617c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 8627c478bd9Sstevel@tonic-gate #endif /* LP64 && FD_SETSIZE > 1024 */ 8637c478bd9Sstevel@tonic-gate #define svc_fds svc_fdset.fds_bits[0] /* compatibility */ 8647c478bd9Sstevel@tonic-gate 8657c478bd9Sstevel@tonic-gate /* 8667c478bd9Sstevel@tonic-gate * A small program implemented by the svc_rpc implementation itself. 8677c478bd9Sstevel@tonic-gate * Also see clnt.h for protocol numbers. 8687c478bd9Sstevel@tonic-gate */ 8697c478bd9Sstevel@tonic-gate #ifdef __STDC__ 8707c478bd9Sstevel@tonic-gate extern void svc_getreq(int); 8717c478bd9Sstevel@tonic-gate extern void svc_getreq_common(const int); 8727c478bd9Sstevel@tonic-gate extern void svc_getreqset(fd_set *); /* takes fdset instead of int */ 8737c478bd9Sstevel@tonic-gate extern void svc_getreq_poll(struct pollfd *, const int); 8747c478bd9Sstevel@tonic-gate extern void svc_run(void); 8757c478bd9Sstevel@tonic-gate extern void svc_exit(void); 8767c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 8777c478bd9Sstevel@tonic-gate extern void rpctest_service(); 8787c478bd9Sstevel@tonic-gate extern void svc_getreqset(); 8797c478bd9Sstevel@tonic-gate extern void svc_getreq(); 8807c478bd9Sstevel@tonic-gate extern void svc_getreq_common(); 8817c478bd9Sstevel@tonic-gate extern void svc_getreqset(); /* takes fdset instead of int */ 8827c478bd9Sstevel@tonic-gate extern void svc_getreq_poll(); 8837c478bd9Sstevel@tonic-gate extern void svc_run(); 8847c478bd9Sstevel@tonic-gate extern void svc_exit(); 8857c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 8867c478bd9Sstevel@tonic-gate 8877c478bd9Sstevel@tonic-gate /* 8887c478bd9Sstevel@tonic-gate * Functions used to manage user file descriptors 8897c478bd9Sstevel@tonic-gate */ 8907c478bd9Sstevel@tonic-gate typedef int svc_input_id_t; 8917c478bd9Sstevel@tonic-gate typedef void (*svc_callback_t)(svc_input_id_t id, int fd, 8927c478bd9Sstevel@tonic-gate unsigned int events, void* cookie); 8937c478bd9Sstevel@tonic-gate 8947c478bd9Sstevel@tonic-gate #ifdef __STDC__ 8957c478bd9Sstevel@tonic-gate extern svc_input_id_t svc_add_input(int fd, unsigned int events, 8967c478bd9Sstevel@tonic-gate svc_callback_t user_callback, 8977c478bd9Sstevel@tonic-gate void* cookie); 8987c478bd9Sstevel@tonic-gate extern int svc_remove_input(svc_input_id_t id); 8997c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 9007c478bd9Sstevel@tonic-gate extern svc_input_id_t svc_add_input(); 9017c478bd9Sstevel@tonic-gate extern int svc_remove_input(); 9027c478bd9Sstevel@tonic-gate #endif 9037c478bd9Sstevel@tonic-gate 9047c478bd9Sstevel@tonic-gate /* 9057c478bd9Sstevel@tonic-gate * These are the existing service side transport implementations. 9067c478bd9Sstevel@tonic-gate * 9077c478bd9Sstevel@tonic-gate * Transport independent svc_create routine. 9087c478bd9Sstevel@tonic-gate */ 9097c478bd9Sstevel@tonic-gate #ifdef __STDC__ 9107c478bd9Sstevel@tonic-gate extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), 9117c478bd9Sstevel@tonic-gate const rpcprog_t, const rpcvers_t, 9127c478bd9Sstevel@tonic-gate const char *); 9137c478bd9Sstevel@tonic-gate /* 9147c478bd9Sstevel@tonic-gate * void (*dispatch)(); -- dispatch routine 9157c478bd9Sstevel@tonic-gate * const rpcprog_t prognum; -- program number 9167c478bd9Sstevel@tonic-gate * const rpcvers_t versnum; -- version number 9177c478bd9Sstevel@tonic-gate * const char *nettype; -- network type 9187c478bd9Sstevel@tonic-gate */ 9197c478bd9Sstevel@tonic-gate 9207c478bd9Sstevel@tonic-gate /* 9217c478bd9Sstevel@tonic-gate * Generic server creation routine. It takes a netconfig structure 9227c478bd9Sstevel@tonic-gate * instead of a nettype. 9237c478bd9Sstevel@tonic-gate */ 9247c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), 9257c478bd9Sstevel@tonic-gate const rpcprog_t, const rpcvers_t, 9267c478bd9Sstevel@tonic-gate const struct netconfig *); 9277c478bd9Sstevel@tonic-gate /* 9287c478bd9Sstevel@tonic-gate * void (*dispatch)(); -- dispatch routine 9297c478bd9Sstevel@tonic-gate * const rpcprog_t prognum; -- program number 9307c478bd9Sstevel@tonic-gate * const rpcvers_t versnum; -- version number 9317c478bd9Sstevel@tonic-gate * const struct netconfig *nconf; -- netconfig structure 9327c478bd9Sstevel@tonic-gate */ 9337c478bd9Sstevel@tonic-gate 9347c478bd9Sstevel@tonic-gate /* 9357c478bd9Sstevel@tonic-gate * Generic TLI create routine 9367c478bd9Sstevel@tonic-gate */ 9377c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, 9387c478bd9Sstevel@tonic-gate const struct t_bind *, const uint_t, 9397c478bd9Sstevel@tonic-gate const uint_t); 9407c478bd9Sstevel@tonic-gate /* 9417c478bd9Sstevel@tonic-gate * const int fd; -- connection end point 9427c478bd9Sstevel@tonic-gate * const struct netconfig *nconf; -- netconfig structure 9437c478bd9Sstevel@tonic-gate * const struct t_bind *bindaddr; -- local bind address 9447c478bd9Sstevel@tonic-gate * const uint_t sendsz; -- max sendsize 9457c478bd9Sstevel@tonic-gate * const uint_t recvsz; -- max recvsize 9467c478bd9Sstevel@tonic-gate */ 9477c478bd9Sstevel@tonic-gate 9487c478bd9Sstevel@tonic-gate /* 9497c478bd9Sstevel@tonic-gate * Connectionless and connectionful create routines. 9507c478bd9Sstevel@tonic-gate */ 9517c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_vc_create(const int, const uint_t, const uint_t); 9527c478bd9Sstevel@tonic-gate /* 9537c478bd9Sstevel@tonic-gate * const int fd; -- open connection end point 9547c478bd9Sstevel@tonic-gate * const uint_t sendsize; -- max send size 9557c478bd9Sstevel@tonic-gate * const uint_t recvsize; -- max recv size 9567c478bd9Sstevel@tonic-gate */ 9577c478bd9Sstevel@tonic-gate 9587c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_dg_create(const int, const uint_t, const uint_t); 9597c478bd9Sstevel@tonic-gate /* 9607c478bd9Sstevel@tonic-gate * const int fd; -- open connection 9617c478bd9Sstevel@tonic-gate * const uint_t sendsize; -- max send size 9627c478bd9Sstevel@tonic-gate * const uint_t recvsize; -- max recv size 9637c478bd9Sstevel@tonic-gate */ 9647c478bd9Sstevel@tonic-gate 9657c478bd9Sstevel@tonic-gate /* 9667c478bd9Sstevel@tonic-gate * the routine takes any *open* TLI file 9677c478bd9Sstevel@tonic-gate * descriptor as its first input and is used for open connections. 9687c478bd9Sstevel@tonic-gate */ 9697c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_fd_create(const int, const uint_t, const uint_t); 9707c478bd9Sstevel@tonic-gate /* 9717c478bd9Sstevel@tonic-gate * const int fd; -- open connection end point 9727c478bd9Sstevel@tonic-gate * const uint_t sendsize; -- max send size 9737c478bd9Sstevel@tonic-gate * const uint_t recvsize; -- max recv size 9747c478bd9Sstevel@tonic-gate */ 9757c478bd9Sstevel@tonic-gate 9767c478bd9Sstevel@tonic-gate /* 9777c478bd9Sstevel@tonic-gate * Memory based rpc (for speed check and testing) 9787c478bd9Sstevel@tonic-gate */ 9797c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_raw_create(void); 9807c478bd9Sstevel@tonic-gate 9817c478bd9Sstevel@tonic-gate /* 9827c478bd9Sstevel@tonic-gate * Creation of service over doors transport. 9837c478bd9Sstevel@tonic-gate */ 9847c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_door_create(void (*)(struct svc_req *, SVCXPRT *), 9857c478bd9Sstevel@tonic-gate const rpcprog_t, const rpcvers_t, 9867c478bd9Sstevel@tonic-gate const uint_t); 9877c478bd9Sstevel@tonic-gate /* 9887c478bd9Sstevel@tonic-gate * void (*dispatch)(); -- dispatch routine 9897c478bd9Sstevel@tonic-gate * const rpcprog_t prognum; -- program number 9907c478bd9Sstevel@tonic-gate * const rpcvers_t versnum; -- version number 9917c478bd9Sstevel@tonic-gate * const uint_t sendsize; -- send buffer size 9927c478bd9Sstevel@tonic-gate */ 9937c478bd9Sstevel@tonic-gate 9947c478bd9Sstevel@tonic-gate /* 9957c478bd9Sstevel@tonic-gate * Service control interface 9967c478bd9Sstevel@tonic-gate */ 9977c478bd9Sstevel@tonic-gate extern bool_t svc_control(SVCXPRT *, const uint_t, void *); 9987c478bd9Sstevel@tonic-gate /* 9997c478bd9Sstevel@tonic-gate * SVCXPRT *svc; -- service to manipulate 10007c478bd9Sstevel@tonic-gate * const uint_t req; -- request 10017c478bd9Sstevel@tonic-gate * void *info; -- argument to request 10027c478bd9Sstevel@tonic-gate */ 10037c478bd9Sstevel@tonic-gate 10047c478bd9Sstevel@tonic-gate /* 10057c478bd9Sstevel@tonic-gate * svc_dg_enable_cache() enables the cache on dg transports. 10067c478bd9Sstevel@tonic-gate */ 10077c478bd9Sstevel@tonic-gate extern int svc_dg_enablecache(SVCXPRT *, const uint_t); 10087c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 10097c478bd9Sstevel@tonic-gate extern int svc_create(); 10107c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_tp_create(); 10117c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_tli_create(); 10127c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_vc_create(); 10137c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_dg_create(); 10147c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_fd_create(); 10157c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_raw_create(); 10167c478bd9Sstevel@tonic-gate extern SVCXPRT *svc_door_create(); 10177c478bd9Sstevel@tonic-gate extern int svc_dg_enablecache(); 10187c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 10197c478bd9Sstevel@tonic-gate 102045916cd2Sjpk extern boolean_t is_multilevel(rpcprog_t); 102145916cd2Sjpk 10227c478bd9Sstevel@tonic-gate #ifdef PORTMAP 10237c478bd9Sstevel@tonic-gate /* For backward compatibility */ 10247c478bd9Sstevel@tonic-gate #include <rpc/svc_soc.h> 10257c478bd9Sstevel@tonic-gate #endif /* PORTMAP */ 10267c478bd9Sstevel@tonic-gate 10277c478bd9Sstevel@tonic-gate /* 10287c478bd9Sstevel@tonic-gate * For user level MT hot server functions 10297c478bd9Sstevel@tonic-gate */ 10307c478bd9Sstevel@tonic-gate 10317c478bd9Sstevel@tonic-gate /* 10327c478bd9Sstevel@tonic-gate * Different MT modes 10337c478bd9Sstevel@tonic-gate */ 10347c478bd9Sstevel@tonic-gate #define RPC_SVC_MT_NONE 0 /* default, single-threaded */ 10357c478bd9Sstevel@tonic-gate #define RPC_SVC_MT_AUTO 1 /* automatic MT mode */ 10367c478bd9Sstevel@tonic-gate #define RPC_SVC_MT_USER 2 /* user MT mode */ 10377c478bd9Sstevel@tonic-gate 10387c478bd9Sstevel@tonic-gate #ifdef __STDC__ 10397c478bd9Sstevel@tonic-gate extern void svc_done(SVCXPRT *); 10407c478bd9Sstevel@tonic-gate #else 10417c478bd9Sstevel@tonic-gate extern void svc_done(); 10427c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 10437c478bd9Sstevel@tonic-gate 10447c478bd9Sstevel@tonic-gate /* 10457c478bd9Sstevel@tonic-gate * Obtaining local credentials. 10467c478bd9Sstevel@tonic-gate */ 10477c478bd9Sstevel@tonic-gate typedef struct __svc_local_cred_t { 10487c478bd9Sstevel@tonic-gate uid_t euid; /* effective uid */ 10497c478bd9Sstevel@tonic-gate gid_t egid; /* effective gid */ 10507c478bd9Sstevel@tonic-gate uid_t ruid; /* real uid */ 10517c478bd9Sstevel@tonic-gate gid_t rgid; /* real gid */ 10527c478bd9Sstevel@tonic-gate pid_t pid; /* caller's pid, or -1 if not available */ 10537c478bd9Sstevel@tonic-gate } svc_local_cred_t; 10547c478bd9Sstevel@tonic-gate 10557c478bd9Sstevel@tonic-gate #ifdef __STDC__ 10567c478bd9Sstevel@tonic-gate struct ucred_s; 10577c478bd9Sstevel@tonic-gate extern void svc_fd_negotiate_ucred(int); 10587c478bd9Sstevel@tonic-gate extern int svc_getcallerucred(const SVCXPRT *, struct ucred_s **); 10597c478bd9Sstevel@tonic-gate extern bool_t svc_get_local_cred(SVCXPRT *, svc_local_cred_t *); 10607c478bd9Sstevel@tonic-gate #else 10617c478bd9Sstevel@tonic-gate extern void svc_fd_negotiate_ucred(); 10627c478bd9Sstevel@tonic-gate extern int svc_getcallerucred(); 10637c478bd9Sstevel@tonic-gate extern bool_t svc_get_local_cred(); 10647c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 10657c478bd9Sstevel@tonic-gate 10667c478bd9Sstevel@tonic-gate /* 10677c478bd9Sstevel@tonic-gate * Private interfaces and structures for user level duplicate request caching. 10687c478bd9Sstevel@tonic-gate * The interfaces and data structures are not committed and subject to 10697c478bd9Sstevel@tonic-gate * change in future releases. Currently only intended for use by automountd. 10707c478bd9Sstevel@tonic-gate */ 10717c478bd9Sstevel@tonic-gate struct dupreq { 10727c478bd9Sstevel@tonic-gate uint32_t dr_xid; 10737c478bd9Sstevel@tonic-gate rpcproc_t dr_proc; 10747c478bd9Sstevel@tonic-gate rpcvers_t dr_vers; 10757c478bd9Sstevel@tonic-gate rpcprog_t dr_prog; 10767c478bd9Sstevel@tonic-gate struct netbuf dr_addr; 10777c478bd9Sstevel@tonic-gate struct netbuf dr_resp; 10787c478bd9Sstevel@tonic-gate int dr_status; 10797c478bd9Sstevel@tonic-gate time_t dr_time; 10807c478bd9Sstevel@tonic-gate uint_t dr_hash; 10817c478bd9Sstevel@tonic-gate struct dupreq *dr_next; 10827c478bd9Sstevel@tonic-gate struct dupreq *dr_prev; 10837c478bd9Sstevel@tonic-gate struct dupreq *dr_chain; 10847c478bd9Sstevel@tonic-gate struct dupreq *dr_prevchain; 10857c478bd9Sstevel@tonic-gate }; 10867c478bd9Sstevel@tonic-gate 10877c478bd9Sstevel@tonic-gate /* 10887c478bd9Sstevel@tonic-gate * The fixedtime state is defined if we want to expand the routines to 10897c478bd9Sstevel@tonic-gate * handle and encompass fixed size caches. 10907c478bd9Sstevel@tonic-gate */ 10917c478bd9Sstevel@tonic-gate #define DUPCACHE_FIXEDTIME 0 10927c478bd9Sstevel@tonic-gate 10937c478bd9Sstevel@tonic-gate /* 10947c478bd9Sstevel@tonic-gate * States of requests for duplicate request caching. 10957c478bd9Sstevel@tonic-gate * These are the same as defined for the kernel. 10967c478bd9Sstevel@tonic-gate */ 10977c478bd9Sstevel@tonic-gate #define DUP_NEW 0x00 /* new entry */ 10987c478bd9Sstevel@tonic-gate #define DUP_INPROGRESS 0x01 /* request already going */ 10997c478bd9Sstevel@tonic-gate #define DUP_DONE 0x02 /* request done */ 11007c478bd9Sstevel@tonic-gate #define DUP_DROP 0x03 /* request dropped */ 11017c478bd9Sstevel@tonic-gate #define DUP_ERROR 0x04 /* error in dup req cache */ 11027c478bd9Sstevel@tonic-gate 11037c478bd9Sstevel@tonic-gate #ifdef __STDC__ 11047c478bd9Sstevel@tonic-gate extern bool_t __svc_dupcache_init(void *, int, char **); 11057c478bd9Sstevel@tonic-gate extern int __svc_dup(struct svc_req *, caddr_t *, uint_t *, char *); 11067c478bd9Sstevel@tonic-gate extern int __svc_dupdone(struct svc_req *, caddr_t, uint_t, int, char *); 11077c478bd9Sstevel@tonic-gate extern bool_t __svc_vc_dupcache_init(SVCXPRT *, void *, int); 11087c478bd9Sstevel@tonic-gate extern int __svc_vc_dup(struct svc_req *, caddr_t *, uint_t *); 11097c478bd9Sstevel@tonic-gate extern int __svc_vc_dupdone(struct svc_req *, caddr_t, uint_t, int); 11107c478bd9Sstevel@tonic-gate #else 11117c478bd9Sstevel@tonic-gate extern bool_t __svc_dupcache_init(); 11127c478bd9Sstevel@tonic-gate extern int __svc_dup(); 11137c478bd9Sstevel@tonic-gate extern int __svc_dupdone(); 11147c478bd9Sstevel@tonic-gate extern bool_t __svc_vc_dupcache_init(); 11157c478bd9Sstevel@tonic-gate extern int __svc_vc_dup(); 11167c478bd9Sstevel@tonic-gate extern int __svc_vc_dupdone(); 11177c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 11187c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 11197c478bd9Sstevel@tonic-gate 1120bfd8310aSGlenn Barry #ifdef _KERNEL 1121bfd8310aSGlenn Barry /* 1122bfd8310aSGlenn Barry * Private interfaces and structures for SVCXPRT cloning. 1123bfd8310aSGlenn Barry * The interfaces and data structures are not committed and subject to 1124bfd8310aSGlenn Barry * change in future releases. 1125bfd8310aSGlenn Barry */ 1126bfd8310aSGlenn Barry extern SVCXPRT *svc_clone_init(void); 1127bfd8310aSGlenn Barry extern void svc_clone_free(SVCXPRT *); 112860536ef9SKaren Rochford extern void svc_clone_link(SVCMASTERXPRT *, SVCXPRT *, SVCXPRT *); 1129bfd8310aSGlenn Barry extern void svc_clone_unlink(SVCXPRT *); 1130bfd8310aSGlenn Barry #endif /* _KERNEL */ 1131bfd8310aSGlenn Barry 11327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 11337c478bd9Sstevel@tonic-gate } 11347c478bd9Sstevel@tonic-gate #endif 11357c478bd9Sstevel@tonic-gate 11367c478bd9Sstevel@tonic-gate #endif /* !_RPC_SVC_H */ 1137