xref: /onnv-gate/usr/src/uts/common/rpc/svc_clts.c (revision 12743:3bd368aca7be)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57208Svv149972  * Common Development and Distribution License (the "License").
67208Svv149972  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
2212553SKaren.Rochford@Sun.COM  *  Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
260Sstevel@tonic-gate /*	  All Rights Reserved  	*/
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
300Sstevel@tonic-gate  * under license from the Regents of the University of California.
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * svc_clts.c
350Sstevel@tonic-gate  * Server side for RPC in the kernel.
360Sstevel@tonic-gate  *
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #include <sys/param.h>
400Sstevel@tonic-gate #include <sys/types.h>
410Sstevel@tonic-gate #include <sys/sysmacros.h>
420Sstevel@tonic-gate #include <sys/file.h>
430Sstevel@tonic-gate #include <sys/stream.h>
44*12743SMarcel.Telka@Sun.COM #include <sys/strsun.h>
450Sstevel@tonic-gate #include <sys/strsubr.h>
460Sstevel@tonic-gate #include <sys/tihdr.h>
470Sstevel@tonic-gate #include <sys/tiuser.h>
480Sstevel@tonic-gate #include <sys/t_kuser.h>
490Sstevel@tonic-gate #include <sys/fcntl.h>
500Sstevel@tonic-gate #include <sys/errno.h>
510Sstevel@tonic-gate #include <sys/kmem.h>
520Sstevel@tonic-gate #include <sys/systm.h>
530Sstevel@tonic-gate #include <sys/cmn_err.h>
540Sstevel@tonic-gate #include <sys/kstat.h>
550Sstevel@tonic-gate #include <sys/vtrace.h>
560Sstevel@tonic-gate #include <sys/debug.h>
570Sstevel@tonic-gate 
580Sstevel@tonic-gate #include <rpc/types.h>
590Sstevel@tonic-gate #include <rpc/xdr.h>
600Sstevel@tonic-gate #include <rpc/auth.h>
610Sstevel@tonic-gate #include <rpc/clnt.h>
620Sstevel@tonic-gate #include <rpc/rpc_msg.h>
630Sstevel@tonic-gate #include <rpc/svc.h>
647208Svv149972 #include <inet/ip.h>
650Sstevel@tonic-gate 
660Sstevel@tonic-gate /*
670Sstevel@tonic-gate  * Routines exported through ops vector.
680Sstevel@tonic-gate  */
690Sstevel@tonic-gate static bool_t		svc_clts_krecv(SVCXPRT *, mblk_t *, struct rpc_msg *);
700Sstevel@tonic-gate static bool_t		svc_clts_ksend(SVCXPRT *, struct rpc_msg *);
710Sstevel@tonic-gate static bool_t		svc_clts_kgetargs(SVCXPRT *, xdrproc_t, caddr_t);
720Sstevel@tonic-gate static bool_t		svc_clts_kfreeargs(SVCXPRT *, xdrproc_t, caddr_t);
730Sstevel@tonic-gate static void		svc_clts_kdestroy(SVCMASTERXPRT *);
740Sstevel@tonic-gate static int		svc_clts_kdup(struct svc_req *, caddr_t, int,
750Sstevel@tonic-gate 				struct dupreq **, bool_t *);
760Sstevel@tonic-gate static void		svc_clts_kdupdone(struct dupreq *, caddr_t,
770Sstevel@tonic-gate 				void (*)(), int, int);
780Sstevel@tonic-gate static int32_t		*svc_clts_kgetres(SVCXPRT *, int);
790Sstevel@tonic-gate static void		svc_clts_kclone_destroy(SVCXPRT *);
800Sstevel@tonic-gate static void		svc_clts_kfreeres(SVCXPRT *);
810Sstevel@tonic-gate static void		svc_clts_kstart(SVCMASTERXPRT *);
8211967SKaren.Rochford@Sun.COM static void		svc_clts_kclone_xprt(SVCXPRT *, SVCXPRT *);
8312553SKaren.Rochford@Sun.COM static void		svc_clts_ktattrs(SVCXPRT *, int, void **);
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /*
860Sstevel@tonic-gate  * Server transport operations vector.
870Sstevel@tonic-gate  */
880Sstevel@tonic-gate struct svc_ops svc_clts_op = {
890Sstevel@tonic-gate 	svc_clts_krecv,		/* Get requests */
900Sstevel@tonic-gate 	svc_clts_kgetargs,	/* Deserialize arguments */
910Sstevel@tonic-gate 	svc_clts_ksend,		/* Send reply */
920Sstevel@tonic-gate 	svc_clts_kfreeargs,	/* Free argument data space */
930Sstevel@tonic-gate 	svc_clts_kdestroy,	/* Destroy transport handle */
940Sstevel@tonic-gate 	svc_clts_kdup,		/* Check entry in dup req cache */
950Sstevel@tonic-gate 	svc_clts_kdupdone,	/* Mark entry in dup req cache as done */
960Sstevel@tonic-gate 	svc_clts_kgetres,	/* Get pointer to response buffer */
970Sstevel@tonic-gate 	svc_clts_kfreeres,	/* Destroy pre-serialized response header */
980Sstevel@tonic-gate 	svc_clts_kclone_destroy, /* Destroy a clone xprt */
9911967SKaren.Rochford@Sun.COM 	svc_clts_kstart,	/* Tell `ready-to-receive' to rpcmod */
10012553SKaren.Rochford@Sun.COM 	svc_clts_kclone_xprt,	/* transport specific clone xprt function */
10112553SKaren.Rochford@Sun.COM 	svc_clts_ktattrs	/* Transport specific attributes. */
1020Sstevel@tonic-gate };
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate /*
1050Sstevel@tonic-gate  * Transport private data.
1060Sstevel@tonic-gate  * Kept in xprt->xp_p2buf.
1070Sstevel@tonic-gate  */
1080Sstevel@tonic-gate struct udp_data {
1090Sstevel@tonic-gate 	mblk_t	*ud_resp;			/* buffer for response */
1100Sstevel@tonic-gate 	mblk_t	*ud_inmp;			/* mblk chain of request */
1110Sstevel@tonic-gate };
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate #define	UD_MAXSIZE	8800
1140Sstevel@tonic-gate #define	UD_INITSIZE	2048
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate /*
1170Sstevel@tonic-gate  * Connectionless server statistics
1180Sstevel@tonic-gate  */
1190Sstevel@tonic-gate static const struct rpc_clts_server {
1200Sstevel@tonic-gate 	kstat_named_t	rscalls;
1210Sstevel@tonic-gate 	kstat_named_t	rsbadcalls;
1220Sstevel@tonic-gate 	kstat_named_t	rsnullrecv;
1230Sstevel@tonic-gate 	kstat_named_t	rsbadlen;
1240Sstevel@tonic-gate 	kstat_named_t	rsxdrcall;
1250Sstevel@tonic-gate 	kstat_named_t	rsdupchecks;
1260Sstevel@tonic-gate 	kstat_named_t	rsdupreqs;
1270Sstevel@tonic-gate } clts_rsstat_tmpl = {
1280Sstevel@tonic-gate 	{ "calls",	KSTAT_DATA_UINT64 },
1290Sstevel@tonic-gate 	{ "badcalls",	KSTAT_DATA_UINT64 },
1300Sstevel@tonic-gate 	{ "nullrecv",	KSTAT_DATA_UINT64 },
1310Sstevel@tonic-gate 	{ "badlen",	KSTAT_DATA_UINT64 },
1320Sstevel@tonic-gate 	{ "xdrcall",	KSTAT_DATA_UINT64 },
1330Sstevel@tonic-gate 	{ "dupchecks",	KSTAT_DATA_UINT64 },
1340Sstevel@tonic-gate 	{ "dupreqs",	KSTAT_DATA_UINT64 }
1350Sstevel@tonic-gate };
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate static uint_t clts_rsstat_ndata =
1380Sstevel@tonic-gate 	sizeof (clts_rsstat_tmpl) / sizeof (kstat_named_t);
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate #define	CLONE2STATS(clone_xprt)	\
1410Sstevel@tonic-gate 	(struct rpc_clts_server *)(clone_xprt)->xp_master->xp_p2
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate #define	RSSTAT_INCR(stats, x)	\
1440Sstevel@tonic-gate 	atomic_add_64(&(stats)->x.value.ui64, 1)
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate /*
1470Sstevel@tonic-gate  * Create a transport record.
1480Sstevel@tonic-gate  * The transport record, output buffer, and private data structure
1490Sstevel@tonic-gate  * are allocated.  The output buffer is serialized into using xdrmem.
1500Sstevel@tonic-gate  * There is one transport record per user process which implements a
1510Sstevel@tonic-gate  * set of services.
1520Sstevel@tonic-gate  */
1530Sstevel@tonic-gate /* ARGSUSED */
1540Sstevel@tonic-gate int
svc_clts_kcreate(file_t * fp,uint_t sendsz,struct T_info_ack * tinfo,SVCMASTERXPRT ** nxprt)1550Sstevel@tonic-gate svc_clts_kcreate(file_t *fp, uint_t sendsz, struct T_info_ack *tinfo,
1560Sstevel@tonic-gate     SVCMASTERXPRT **nxprt)
1570Sstevel@tonic-gate {
1580Sstevel@tonic-gate 	SVCMASTERXPRT *xprt;
1590Sstevel@tonic-gate 	struct rpcstat *rpcstat;
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate 	if (nxprt == NULL)
1620Sstevel@tonic-gate 		return (EINVAL);
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate 	rpcstat = zone_getspecific(rpcstat_zone_key, curproc->p_zone);
1650Sstevel@tonic-gate 	ASSERT(rpcstat != NULL);
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate 	xprt = kmem_zalloc(sizeof (*xprt), KM_SLEEP);
1687208Svv149972 	xprt->xp_lcladdr.buf = kmem_zalloc(sizeof (sin6_t), KM_SLEEP);
1690Sstevel@tonic-gate 	xprt->xp_p2 = (caddr_t)rpcstat->rpc_clts_server;
1700Sstevel@tonic-gate 	xprt->xp_ops = &svc_clts_op;
1710Sstevel@tonic-gate 	xprt->xp_msg_size = tinfo->TSDU_size;
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate 	xprt->xp_rtaddr.buf = NULL;
1740Sstevel@tonic-gate 	xprt->xp_rtaddr.maxlen = tinfo->ADDR_size;
1750Sstevel@tonic-gate 	xprt->xp_rtaddr.len = 0;
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate 	*nxprt = xprt;
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate 	return (0);
1800Sstevel@tonic-gate }
1810Sstevel@tonic-gate 
1820Sstevel@tonic-gate /*
1830Sstevel@tonic-gate  * Destroy a transport record.
1840Sstevel@tonic-gate  * Frees the space allocated for a transport record.
1850Sstevel@tonic-gate  */
1860Sstevel@tonic-gate static void
svc_clts_kdestroy(SVCMASTERXPRT * xprt)1870Sstevel@tonic-gate svc_clts_kdestroy(SVCMASTERXPRT *xprt)
1880Sstevel@tonic-gate {
1890Sstevel@tonic-gate 	if (xprt->xp_netid)
1900Sstevel@tonic-gate 		kmem_free(xprt->xp_netid, strlen(xprt->xp_netid) + 1);
1910Sstevel@tonic-gate 	if (xprt->xp_addrmask.maxlen)
1920Sstevel@tonic-gate 		kmem_free(xprt->xp_addrmask.buf, xprt->xp_addrmask.maxlen);
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate 	mutex_destroy(&xprt->xp_req_lock);
1950Sstevel@tonic-gate 	mutex_destroy(&xprt->xp_thread_lock);
1960Sstevel@tonic-gate 
1977208Svv149972 	kmem_free(xprt->xp_lcladdr.buf, sizeof (sin6_t));
1980Sstevel@tonic-gate 	kmem_free(xprt, sizeof (SVCMASTERXPRT));
1990Sstevel@tonic-gate }
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate /*
2020Sstevel@tonic-gate  * Transport-type specific part of svc_xprt_cleanup().
2030Sstevel@tonic-gate  * Frees the message buffer space allocated for a clone of a transport record
2040Sstevel@tonic-gate  */
2050Sstevel@tonic-gate static void
svc_clts_kclone_destroy(SVCXPRT * clone_xprt)2060Sstevel@tonic-gate svc_clts_kclone_destroy(SVCXPRT *clone_xprt)
2070Sstevel@tonic-gate {
2080Sstevel@tonic-gate 	/* LINTED pointer alignment */
2090Sstevel@tonic-gate 	struct udp_data *ud = (struct udp_data *)clone_xprt->xp_p2buf;
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate 	if (ud->ud_resp) {
2120Sstevel@tonic-gate 		/*
2130Sstevel@tonic-gate 		 * There should not be any left over results buffer.
2140Sstevel@tonic-gate 		 */
2150Sstevel@tonic-gate 		ASSERT(ud->ud_resp->b_cont == NULL);
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate 		/*
2180Sstevel@tonic-gate 		 * Free the T_UNITDATA_{REQ/IND} that svc_clts_krecv
2190Sstevel@tonic-gate 		 * saved.
2200Sstevel@tonic-gate 		 */
2210Sstevel@tonic-gate 		freeb(ud->ud_resp);
2220Sstevel@tonic-gate 	}
2230Sstevel@tonic-gate 	if (ud->ud_inmp)
2240Sstevel@tonic-gate 		freemsg(ud->ud_inmp);
2250Sstevel@tonic-gate }
2260Sstevel@tonic-gate 
2270Sstevel@tonic-gate /*
2280Sstevel@tonic-gate  * svc_tli_kcreate() calls this function at the end to tell
2290Sstevel@tonic-gate  * rpcmod that the transport is ready to receive requests.
2300Sstevel@tonic-gate  */
2310Sstevel@tonic-gate /* ARGSUSED */
2320Sstevel@tonic-gate static void
svc_clts_kstart(SVCMASTERXPRT * xprt)2330Sstevel@tonic-gate svc_clts_kstart(SVCMASTERXPRT *xprt)
2340Sstevel@tonic-gate {
2350Sstevel@tonic-gate }
2360Sstevel@tonic-gate 
23711967SKaren.Rochford@Sun.COM static void
svc_clts_kclone_xprt(SVCXPRT * src_xprt,SVCXPRT * dst_xprt)23811967SKaren.Rochford@Sun.COM svc_clts_kclone_xprt(SVCXPRT *src_xprt, SVCXPRT *dst_xprt)
23911967SKaren.Rochford@Sun.COM {
24011967SKaren.Rochford@Sun.COM 	struct udp_data *ud_src =
24111967SKaren.Rochford@Sun.COM 	    (struct udp_data *)src_xprt->xp_p2buf;
24211967SKaren.Rochford@Sun.COM 	struct udp_data *ud_dst =
24311967SKaren.Rochford@Sun.COM 	    (struct udp_data *)dst_xprt->xp_p2buf;
24411967SKaren.Rochford@Sun.COM 
24511967SKaren.Rochford@Sun.COM 	if (ud_src->ud_resp)
24611967SKaren.Rochford@Sun.COM 		ud_dst->ud_resp = dupb(ud_src->ud_resp);
24711967SKaren.Rochford@Sun.COM 
24811967SKaren.Rochford@Sun.COM }
24911967SKaren.Rochford@Sun.COM 
25012553SKaren.Rochford@Sun.COM static void
svc_clts_ktattrs(SVCXPRT * clone_xprt,int attrflag,void ** tattr)25112553SKaren.Rochford@Sun.COM svc_clts_ktattrs(SVCXPRT *clone_xprt, int attrflag, void **tattr)
25212553SKaren.Rochford@Sun.COM {
25312553SKaren.Rochford@Sun.COM 	*tattr = NULL;
25412553SKaren.Rochford@Sun.COM 
25512553SKaren.Rochford@Sun.COM 	switch (attrflag) {
25612553SKaren.Rochford@Sun.COM 	case SVC_TATTR_ADDRMASK:
25712553SKaren.Rochford@Sun.COM 		*tattr = (void *)&clone_xprt->xp_master->xp_addrmask;
25812553SKaren.Rochford@Sun.COM 	}
25912553SKaren.Rochford@Sun.COM }
26011967SKaren.Rochford@Sun.COM 
2610Sstevel@tonic-gate /*
2620Sstevel@tonic-gate  * Receive rpc requests.
2630Sstevel@tonic-gate  * Pulls a request in off the socket, checks if the packet is intact,
2640Sstevel@tonic-gate  * and deserializes the call packet.
2650Sstevel@tonic-gate  */
2660Sstevel@tonic-gate static bool_t
svc_clts_krecv(SVCXPRT * clone_xprt,mblk_t * mp,struct rpc_msg * msg)2670Sstevel@tonic-gate svc_clts_krecv(SVCXPRT *clone_xprt, mblk_t *mp, struct rpc_msg *msg)
2680Sstevel@tonic-gate {
2690Sstevel@tonic-gate 	/* LINTED pointer alignment */
2700Sstevel@tonic-gate 	struct udp_data *ud = (struct udp_data *)clone_xprt->xp_p2buf;
2710Sstevel@tonic-gate 	XDR *xdrs = &clone_xprt->xp_xdrin;
2720Sstevel@tonic-gate 	struct rpc_clts_server *stats = CLONE2STATS(clone_xprt);
2730Sstevel@tonic-gate 	union T_primitives *pptr;
2740Sstevel@tonic-gate 	int hdrsz;
2758778SErik.Nordmark@Sun.COM 	cred_t *cr;
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate 	TRACE_0(TR_FAC_KRPC, TR_SVC_CLTS_KRECV_START,
2780Sstevel@tonic-gate 	    "svc_clts_krecv_start:");
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate 	RSSTAT_INCR(stats, rscalls);
2810Sstevel@tonic-gate 
2820Sstevel@tonic-gate 	/*
2830Sstevel@tonic-gate 	 * The incoming request should start with an M_PROTO message.
2840Sstevel@tonic-gate 	 */
2850Sstevel@tonic-gate 	if (mp->b_datap->db_type != M_PROTO) {
2860Sstevel@tonic-gate 		goto bad;
2870Sstevel@tonic-gate 	}
2880Sstevel@tonic-gate 
2890Sstevel@tonic-gate 	/*
2900Sstevel@tonic-gate 	 * The incoming request should be an T_UNITDTA_IND.  There
2910Sstevel@tonic-gate 	 * might be other messages coming up the stream, but we can
2920Sstevel@tonic-gate 	 * ignore them.
2930Sstevel@tonic-gate 	 */
2940Sstevel@tonic-gate 	pptr = (union T_primitives *)mp->b_rptr;
2950Sstevel@tonic-gate 	if (pptr->type != T_UNITDATA_IND) {
2960Sstevel@tonic-gate 		goto bad;
2970Sstevel@tonic-gate 	}
2980Sstevel@tonic-gate 	/*
2990Sstevel@tonic-gate 	 * Do some checking to make sure that the header at least looks okay.
3000Sstevel@tonic-gate 	 */
3010Sstevel@tonic-gate 	hdrsz = (int)(mp->b_wptr - mp->b_rptr);
3020Sstevel@tonic-gate 	if (hdrsz < TUNITDATAINDSZ ||
3030Sstevel@tonic-gate 	    hdrsz < (pptr->unitdata_ind.OPT_offset +
3047208Svv149972 	    pptr->unitdata_ind.OPT_length) ||
3050Sstevel@tonic-gate 	    hdrsz < (pptr->unitdata_ind.SRC_offset +
3067208Svv149972 	    pptr->unitdata_ind.SRC_length)) {
3070Sstevel@tonic-gate 		goto bad;
3080Sstevel@tonic-gate 	}
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate 	/*
3110Sstevel@tonic-gate 	 * Make sure that the transport provided a usable address.
3120Sstevel@tonic-gate 	 */
3130Sstevel@tonic-gate 	if (pptr->unitdata_ind.SRC_length <= 0) {
3140Sstevel@tonic-gate 		goto bad;
3150Sstevel@tonic-gate 	}
3160Sstevel@tonic-gate 	/*
3170Sstevel@tonic-gate 	 * Point the remote transport address in the service_transport
3180Sstevel@tonic-gate 	 * handle at the address in the request.
3190Sstevel@tonic-gate 	 */
3200Sstevel@tonic-gate 	clone_xprt->xp_rtaddr.buf = (char *)mp->b_rptr +
3210Sstevel@tonic-gate 	    pptr->unitdata_ind.SRC_offset;
3220Sstevel@tonic-gate 	clone_xprt->xp_rtaddr.len = pptr->unitdata_ind.SRC_length;
3230Sstevel@tonic-gate 
3240Sstevel@tonic-gate 	/*
3257208Svv149972 	 * Copy the local transport address in the service_transport
3267208Svv149972 	 * handle at the address in the request. We will have only
3277208Svv149972 	 * the local IP address in options.
3287208Svv149972 	 */
329*12743SMarcel.Telka@Sun.COM 	((sin_t *)(clone_xprt->xp_lcladdr.buf))->sin_family = AF_UNSPEC;
3307208Svv149972 	if (pptr->unitdata_ind.OPT_length && pptr->unitdata_ind.OPT_offset) {
3317208Svv149972 		char *dstopt = (char *)mp->b_rptr +
3327208Svv149972 		    pptr->unitdata_ind.OPT_offset;
3337208Svv149972 		struct T_opthdr *toh = (struct T_opthdr *)dstopt;
3347208Svv149972 
3357208Svv149972 		if (toh->level == IPPROTO_IPV6 && toh->status == 0 &&
3367208Svv149972 		    toh->name == IPV6_PKTINFO) {
3377208Svv149972 			struct in6_pktinfo *pkti;
3387208Svv149972 
3397208Svv149972 			dstopt += sizeof (struct T_opthdr);
3407208Svv149972 			pkti = (struct in6_pktinfo *)dstopt;
3417208Svv149972 			((sin6_t *)(clone_xprt->xp_lcladdr.buf))->sin6_addr
3427208Svv149972 			    = pkti->ipi6_addr;
343*12743SMarcel.Telka@Sun.COM 			((sin6_t *)(clone_xprt->xp_lcladdr.buf))->sin6_family
344*12743SMarcel.Telka@Sun.COM 			    = AF_INET6;
3457208Svv149972 		} else if (toh->level == IPPROTO_IP && toh->status == 0 &&
3467208Svv149972 		    toh->name == IP_RECVDSTADDR) {
3477208Svv149972 			dstopt += sizeof (struct T_opthdr);
3487208Svv149972 			((sin_t *)(clone_xprt->xp_lcladdr.buf))->sin_addr
3497208Svv149972 			    = *(struct in_addr *)dstopt;
350*12743SMarcel.Telka@Sun.COM 			((sin_t *)(clone_xprt->xp_lcladdr.buf))->sin_family
351*12743SMarcel.Telka@Sun.COM 			    = AF_INET;
3527208Svv149972 		}
3537208Svv149972 	}
3547208Svv149972 
3557208Svv149972 	/*
3560Sstevel@tonic-gate 	 * Save the first mblk which contains the T_unidata_ind in
3570Sstevel@tonic-gate 	 * ud_resp.  It will be used to generate the T_unitdata_req
3580Sstevel@tonic-gate 	 * during the reply.
3598778SErik.Nordmark@Sun.COM 	 * We reuse any options in the T_unitdata_ind for the T_unitdata_req
3608778SErik.Nordmark@Sun.COM 	 * since we must pass any SCM_UCRED across in order for TX to
3618778SErik.Nordmark@Sun.COM 	 * work. We also make sure any cred_t is carried across.
3620Sstevel@tonic-gate 	 */
3630Sstevel@tonic-gate 	if (ud->ud_resp) {
3640Sstevel@tonic-gate 		if (ud->ud_resp->b_cont != NULL) {
3650Sstevel@tonic-gate 			cmn_err(CE_WARN, "svc_clts_krecv: ud_resp %p, "
3660Sstevel@tonic-gate 			    "b_cont %p", (void *)ud->ud_resp,
3670Sstevel@tonic-gate 			    (void *)ud->ud_resp->b_cont);
3680Sstevel@tonic-gate 		}
3690Sstevel@tonic-gate 		freeb(ud->ud_resp);
3700Sstevel@tonic-gate 	}
3718778SErik.Nordmark@Sun.COM 	/* Move any cred_t to the first mblk in the message */
3728778SErik.Nordmark@Sun.COM 	cr = msg_getcred(mp, NULL);
3738778SErik.Nordmark@Sun.COM 	if (cr != NULL)
3748778SErik.Nordmark@Sun.COM 		mblk_setcred(mp, cr, NOPID);
3758778SErik.Nordmark@Sun.COM 
3760Sstevel@tonic-gate 	ud->ud_resp = mp;
3770Sstevel@tonic-gate 	mp = mp->b_cont;
3780Sstevel@tonic-gate 	ud->ud_resp->b_cont = NULL;
3790Sstevel@tonic-gate 
3800Sstevel@tonic-gate 	xdrmblk_init(xdrs, mp, XDR_DECODE, 0);
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate 	TRACE_0(TR_FAC_KRPC, TR_XDR_CALLMSG_START,
3830Sstevel@tonic-gate 	    "xdr_callmsg_start:");
3840Sstevel@tonic-gate 	if (! xdr_callmsg(xdrs, msg)) {
3850Sstevel@tonic-gate 		TRACE_1(TR_FAC_KRPC, TR_XDR_CALLMSG_END,
3860Sstevel@tonic-gate 		    "xdr_callmsg_end:(%S)", "bad");
3870Sstevel@tonic-gate 		RSSTAT_INCR(stats, rsxdrcall);
3880Sstevel@tonic-gate 		goto bad;
3890Sstevel@tonic-gate 	}
3900Sstevel@tonic-gate 	TRACE_1(TR_FAC_KRPC, TR_XDR_CALLMSG_END,
3910Sstevel@tonic-gate 	    "xdr_callmsg_end:(%S)", "good");
3920Sstevel@tonic-gate 
3930Sstevel@tonic-gate 	clone_xprt->xp_xid = msg->rm_xid;
3940Sstevel@tonic-gate 	ud->ud_inmp = mp;
3950Sstevel@tonic-gate 
3960Sstevel@tonic-gate 	TRACE_1(TR_FAC_KRPC, TR_SVC_CLTS_KRECV_END,
3970Sstevel@tonic-gate 	    "svc_clts_krecv_end:(%S)", "good");
3980Sstevel@tonic-gate 	return (TRUE);
3990Sstevel@tonic-gate 
4000Sstevel@tonic-gate bad:
401*12743SMarcel.Telka@Sun.COM 	freemsg(mp);
4020Sstevel@tonic-gate 	if (ud->ud_resp) {
4030Sstevel@tonic-gate 		/*
4040Sstevel@tonic-gate 		 * There should not be any left over results buffer.
4050Sstevel@tonic-gate 		 */
4060Sstevel@tonic-gate 		ASSERT(ud->ud_resp->b_cont == NULL);
4070Sstevel@tonic-gate 		freeb(ud->ud_resp);
4080Sstevel@tonic-gate 		ud->ud_resp = NULL;
4090Sstevel@tonic-gate 	}
4100Sstevel@tonic-gate 
4110Sstevel@tonic-gate 	RSSTAT_INCR(stats, rsbadcalls);
4120Sstevel@tonic-gate 	TRACE_1(TR_FAC_KRPC, TR_SVC_CLTS_KRECV_END,
4130Sstevel@tonic-gate 	    "svc_clts_krecv_end:(%S)", "bad");
4140Sstevel@tonic-gate 	return (FALSE);
4150Sstevel@tonic-gate }
4160Sstevel@tonic-gate 
4170Sstevel@tonic-gate /*
4180Sstevel@tonic-gate  * Send rpc reply.
4190Sstevel@tonic-gate  * Serialize the reply packet into the output buffer then
4200Sstevel@tonic-gate  * call t_ksndudata to send it.
4210Sstevel@tonic-gate  */
4220Sstevel@tonic-gate static bool_t
svc_clts_ksend(SVCXPRT * clone_xprt,struct rpc_msg * msg)4230Sstevel@tonic-gate svc_clts_ksend(SVCXPRT *clone_xprt, struct rpc_msg *msg)
4240Sstevel@tonic-gate {
4250Sstevel@tonic-gate 	/* LINTED pointer alignment */
4260Sstevel@tonic-gate 	struct udp_data *ud = (struct udp_data *)clone_xprt->xp_p2buf;
4270Sstevel@tonic-gate 	XDR *xdrs = &clone_xprt->xp_xdrout;
4280Sstevel@tonic-gate 	int stat = FALSE;
4290Sstevel@tonic-gate 	mblk_t *mp;
4300Sstevel@tonic-gate 	int msgsz;
4310Sstevel@tonic-gate 	struct T_unitdata_req *udreq;
4320Sstevel@tonic-gate 	xdrproc_t xdr_results;
4330Sstevel@tonic-gate 	caddr_t xdr_location;
4340Sstevel@tonic-gate 	bool_t has_args;
4350Sstevel@tonic-gate 
4360Sstevel@tonic-gate 	TRACE_0(TR_FAC_KRPC, TR_SVC_CLTS_KSEND_START,
4370Sstevel@tonic-gate 	    "svc_clts_ksend_start:");
4380Sstevel@tonic-gate 
4390Sstevel@tonic-gate 	ASSERT(ud->ud_resp != NULL);
4400Sstevel@tonic-gate 
4410Sstevel@tonic-gate 	/*
4420Sstevel@tonic-gate 	 * If there is a result procedure specified in the reply message,
4430Sstevel@tonic-gate 	 * it will be processed in the xdr_replymsg and SVCAUTH_WRAP.
4440Sstevel@tonic-gate 	 * We need to make sure it won't be processed twice, so we null
4450Sstevel@tonic-gate 	 * it for xdr_replymsg here.
4460Sstevel@tonic-gate 	 */
4470Sstevel@tonic-gate 	has_args = FALSE;
4480Sstevel@tonic-gate 	if (msg->rm_reply.rp_stat == MSG_ACCEPTED &&
4497208Svv149972 	    msg->rm_reply.rp_acpt.ar_stat == SUCCESS) {
4500Sstevel@tonic-gate 		if ((xdr_results = msg->acpted_rply.ar_results.proc) != NULL) {
4510Sstevel@tonic-gate 			has_args = TRUE;
4520Sstevel@tonic-gate 			xdr_location = msg->acpted_rply.ar_results.where;
4530Sstevel@tonic-gate 			msg->acpted_rply.ar_results.proc = xdr_void;
4540Sstevel@tonic-gate 			msg->acpted_rply.ar_results.where = NULL;
4550Sstevel@tonic-gate 		}
4560Sstevel@tonic-gate 	}
4570Sstevel@tonic-gate 
4580Sstevel@tonic-gate 	if (ud->ud_resp->b_cont == NULL) {
4590Sstevel@tonic-gate 		/*
4600Sstevel@tonic-gate 		 * Allocate an initial mblk for the response data.
4610Sstevel@tonic-gate 		 */
4620Sstevel@tonic-gate 		while ((mp = allocb(UD_INITSIZE, BPRI_LO)) == NULL) {
4630Sstevel@tonic-gate 			if (strwaitbuf(UD_INITSIZE, BPRI_LO)) {
4640Sstevel@tonic-gate 				TRACE_1(TR_FAC_KRPC, TR_SVC_CLTS_KSEND_END,
4650Sstevel@tonic-gate 				    "svc_clts_ksend_end:(%S)", "strwaitbuf");
4660Sstevel@tonic-gate 				return (FALSE);
4670Sstevel@tonic-gate 			}
4680Sstevel@tonic-gate 		}
4690Sstevel@tonic-gate 
4700Sstevel@tonic-gate 		/*
4710Sstevel@tonic-gate 		 * Initialize the XDR decode stream.  Additional mblks
4720Sstevel@tonic-gate 		 * will be allocated if necessary.  They will be UD_MAXSIZE
4730Sstevel@tonic-gate 		 * sized.
4740Sstevel@tonic-gate 		 */
4750Sstevel@tonic-gate 		xdrmblk_init(xdrs, mp, XDR_ENCODE, UD_MAXSIZE);
4760Sstevel@tonic-gate 
4770Sstevel@tonic-gate 		/*
4780Sstevel@tonic-gate 		 * Leave some space for protocol headers.
4790Sstevel@tonic-gate 		 */
4800Sstevel@tonic-gate 		(void) XDR_SETPOS(xdrs, 512);
4810Sstevel@tonic-gate 		mp->b_rptr += 512;
4820Sstevel@tonic-gate 
4830Sstevel@tonic-gate 		msg->rm_xid = clone_xprt->xp_xid;
4840Sstevel@tonic-gate 
4850Sstevel@tonic-gate 		ud->ud_resp->b_cont = mp;
4860Sstevel@tonic-gate 
4870Sstevel@tonic-gate 		TRACE_0(TR_FAC_KRPC, TR_XDR_REPLYMSG_START,
4880Sstevel@tonic-gate 		    "xdr_replymsg_start:");
4890Sstevel@tonic-gate 		if (!(xdr_replymsg(xdrs, msg) &&
4907208Svv149972 		    (!has_args || SVCAUTH_WRAP(&clone_xprt->xp_auth, xdrs,
4917208Svv149972 		    xdr_results, xdr_location)))) {
4920Sstevel@tonic-gate 			TRACE_1(TR_FAC_KRPC, TR_XDR_REPLYMSG_END,
4930Sstevel@tonic-gate 			    "xdr_replymsg_end:(%S)", "bad");
4940Sstevel@tonic-gate 			RPCLOG0(1, "xdr_replymsg/SVCAUTH_WRAP failed\n");
4950Sstevel@tonic-gate 			goto out;
4960Sstevel@tonic-gate 		}
4970Sstevel@tonic-gate 		TRACE_1(TR_FAC_KRPC, TR_XDR_REPLYMSG_END,
4980Sstevel@tonic-gate 		    "xdr_replymsg_end:(%S)", "good");
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate 	} else if (!(xdr_replymsg_body(xdrs, msg) &&
5017208Svv149972 	    (!has_args || SVCAUTH_WRAP(&clone_xprt->xp_auth, xdrs,
5027208Svv149972 	    xdr_results, xdr_location)))) {
5030Sstevel@tonic-gate 		RPCLOG0(1, "xdr_replymsg_body/SVCAUTH_WRAP failed\n");
5040Sstevel@tonic-gate 		goto out;
5050Sstevel@tonic-gate 	}
5060Sstevel@tonic-gate 
5070Sstevel@tonic-gate 	msgsz = (int)xmsgsize(ud->ud_resp->b_cont);
5080Sstevel@tonic-gate 
5090Sstevel@tonic-gate 	if (msgsz <= 0 || (clone_xprt->xp_msg_size != -1 &&
5100Sstevel@tonic-gate 	    msgsz > clone_xprt->xp_msg_size)) {
5110Sstevel@tonic-gate #ifdef	DEBUG
5120Sstevel@tonic-gate 		cmn_err(CE_NOTE,
5130Sstevel@tonic-gate "KRPC: server response message of %d bytes; transport limits are [0, %d]",
5147208Svv149972 		    msgsz, clone_xprt->xp_msg_size);
5150Sstevel@tonic-gate #endif
5160Sstevel@tonic-gate 		goto out;
5170Sstevel@tonic-gate 	}
5180Sstevel@tonic-gate 
5190Sstevel@tonic-gate 	/*
520*12743SMarcel.Telka@Sun.COM 	 * Construct the T_unitdata_req.  We take advantage of the fact that
521*12743SMarcel.Telka@Sun.COM 	 * T_unitdata_ind looks just like T_unitdata_req, except for the
522*12743SMarcel.Telka@Sun.COM 	 * primitive type.  Reusing it means we preserve the SCM_UCRED, and
523*12743SMarcel.Telka@Sun.COM 	 * we must preserve it for TX to work.
524*12743SMarcel.Telka@Sun.COM 	 *
525*12743SMarcel.Telka@Sun.COM 	 * This has the side effect that we can also pass certain receive-side
526*12743SMarcel.Telka@Sun.COM 	 * options like IPV6_PKTINFO back down the send side.  This implies
527*12743SMarcel.Telka@Sun.COM 	 * that we can not ASSERT on a non-NULL db_credp when we have send-side
528*12743SMarcel.Telka@Sun.COM 	 * options in UDP.
529*12743SMarcel.Telka@Sun.COM 	 */
530*12743SMarcel.Telka@Sun.COM 	ASSERT(MBLKL(ud->ud_resp) >= TUNITDATAREQSZ);
531*12743SMarcel.Telka@Sun.COM 	udreq = (struct T_unitdata_req *)ud->ud_resp->b_rptr;
532*12743SMarcel.Telka@Sun.COM 	ASSERT(udreq->PRIM_type == T_UNITDATA_IND);
533*12743SMarcel.Telka@Sun.COM 	udreq->PRIM_type = T_UNITDATA_REQ;
534*12743SMarcel.Telka@Sun.COM 
535*12743SMarcel.Telka@Sun.COM 	/*
536*12743SMarcel.Telka@Sun.COM 	 * If the local IPv4 transport address is known use it as a source
537*12743SMarcel.Telka@Sun.COM 	 * address for the outgoing UDP packet.
5380Sstevel@tonic-gate 	 */
539*12743SMarcel.Telka@Sun.COM 	if (((sin_t *)(clone_xprt->xp_lcladdr.buf))->sin_family == AF_INET) {
540*12743SMarcel.Telka@Sun.COM 		struct T_opthdr *opthdr;
541*12743SMarcel.Telka@Sun.COM 		in_pktinfo_t *pktinfo;
542*12743SMarcel.Telka@Sun.COM 		size_t size;
543*12743SMarcel.Telka@Sun.COM 
544*12743SMarcel.Telka@Sun.COM 		if (udreq->DEST_length == 0)
545*12743SMarcel.Telka@Sun.COM 			udreq->OPT_offset = _TPI_ALIGN_TOPT(TUNITDATAREQSZ);
546*12743SMarcel.Telka@Sun.COM 		else
547*12743SMarcel.Telka@Sun.COM 			udreq->OPT_offset = _TPI_ALIGN_TOPT(udreq->DEST_offset +
548*12743SMarcel.Telka@Sun.COM 			    udreq->DEST_length);
549*12743SMarcel.Telka@Sun.COM 
550*12743SMarcel.Telka@Sun.COM 		udreq->OPT_length = sizeof (struct T_opthdr) +
551*12743SMarcel.Telka@Sun.COM 		    sizeof (in_pktinfo_t);
552*12743SMarcel.Telka@Sun.COM 
553*12743SMarcel.Telka@Sun.COM 		size = udreq->OPT_length + udreq->OPT_offset;
554*12743SMarcel.Telka@Sun.COM 
555*12743SMarcel.Telka@Sun.COM 		/* make sure we have enough space for the option data */
556*12743SMarcel.Telka@Sun.COM 		mp = reallocb(ud->ud_resp, size, 1);
557*12743SMarcel.Telka@Sun.COM 		if (mp == NULL)
558*12743SMarcel.Telka@Sun.COM 			goto out;
559*12743SMarcel.Telka@Sun.COM 		ud->ud_resp = mp;
560*12743SMarcel.Telka@Sun.COM 		udreq = (struct T_unitdata_req *)mp->b_rptr;
561*12743SMarcel.Telka@Sun.COM 
562*12743SMarcel.Telka@Sun.COM 		/* set desired option header */
563*12743SMarcel.Telka@Sun.COM 		opthdr = (struct T_opthdr *)(mp->b_rptr + udreq->OPT_offset);
564*12743SMarcel.Telka@Sun.COM 		opthdr->len = udreq->OPT_length;
565*12743SMarcel.Telka@Sun.COM 		opthdr->level = IPPROTO_IP;
566*12743SMarcel.Telka@Sun.COM 		opthdr->name = IP_PKTINFO;
567*12743SMarcel.Telka@Sun.COM 
568*12743SMarcel.Telka@Sun.COM 		/*
569*12743SMarcel.Telka@Sun.COM 		 * 1. set source IP of outbound packet
570*12743SMarcel.Telka@Sun.COM 		 * 2. value '0' for index means IP layer uses this as source
571*12743SMarcel.Telka@Sun.COM 		 *    address
572*12743SMarcel.Telka@Sun.COM 		 */
573*12743SMarcel.Telka@Sun.COM 		pktinfo = (in_pktinfo_t *)(opthdr + 1);
574*12743SMarcel.Telka@Sun.COM 		(void) memset(pktinfo, 0, sizeof (in_pktinfo_t));
575*12743SMarcel.Telka@Sun.COM 		pktinfo->ipi_spec_dst.s_addr =
576*12743SMarcel.Telka@Sun.COM 		    ((sin_t *)(clone_xprt->xp_lcladdr.buf))->sin_addr.s_addr;
577*12743SMarcel.Telka@Sun.COM 		pktinfo->ipi_ifindex = 0;
578*12743SMarcel.Telka@Sun.COM 
579*12743SMarcel.Telka@Sun.COM 		/* adjust the end of active data */
580*12743SMarcel.Telka@Sun.COM 		mp->b_wptr = mp->b_rptr + size;
581*12743SMarcel.Telka@Sun.COM 	}
582*12743SMarcel.Telka@Sun.COM 
5830Sstevel@tonic-gate 	put(clone_xprt->xp_wq, ud->ud_resp);
5840Sstevel@tonic-gate 	stat = TRUE;
5850Sstevel@tonic-gate 	ud->ud_resp = NULL;
5860Sstevel@tonic-gate 
5870Sstevel@tonic-gate out:
5880Sstevel@tonic-gate 	if (stat == FALSE) {
5890Sstevel@tonic-gate 		freemsg(ud->ud_resp);
5900Sstevel@tonic-gate 		ud->ud_resp = NULL;
5910Sstevel@tonic-gate 	}
5920Sstevel@tonic-gate 
5930Sstevel@tonic-gate 	/*
5940Sstevel@tonic-gate 	 * This is completely disgusting.  If public is set it is
5950Sstevel@tonic-gate 	 * a pointer to a structure whose first field is the address
5960Sstevel@tonic-gate 	 * of the function to free that structure and any related
5970Sstevel@tonic-gate 	 * stuff.  (see rrokfree in nfs_xdr.c).
5980Sstevel@tonic-gate 	 */
5990Sstevel@tonic-gate 	if (xdrs->x_public) {
6000Sstevel@tonic-gate 		/* LINTED pointer alignment */
6010Sstevel@tonic-gate 		(**((int (**)())xdrs->x_public))(xdrs->x_public);
6020Sstevel@tonic-gate 	}
6030Sstevel@tonic-gate 
6040Sstevel@tonic-gate 	TRACE_1(TR_FAC_KRPC, TR_SVC_CLTS_KSEND_END,
6050Sstevel@tonic-gate 	    "svc_clts_ksend_end:(%S)", "done");
6060Sstevel@tonic-gate 	return (stat);
6070Sstevel@tonic-gate }
6080Sstevel@tonic-gate 
6090Sstevel@tonic-gate /*
6100Sstevel@tonic-gate  * Deserialize arguments.
6110Sstevel@tonic-gate  */
6120Sstevel@tonic-gate static bool_t
svc_clts_kgetargs(SVCXPRT * clone_xprt,xdrproc_t xdr_args,caddr_t args_ptr)6130Sstevel@tonic-gate svc_clts_kgetargs(SVCXPRT *clone_xprt, xdrproc_t xdr_args,
6140Sstevel@tonic-gate     caddr_t args_ptr)
6150Sstevel@tonic-gate {
6160Sstevel@tonic-gate 
6170Sstevel@tonic-gate 	/* LINTED pointer alignment */
6180Sstevel@tonic-gate 	return (SVCAUTH_UNWRAP(&clone_xprt->xp_auth, &clone_xprt->xp_xdrin,
6197208Svv149972 	    xdr_args, args_ptr));
6200Sstevel@tonic-gate 
6210Sstevel@tonic-gate }
6220Sstevel@tonic-gate 
6230Sstevel@tonic-gate static bool_t
svc_clts_kfreeargs(SVCXPRT * clone_xprt,xdrproc_t xdr_args,caddr_t args_ptr)6240Sstevel@tonic-gate svc_clts_kfreeargs(SVCXPRT *clone_xprt, xdrproc_t xdr_args,
6250Sstevel@tonic-gate     caddr_t args_ptr)
6260Sstevel@tonic-gate {
6270Sstevel@tonic-gate 	/* LINTED pointer alignment */
6280Sstevel@tonic-gate 	struct udp_data *ud = (struct udp_data *)clone_xprt->xp_p2buf;
6290Sstevel@tonic-gate 	XDR *xdrs = &clone_xprt->xp_xdrin;
6300Sstevel@tonic-gate 	bool_t retval;
6310Sstevel@tonic-gate 
6320Sstevel@tonic-gate 	if (args_ptr) {
6330Sstevel@tonic-gate 		xdrs->x_op = XDR_FREE;
6340Sstevel@tonic-gate 		retval = (*xdr_args)(xdrs, args_ptr);
6350Sstevel@tonic-gate 	} else
6360Sstevel@tonic-gate 		retval = TRUE;
6370Sstevel@tonic-gate 
6380Sstevel@tonic-gate 	if (ud->ud_inmp) {
6390Sstevel@tonic-gate 		freemsg(ud->ud_inmp);
6400Sstevel@tonic-gate 		ud->ud_inmp = NULL;
6410Sstevel@tonic-gate 	}
6420Sstevel@tonic-gate 
6430Sstevel@tonic-gate 	return (retval);
6440Sstevel@tonic-gate }
6450Sstevel@tonic-gate 
6460Sstevel@tonic-gate static int32_t *
svc_clts_kgetres(SVCXPRT * clone_xprt,int size)6470Sstevel@tonic-gate svc_clts_kgetres(SVCXPRT *clone_xprt, int size)
6480Sstevel@tonic-gate {
6490Sstevel@tonic-gate 	/* LINTED pointer alignment */
6500Sstevel@tonic-gate 	struct udp_data *ud = (struct udp_data *)clone_xprt->xp_p2buf;
6510Sstevel@tonic-gate 	XDR *xdrs = &clone_xprt->xp_xdrout;
6520Sstevel@tonic-gate 	mblk_t *mp;
6530Sstevel@tonic-gate 	int32_t *buf;
6540Sstevel@tonic-gate 	struct rpc_msg rply;
6550Sstevel@tonic-gate 
6560Sstevel@tonic-gate 	/*
6570Sstevel@tonic-gate 	 * Allocate an initial mblk for the response data.
6580Sstevel@tonic-gate 	 */
6590Sstevel@tonic-gate 	while ((mp = allocb(UD_INITSIZE, BPRI_LO)) == NULL) {
6600Sstevel@tonic-gate 		if (strwaitbuf(UD_INITSIZE, BPRI_LO)) {
6610Sstevel@tonic-gate 			return (FALSE);
6620Sstevel@tonic-gate 		}
6630Sstevel@tonic-gate 	}
6640Sstevel@tonic-gate 
6650Sstevel@tonic-gate 	mp->b_cont = NULL;
6660Sstevel@tonic-gate 
6670Sstevel@tonic-gate 	/*
6680Sstevel@tonic-gate 	 * Initialize the XDR decode stream.  Additional mblks
6690Sstevel@tonic-gate 	 * will be allocated if necessary.  They will be UD_MAXSIZE
6700Sstevel@tonic-gate 	 * sized.
6710Sstevel@tonic-gate 	 */
6720Sstevel@tonic-gate 	xdrmblk_init(xdrs, mp, XDR_ENCODE, UD_MAXSIZE);
6730Sstevel@tonic-gate 
6740Sstevel@tonic-gate 	/*
6750Sstevel@tonic-gate 	 * Leave some space for protocol headers.
6760Sstevel@tonic-gate 	 */
6770Sstevel@tonic-gate 	(void) XDR_SETPOS(xdrs, 512);
6780Sstevel@tonic-gate 	mp->b_rptr += 512;
6790Sstevel@tonic-gate 
6800Sstevel@tonic-gate 	/*
6810Sstevel@tonic-gate 	 * Assume a successful RPC since most of them are.
6820Sstevel@tonic-gate 	 */
6830Sstevel@tonic-gate 	rply.rm_xid = clone_xprt->xp_xid;
6840Sstevel@tonic-gate 	rply.rm_direction = REPLY;
6850Sstevel@tonic-gate 	rply.rm_reply.rp_stat = MSG_ACCEPTED;
6860Sstevel@tonic-gate 	rply.acpted_rply.ar_verf = clone_xprt->xp_verf;
6870Sstevel@tonic-gate 	rply.acpted_rply.ar_stat = SUCCESS;
6880Sstevel@tonic-gate 
6890Sstevel@tonic-gate 	if (!xdr_replymsg_hdr(xdrs, &rply)) {
6900Sstevel@tonic-gate 		freeb(mp);
6910Sstevel@tonic-gate 		return (NULL);
6920Sstevel@tonic-gate 	}
6930Sstevel@tonic-gate 
6940Sstevel@tonic-gate 	buf = XDR_INLINE(xdrs, size);
6950Sstevel@tonic-gate 
6960Sstevel@tonic-gate 	if (buf == NULL)
6970Sstevel@tonic-gate 		freeb(mp);
6980Sstevel@tonic-gate 	else
6990Sstevel@tonic-gate 		ud->ud_resp->b_cont = mp;
7000Sstevel@tonic-gate 
7010Sstevel@tonic-gate 	return (buf);
7020Sstevel@tonic-gate }
7030Sstevel@tonic-gate 
7040Sstevel@tonic-gate static void
svc_clts_kfreeres(SVCXPRT * clone_xprt)7050Sstevel@tonic-gate svc_clts_kfreeres(SVCXPRT *clone_xprt)
7060Sstevel@tonic-gate {
7070Sstevel@tonic-gate 	/* LINTED pointer alignment */
7080Sstevel@tonic-gate 	struct udp_data *ud = (struct udp_data *)clone_xprt->xp_p2buf;
7090Sstevel@tonic-gate 
7100Sstevel@tonic-gate 	if (ud->ud_resp == NULL || ud->ud_resp->b_cont == NULL)
7110Sstevel@tonic-gate 		return;
7120Sstevel@tonic-gate 
7130Sstevel@tonic-gate 	/*
7140Sstevel@tonic-gate 	 * SVC_FREERES() is called whenever the server decides not to
7150Sstevel@tonic-gate 	 * send normal reply. Thus, we expect only one mblk to be allocated,
7160Sstevel@tonic-gate 	 * because we have not attempted any XDR encoding.
7170Sstevel@tonic-gate 	 * If we do any XDR encoding and we get an error, then SVC_REPLY()
7180Sstevel@tonic-gate 	 * will freemsg(ud->ud_resp);
7190Sstevel@tonic-gate 	 */
7200Sstevel@tonic-gate 	ASSERT(ud->ud_resp->b_cont->b_cont == NULL);
7210Sstevel@tonic-gate 	freeb(ud->ud_resp->b_cont);
7220Sstevel@tonic-gate 	ud->ud_resp->b_cont = NULL;
7230Sstevel@tonic-gate }
7240Sstevel@tonic-gate 
7250Sstevel@tonic-gate /*
7260Sstevel@tonic-gate  * the dup cacheing routines below provide a cache of non-failure
7270Sstevel@tonic-gate  * transaction id's.  rpc service routines can use this to detect
7280Sstevel@tonic-gate  * retransmissions and re-send a non-failure response.
7290Sstevel@tonic-gate  */
7300Sstevel@tonic-gate 
7310Sstevel@tonic-gate /*
7320Sstevel@tonic-gate  * MAXDUPREQS is the number of cached items.  It should be adjusted
7330Sstevel@tonic-gate  * to the service load so that there is likely to be a response entry
7340Sstevel@tonic-gate  * when the first retransmission comes in.
7350Sstevel@tonic-gate  */
7360Sstevel@tonic-gate #define	MAXDUPREQS	1024
7370Sstevel@tonic-gate 
7380Sstevel@tonic-gate /*
7390Sstevel@tonic-gate  * This should be appropriately scaled to MAXDUPREQS.
7400Sstevel@tonic-gate  */
7410Sstevel@tonic-gate #define	DRHASHSZ	257
7420Sstevel@tonic-gate 
7430Sstevel@tonic-gate #if ((DRHASHSZ & (DRHASHSZ - 1)) == 0)
7440Sstevel@tonic-gate #define	XIDHASH(xid)	((xid) & (DRHASHSZ - 1))
7450Sstevel@tonic-gate #else
7460Sstevel@tonic-gate #define	XIDHASH(xid)	((xid) % DRHASHSZ)
7470Sstevel@tonic-gate #endif
7480Sstevel@tonic-gate #define	DRHASH(dr)	XIDHASH((dr)->dr_xid)
7490Sstevel@tonic-gate #define	REQTOXID(req)	((req)->rq_xprt->xp_xid)
7500Sstevel@tonic-gate 
7510Sstevel@tonic-gate static int	ndupreqs = 0;
7527803Sgt29601@anthrax int	maxdupreqs = MAXDUPREQS;
7530Sstevel@tonic-gate static kmutex_t dupreq_lock;
7540Sstevel@tonic-gate static struct dupreq *drhashtbl[DRHASHSZ];
7550Sstevel@tonic-gate static int	drhashstat[DRHASHSZ];
7560Sstevel@tonic-gate 
7570Sstevel@tonic-gate static void unhash(struct dupreq *);
7580Sstevel@tonic-gate 
7590Sstevel@tonic-gate /*
7600Sstevel@tonic-gate  * drmru points to the head of a circular linked list in lru order.
7610Sstevel@tonic-gate  * drmru->dr_next == drlru
7620Sstevel@tonic-gate  */
7630Sstevel@tonic-gate struct dupreq *drmru;
7640Sstevel@tonic-gate 
7650Sstevel@tonic-gate /*
7660Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
7670Sstevel@tonic-gate  * svc_clts_kdup
7680Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
7690Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
7700Sstevel@tonic-gate  *
7710Sstevel@tonic-gate  * svc_clts_kdup searches the request cache and returns 0 if the
7720Sstevel@tonic-gate  * request is not found in the cache.  If it is found, then it
7730Sstevel@tonic-gate  * returns the state of the request (in progress or done) and
7740Sstevel@tonic-gate  * the status or attributes that were part of the original reply.
7750Sstevel@tonic-gate  *
7760Sstevel@tonic-gate  * If DUP_DONE (there is a duplicate) svc_clts_kdup copies over the
7770Sstevel@tonic-gate  * value of the response. In that case, also return in *dupcachedp
7780Sstevel@tonic-gate  * whether the response free routine is cached in the dupreq - in which case
7790Sstevel@tonic-gate  * the caller should not be freeing it, because it will be done later
7800Sstevel@tonic-gate  * in the svc_clts_kdup code when the dupreq is reused.
7810Sstevel@tonic-gate  */
7820Sstevel@tonic-gate static int
svc_clts_kdup(struct svc_req * req,caddr_t res,int size,struct dupreq ** drpp,bool_t * dupcachedp)7830Sstevel@tonic-gate svc_clts_kdup(struct svc_req *req, caddr_t res, int size, struct dupreq **drpp,
7840Sstevel@tonic-gate 	bool_t *dupcachedp)
7850Sstevel@tonic-gate {
7860Sstevel@tonic-gate 	struct rpc_clts_server *stats = CLONE2STATS(req->rq_xprt);
7870Sstevel@tonic-gate 	struct dupreq *dr;
7880Sstevel@tonic-gate 	uint32_t xid;
7890Sstevel@tonic-gate 	uint32_t drhash;
7900Sstevel@tonic-gate 	int status;
7910Sstevel@tonic-gate 
7920Sstevel@tonic-gate 	xid = REQTOXID(req);
7930Sstevel@tonic-gate 	mutex_enter(&dupreq_lock);
7940Sstevel@tonic-gate 	RSSTAT_INCR(stats, rsdupchecks);
7950Sstevel@tonic-gate 	/*
7960Sstevel@tonic-gate 	 * Check to see whether an entry already exists in the cache.
7970Sstevel@tonic-gate 	 */
7980Sstevel@tonic-gate 	dr = drhashtbl[XIDHASH(xid)];
7990Sstevel@tonic-gate 	while (dr != NULL) {
8000Sstevel@tonic-gate 		if (dr->dr_xid == xid &&
8010Sstevel@tonic-gate 		    dr->dr_proc == req->rq_proc &&
8020Sstevel@tonic-gate 		    dr->dr_prog == req->rq_prog &&
8030Sstevel@tonic-gate 		    dr->dr_vers == req->rq_vers &&
8040Sstevel@tonic-gate 		    dr->dr_addr.len == req->rq_xprt->xp_rtaddr.len &&
8050Sstevel@tonic-gate 		    bcmp(dr->dr_addr.buf, req->rq_xprt->xp_rtaddr.buf,
8060Sstevel@tonic-gate 		    dr->dr_addr.len) == 0) {
8070Sstevel@tonic-gate 			status = dr->dr_status;
8080Sstevel@tonic-gate 			if (status == DUP_DONE) {
8090Sstevel@tonic-gate 				bcopy(dr->dr_resp.buf, res, size);
8100Sstevel@tonic-gate 				if (dupcachedp != NULL)
8110Sstevel@tonic-gate 					*dupcachedp = (dr->dr_resfree != NULL);
8120Sstevel@tonic-gate 			} else {
8130Sstevel@tonic-gate 				dr->dr_status = DUP_INPROGRESS;
8140Sstevel@tonic-gate 				*drpp = dr;
8150Sstevel@tonic-gate 			}
8160Sstevel@tonic-gate 			RSSTAT_INCR(stats, rsdupreqs);
8170Sstevel@tonic-gate 			mutex_exit(&dupreq_lock);
8180Sstevel@tonic-gate 			return (status);
8190Sstevel@tonic-gate 		}
8200Sstevel@tonic-gate 		dr = dr->dr_chain;
8210Sstevel@tonic-gate 	}
8220Sstevel@tonic-gate 
8230Sstevel@tonic-gate 	/*
8240Sstevel@tonic-gate 	 * There wasn't an entry, either allocate a new one or recycle
8250Sstevel@tonic-gate 	 * an old one.
8260Sstevel@tonic-gate 	 */
8270Sstevel@tonic-gate 	if (ndupreqs < maxdupreqs) {
8280Sstevel@tonic-gate 		dr = kmem_alloc(sizeof (*dr), KM_NOSLEEP);
8290Sstevel@tonic-gate 		if (dr == NULL) {
8300Sstevel@tonic-gate 			mutex_exit(&dupreq_lock);
8310Sstevel@tonic-gate 			return (DUP_ERROR);
8320Sstevel@tonic-gate 		}
8330Sstevel@tonic-gate 		dr->dr_resp.buf = NULL;
8340Sstevel@tonic-gate 		dr->dr_resp.maxlen = 0;
8350Sstevel@tonic-gate 		dr->dr_addr.buf = NULL;
8360Sstevel@tonic-gate 		dr->dr_addr.maxlen = 0;
8370Sstevel@tonic-gate 		if (drmru) {
8380Sstevel@tonic-gate 			dr->dr_next = drmru->dr_next;
8390Sstevel@tonic-gate 			drmru->dr_next = dr;
8400Sstevel@tonic-gate 		} else {
8410Sstevel@tonic-gate 			dr->dr_next = dr;
8420Sstevel@tonic-gate 		}
8430Sstevel@tonic-gate 		ndupreqs++;
8440Sstevel@tonic-gate 	} else {
8450Sstevel@tonic-gate 		dr = drmru->dr_next;
8460Sstevel@tonic-gate 		while (dr->dr_status == DUP_INPROGRESS) {
8470Sstevel@tonic-gate 			dr = dr->dr_next;
8480Sstevel@tonic-gate 			if (dr == drmru->dr_next) {
8490Sstevel@tonic-gate 				cmn_err(CE_WARN, "svc_clts_kdup no slots free");
8500Sstevel@tonic-gate 				mutex_exit(&dupreq_lock);
8510Sstevel@tonic-gate 				return (DUP_ERROR);
8520Sstevel@tonic-gate 			}
8530Sstevel@tonic-gate 		}
8540Sstevel@tonic-gate 		unhash(dr);
8550Sstevel@tonic-gate 		if (dr->dr_resfree) {
8560Sstevel@tonic-gate 			(*dr->dr_resfree)(dr->dr_resp.buf);
8570Sstevel@tonic-gate 		}
8580Sstevel@tonic-gate 	}
8590Sstevel@tonic-gate 	dr->dr_resfree = NULL;
8600Sstevel@tonic-gate 	drmru = dr;
8610Sstevel@tonic-gate 
8620Sstevel@tonic-gate 	dr->dr_xid = REQTOXID(req);
8630Sstevel@tonic-gate 	dr->dr_prog = req->rq_prog;
8640Sstevel@tonic-gate 	dr->dr_vers = req->rq_vers;
8650Sstevel@tonic-gate 	dr->dr_proc = req->rq_proc;
8660Sstevel@tonic-gate 	if (dr->dr_addr.maxlen < req->rq_xprt->xp_rtaddr.len) {
8670Sstevel@tonic-gate 		if (dr->dr_addr.buf != NULL)
8680Sstevel@tonic-gate 			kmem_free(dr->dr_addr.buf, dr->dr_addr.maxlen);
8690Sstevel@tonic-gate 		dr->dr_addr.maxlen = req->rq_xprt->xp_rtaddr.len;
8700Sstevel@tonic-gate 		dr->dr_addr.buf = kmem_alloc(dr->dr_addr.maxlen,
8710Sstevel@tonic-gate 		    KM_NOSLEEP);
8720Sstevel@tonic-gate 		if (dr->dr_addr.buf == NULL) {
8730Sstevel@tonic-gate 			dr->dr_addr.maxlen = 0;
8740Sstevel@tonic-gate 			dr->dr_status = DUP_DROP;
8750Sstevel@tonic-gate 			mutex_exit(&dupreq_lock);
8760Sstevel@tonic-gate 			return (DUP_ERROR);
8770Sstevel@tonic-gate 		}
8780Sstevel@tonic-gate 	}
8790Sstevel@tonic-gate 	dr->dr_addr.len = req->rq_xprt->xp_rtaddr.len;
8800Sstevel@tonic-gate 	bcopy(req->rq_xprt->xp_rtaddr.buf, dr->dr_addr.buf, dr->dr_addr.len);
8810Sstevel@tonic-gate 	if (dr->dr_resp.maxlen < size) {
8820Sstevel@tonic-gate 		if (dr->dr_resp.buf != NULL)
8830Sstevel@tonic-gate 			kmem_free(dr->dr_resp.buf, dr->dr_resp.maxlen);
8840Sstevel@tonic-gate 		dr->dr_resp.maxlen = (unsigned int)size;
8850Sstevel@tonic-gate 		dr->dr_resp.buf = kmem_alloc(size, KM_NOSLEEP);
8860Sstevel@tonic-gate 		if (dr->dr_resp.buf == NULL) {
8870Sstevel@tonic-gate 			dr->dr_resp.maxlen = 0;
8880Sstevel@tonic-gate 			dr->dr_status = DUP_DROP;
8890Sstevel@tonic-gate 			mutex_exit(&dupreq_lock);
8900Sstevel@tonic-gate 			return (DUP_ERROR);
8910Sstevel@tonic-gate 		}
8920Sstevel@tonic-gate 	}
8930Sstevel@tonic-gate 	dr->dr_status = DUP_INPROGRESS;
8940Sstevel@tonic-gate 
8950Sstevel@tonic-gate 	drhash = (uint32_t)DRHASH(dr);
8960Sstevel@tonic-gate 	dr->dr_chain = drhashtbl[drhash];
8970Sstevel@tonic-gate 	drhashtbl[drhash] = dr;
8980Sstevel@tonic-gate 	drhashstat[drhash]++;
8990Sstevel@tonic-gate 	mutex_exit(&dupreq_lock);
9000Sstevel@tonic-gate 	*drpp = dr;
9010Sstevel@tonic-gate 	return (DUP_NEW);
9020Sstevel@tonic-gate }
9030Sstevel@tonic-gate 
9040Sstevel@tonic-gate /*
9050Sstevel@tonic-gate  * PSARC 2003/523 Contract Private Interface
9060Sstevel@tonic-gate  * svc_clts_kdupdone
9070Sstevel@tonic-gate  * Changes must be reviewed by Solaris File Sharing
9080Sstevel@tonic-gate  * Changes must be communicated to contract-2003-523@sun.com
9090Sstevel@tonic-gate  *
9100Sstevel@tonic-gate  * svc_clts_kdupdone marks the request done (DUP_DONE or DUP_DROP)
9110Sstevel@tonic-gate  * and stores the response.
9120Sstevel@tonic-gate  */
9130Sstevel@tonic-gate static void
svc_clts_kdupdone(struct dupreq * dr,caddr_t res,void (* dis_resfree)(),int size,int status)9140Sstevel@tonic-gate svc_clts_kdupdone(struct dupreq *dr, caddr_t res, void (*dis_resfree)(),
9150Sstevel@tonic-gate 	int size, int status)
9160Sstevel@tonic-gate {
9170Sstevel@tonic-gate 
9180Sstevel@tonic-gate 	ASSERT(dr->dr_resfree == NULL);
9190Sstevel@tonic-gate 	if (status == DUP_DONE) {
9200Sstevel@tonic-gate 		bcopy(res, dr->dr_resp.buf, size);
9210Sstevel@tonic-gate 		dr->dr_resfree = dis_resfree;
9220Sstevel@tonic-gate 	}
9230Sstevel@tonic-gate 	dr->dr_status = status;
9240Sstevel@tonic-gate }
9250Sstevel@tonic-gate 
9260Sstevel@tonic-gate /*
9270Sstevel@tonic-gate  * This routine expects that the mutex, dupreq_lock, is already held.
9280Sstevel@tonic-gate  */
9290Sstevel@tonic-gate static void
unhash(struct dupreq * dr)9300Sstevel@tonic-gate unhash(struct dupreq *dr)
9310Sstevel@tonic-gate {
9320Sstevel@tonic-gate 	struct dupreq *drt;
9330Sstevel@tonic-gate 	struct dupreq *drtprev = NULL;
9340Sstevel@tonic-gate 	uint32_t drhash;
9350Sstevel@tonic-gate 
9360Sstevel@tonic-gate 	ASSERT(MUTEX_HELD(&dupreq_lock));
9370Sstevel@tonic-gate 
9380Sstevel@tonic-gate 	drhash = (uint32_t)DRHASH(dr);
9390Sstevel@tonic-gate 	drt = drhashtbl[drhash];
9400Sstevel@tonic-gate 	while (drt != NULL) {
9410Sstevel@tonic-gate 		if (drt == dr) {
9420Sstevel@tonic-gate 			drhashstat[drhash]--;
9430Sstevel@tonic-gate 			if (drtprev == NULL) {
9440Sstevel@tonic-gate 				drhashtbl[drhash] = drt->dr_chain;
9450Sstevel@tonic-gate 			} else {
9460Sstevel@tonic-gate 				drtprev->dr_chain = drt->dr_chain;
9470Sstevel@tonic-gate 			}
9480Sstevel@tonic-gate 			return;
9490Sstevel@tonic-gate 		}
9500Sstevel@tonic-gate 		drtprev = drt;
9510Sstevel@tonic-gate 		drt = drt->dr_chain;
9520Sstevel@tonic-gate 	}
9530Sstevel@tonic-gate }
9540Sstevel@tonic-gate 
9550Sstevel@tonic-gate void
svc_clts_stats_init(zoneid_t zoneid,struct rpc_clts_server ** statsp)9560Sstevel@tonic-gate svc_clts_stats_init(zoneid_t zoneid, struct rpc_clts_server **statsp)
9570Sstevel@tonic-gate {
9580Sstevel@tonic-gate 	kstat_t *ksp;
9590Sstevel@tonic-gate 	kstat_named_t *knp;
9600Sstevel@tonic-gate 
9610Sstevel@tonic-gate 	knp = rpcstat_zone_init_common(zoneid, "unix", "rpc_clts_server",
9620Sstevel@tonic-gate 	    (const kstat_named_t *)&clts_rsstat_tmpl,
9630Sstevel@tonic-gate 	    sizeof (clts_rsstat_tmpl));
9640Sstevel@tonic-gate 	/*
9650Sstevel@tonic-gate 	 * Backwards compatibility for old kstat clients
9660Sstevel@tonic-gate 	 */
9670Sstevel@tonic-gate 	ksp = kstat_create_zone("unix", 0, "rpc_server", "rpc",
9680Sstevel@tonic-gate 	    KSTAT_TYPE_NAMED, clts_rsstat_ndata,
9690Sstevel@tonic-gate 	    KSTAT_FLAG_VIRTUAL | KSTAT_FLAG_WRITABLE, zoneid);
9700Sstevel@tonic-gate 	if (ksp) {
9710Sstevel@tonic-gate 		ksp->ks_data = knp;
9720Sstevel@tonic-gate 		kstat_install(ksp);
9730Sstevel@tonic-gate 	}
9740Sstevel@tonic-gate 	*statsp = (struct rpc_clts_server *)knp;
9750Sstevel@tonic-gate }
9760Sstevel@tonic-gate 
9770Sstevel@tonic-gate void
svc_clts_stats_fini(zoneid_t zoneid,struct rpc_clts_server ** statsp)9780Sstevel@tonic-gate svc_clts_stats_fini(zoneid_t zoneid, struct rpc_clts_server **statsp)
9790Sstevel@tonic-gate {
9800Sstevel@tonic-gate 	rpcstat_zone_fini_common(zoneid, "unix", "rpc_clts_server");
9810Sstevel@tonic-gate 	kstat_delete_byname_zone("unix", 0, "rpc_server", zoneid);
9820Sstevel@tonic-gate 	kmem_free(*statsp, sizeof (clts_rsstat_tmpl));
9830Sstevel@tonic-gate }
9840Sstevel@tonic-gate 
9850Sstevel@tonic-gate void
svc_clts_init()9860Sstevel@tonic-gate svc_clts_init()
9870Sstevel@tonic-gate {
9880Sstevel@tonic-gate 	/*
9890Sstevel@tonic-gate 	 * Check to make sure that the clts private data will fit into
9900Sstevel@tonic-gate 	 * the stack buffer allocated by svc_run.  The compiler should
9910Sstevel@tonic-gate 	 * remove this check, but it's a safety net if the udp_data
9920Sstevel@tonic-gate 	 * structure ever changes.
9930Sstevel@tonic-gate 	 */
9940Sstevel@tonic-gate 	/*CONSTANTCONDITION*/
9950Sstevel@tonic-gate 	ASSERT(sizeof (struct udp_data) <= SVC_P2LEN);
9960Sstevel@tonic-gate 
9970Sstevel@tonic-gate 	mutex_init(&dupreq_lock, NULL, MUTEX_DEFAULT, NULL);
9980Sstevel@tonic-gate }
999