/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
/*
* Server side for RPC in the kernel.
*
*/
#include <sys/sysmacros.h>
/*
* Routines exported through ops vector.
*/
static void svc_clts_kdestroy(SVCMASTERXPRT *);
void (*)(), int, int);
static void svc_clts_kclone_destroy(SVCXPRT *);
static void svc_clts_kfreeres(SVCXPRT *);
static void svc_clts_kstart(SVCMASTERXPRT *);
static void svc_clts_ktattrs(SVCXPRT *, int, void **);
/*
* Server transport operations vector.
*/
svc_clts_krecv, /* Get requests */
svc_clts_kgetargs, /* Deserialize arguments */
svc_clts_ksend, /* Send reply */
svc_clts_kfreeargs, /* Free argument data space */
svc_clts_kdestroy, /* Destroy transport handle */
svc_clts_kdup, /* Check entry in dup req cache */
svc_clts_kdupdone, /* Mark entry in dup req cache as done */
svc_clts_kgetres, /* Get pointer to response buffer */
svc_clts_kfreeres, /* Destroy pre-serialized response header */
svc_clts_kclone_destroy, /* Destroy a clone xprt */
svc_clts_kstart, /* Tell `ready-to-receive' to rpcmod */
svc_clts_kclone_xprt, /* transport specific clone xprt function */
svc_clts_ktattrs /* Transport specific attributes. */
};
/*
* Transport private data.
* Kept in xprt->xp_p2buf.
*/
struct udp_data {
};
/*
* Connectionless server statistics
*/
static const struct rpc_clts_server {
} clts_rsstat_tmpl = {
{ "calls", KSTAT_DATA_UINT64 },
{ "badcalls", KSTAT_DATA_UINT64 },
{ "nullrecv", KSTAT_DATA_UINT64 },
{ "badlen", KSTAT_DATA_UINT64 },
{ "xdrcall", KSTAT_DATA_UINT64 },
{ "dupchecks", KSTAT_DATA_UINT64 },
{ "dupreqs", KSTAT_DATA_UINT64 }
};
sizeof (clts_rsstat_tmpl) / sizeof (kstat_named_t);
/*
* Create a transport record.
* The transport record, output buffer, and private data structure
* are allocated. The output buffer is serialized into using xdrmem.
* There is one transport record per user process which implements a
* set of services.
*/
/* ARGSUSED */
int
{
return (EINVAL);
return (0);
}
/*
* Destroy a transport record.
* Frees the space allocated for a transport record.
*/
static void
{
}
/*
* Transport-type specific part of svc_xprt_cleanup().
* Frees the message buffer space allocated for a clone of a transport record
*/
static void
{
/* LINTED pointer alignment */
/*
* There should not be any left over results buffer.
*/
/*
* saved.
*/
}
}
/*
* svc_tli_kcreate() calls this function at the end to tell
* rpcmod that the transport is ready to receive requests.
*/
/* ARGSUSED */
static void
{
}
static void
{
}
static void
{
switch (attrflag) {
case SVC_TATTR_ADDRMASK:
}
}
/*
* Receive rpc requests.
* Pulls a request in off the socket, checks if the packet is intact,
* and deserializes the call packet.
*/
static bool_t
{
/* LINTED pointer alignment */
int hdrsz;
"svc_clts_krecv_start:");
/*
* The incoming request should start with an M_PROTO message.
*/
goto bad;
}
/*
* The incoming request should be an T_UNITDTA_IND. There
* might be other messages coming up the stream, but we can
* ignore them.
*/
goto bad;
}
/*
* Do some checking to make sure that the header at least looks okay.
*/
if (hdrsz < TUNITDATAINDSZ ||
goto bad;
}
/*
* Make sure that the transport provided a usable address.
*/
goto bad;
}
/*
* Point the remote transport address in the service_transport
* handle at the address in the request.
*/
/*
* Copy the local transport address in the service_transport
* handle at the address in the request. We will have only
* the local IP address in options.
*/
= AF_INET6;
= AF_INET;
}
}
/*
* Save the first mblk which contains the T_unidata_ind in
* ud_resp. It will be used to generate the T_unitdata_req
* during the reply.
* We reuse any options in the T_unitdata_ind for the T_unitdata_req
* since we must pass any SCM_UCRED across in order for TX to
* work. We also make sure any cred_t is carried across.
*/
}
}
/* Move any cred_t to the first mblk in the message */
"xdr_callmsg_start:");
"xdr_callmsg_end:(%S)", "bad");
goto bad;
}
"xdr_callmsg_end:(%S)", "good");
"svc_clts_krecv_end:(%S)", "good");
return (TRUE);
bad:
/*
* There should not be any left over results buffer.
*/
}
"svc_clts_krecv_end:(%S)", "bad");
return (FALSE);
}
/*
* Send rpc reply.
* Serialize the reply packet into the output buffer then
* call t_ksndudata to send it.
*/
static bool_t
{
/* LINTED pointer alignment */
int msgsz;
"svc_clts_ksend_start:");
/*
* If there is a result procedure specified in the reply message,
* it will be processed in the xdr_replymsg and SVCAUTH_WRAP.
* We need to make sure it won't be processed twice, so we null
* it for xdr_replymsg here.
*/
}
}
/*
* Allocate an initial mblk for the response data.
*/
"svc_clts_ksend_end:(%S)", "strwaitbuf");
return (FALSE);
}
}
/*
* Initialize the XDR encode stream. Additional mblks
* will be allocated if necessary. They will be UD_MAXSIZE
* sized.
*/
/*
* Leave some space for protocol headers.
*/
"xdr_replymsg_start:");
xdr_results, xdr_location)))) {
"xdr_replymsg_end:(%S)", "bad");
goto out;
}
"xdr_replymsg_end:(%S)", "good");
xdr_results, xdr_location)))) {
goto out;
}
#ifdef DEBUG
"KRPC: server response message of %d bytes; transport limits are [0, %d]",
#endif
goto out;
}
/*
* Construct the T_unitdata_req. We take advantage of the fact that
* T_unitdata_ind looks just like T_unitdata_req, except for the
* primitive type. Reusing it means we preserve the SCM_UCRED, and
* we must preserve it for TX to work.
*
* This has the side effect that we can also pass certain receive-side
* options like IPV6_PKTINFO back down the send side. This implies
* that we can not ASSERT on a non-NULL db_credp when we have send-side
* options in UDP.
*/
/*
* If the local IPv4 transport address is known use it as a source
* address for the outgoing UDP packet.
*/
if (udreq->DEST_length == 0)
else
udreq->DEST_length);
sizeof (in_pktinfo_t);
/* make sure we have enough space for the option data */
goto out;
/* set desired option header */
/*
* 1. set source IP of outbound packet
* 2. value '0' for index means IP layer uses this as source
* address
*/
pktinfo->ipi_ifindex = 0;
/* adjust the end of active data */
}
out:
}
/*
* This is completely disgusting. If public is set it is
* a pointer to a structure whose first field is the address
* of the function to free that structure and any related
* stuff. (see rrokfree in nfs_xdr.c).
*/
/* LINTED pointer alignment */
}
"svc_clts_ksend_end:(%S)", "done");
return (stat);
}
/*
* Deserialize arguments.
*/
static bool_t
{
/* LINTED pointer alignment */
}
static bool_t
{
/* LINTED pointer alignment */
if (args_ptr) {
} else
}
return (retval);
}
static int32_t *
{
/* LINTED pointer alignment */
/*
* Allocate an initial mblk for the response data.
*/
return (NULL);
}
}
/*
* Initialize the XDR encode stream. Additional mblks
* will be allocated if necessary. They will be UD_MAXSIZE
* sized.
*/
/*
* Leave some space for protocol headers.
*/
/*
* Assume a successful RPC since most of them are.
*/
return (NULL);
}
} else {
}
return (buf);
}
static void
{
/* LINTED pointer alignment */
return;
/*
* SVC_FREERES() is called whenever the server decides not to
* send normal reply. Thus, we expect only one mblk to be allocated,
* because we have not attempted any XDR encoding.
* If we do any XDR encoding and we get an error, then SVC_REPLY()
* will freemsg(ud->ud_resp);
*/
}
/*
* the dup cacheing routines below provide a cache of non-failure
* transaction id's. rpc service routines can use this to detect
* retransmissions and re-send a non-failure response.
*/
/*
* MAXDUPREQS is the number of cached items. It should be adjusted
* to the service load so that there is likely to be a response entry
* when the first retransmission comes in.
*/
/*
* This should be appropriately scaled to MAXDUPREQS.
*/
#else
#endif
static int ndupreqs = 0;
/*
* drmru points to the head of a circular linked list in lru order.
* drmru->dr_next == drlru
*/
/*
* PSARC 2003/523 Contract Private Interface
* svc_clts_kdup
* Changes must be reviewed by Solaris File Sharing
* Changes must be communicated to contract-2003-523@sun.com
*
* svc_clts_kdup searches the request cache and returns 0 if the
* request is not found in the cache. If it is found, then it
* returns the state of the request (in progress or done) and
* the status or attributes that were part of the original reply.
*
* If DUP_DONE (there is a duplicate) svc_clts_kdup copies over the
* value of the response. In that case, also return in *dupcachedp
* whether the response free routine is cached in the dupreq - in which case
* the caller should not be freeing it, because it will be done later
* in the svc_clts_kdup code when the dupreq is reused.
*/
static int
{
int status;
/*
* Check to see whether an entry already exists in the cache.
*/
if (dupcachedp != NULL)
} else {
}
return (status);
}
}
/*
* There wasn't an entry, either allocate a new one or recycle
* an old one.
*/
if (ndupreqs < maxdupreqs) {
return (DUP_ERROR);
}
if (drmru) {
} else {
}
ndupreqs++;
} else {
return (DUP_ERROR);
}
}
if (dr->dr_resfree) {
}
}
return (DUP_ERROR);
}
}
return (DUP_ERROR);
}
}
drhashstat[drhash]++;
return (DUP_NEW);
}
/*
* PSARC 2003/523 Contract Private Interface
* svc_clts_kdupdone
* Changes must be reviewed by Solaris File Sharing
* Changes must be communicated to contract-2003-523@sun.com
*
* svc_clts_kdupdone marks the request done (DUP_DONE or DUP_DROP)
* and stores the response.
*/
static void
{
}
}
/*
* This routine expects that the mutex, dupreq_lock, is already held.
*/
static void
{
drhashstat[drhash]--;
} else {
}
return;
}
}
}
void
{
(const kstat_named_t *)&clts_rsstat_tmpl,
sizeof (clts_rsstat_tmpl));
/*
* Backwards compatibility for old kstat clients
*/
if (ksp) {
}
}
void
{
}
void
{
/*
* Check to make sure that the clts private data will fit into
* the stack buffer allocated by svc_run. The compiler should
* remove this check, but it's a safety net if the udp_data
* structure ever changes.
*/
/*CONSTANTCONDITION*/
}