/*
* 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 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <rpc/rpcb_prot.h>
#include <rpcsvc/nlm_prot.h>
#include <rpcsvc/sm_inter.h>
#include "nlm_impl.h"
/*
* The following errors codes from nlm_null_rpc indicate that the port we have
* cached for the client's NLM service is stale and that we need to establish
* a new RPC client.
*/
((_status) == RPC_PROGUNAVAIL || \
(_status) == RPC_PROGVERSMISMATCH || \
(_status) == RPC_PROCUNAVAIL || \
(_status) == RPC_CANTCONNECT || \
(_status) == RPC_XPRTFAILED)
static int nlm_rpch_ctor(void *, void *, int);
static void nlm_rpch_dtor(void *, void *);
static void destroy_rpch(nlm_rpc_t *);
static void update_host_rpcbinding(struct nlm_host *, int);
static nlm_rpc_t *
{
return (NULL);
break;
}
}
if (!found)
return (NULL);
return (rpcp);
}
/*
* Update host's RPC binding (host->nh_addr).
* The function is executed by only one thread at time.
*/
static void
{
/*
* Mark RPC binding state as "update in progress" in order
* to say other threads that they need to wait until binding
* is fully updated.
*/
}
/*
* Refresh RPC handle taken from host handles cache.
* This function is called when an RPC handle is either
* uninitialized or was initialized using a binding that's
* no longer current.
*/
static int
{
int ret;
/*
* Set the client's CLSET_NODELAYONERR option to true. The
* RPC clnt_call interface creates an artificial delay for
* certain call errors in order to prevent RPC consumers
* from getting into tight retry loops. Since this function is
* called by the NLM service routines we would like to avoid
* this artificial delay when possible. We do not retry if the
* NULL request fails so it is safe for us to turn this option
* on.
*/
NLM_ERR("Unable to set CLSET_NODELAYONERR\n");
}
} else {
if (ret == 0) {
/*
* Check whether host's RPC binding is still
* fresh, i.e. if remote program is still sits
* on the same port we assume. Call NULL proc
* to do it.
*
* Note: Even though we set no delay on error on the
* client handle the call to nlm_null_rpc can still
* delay for 10 seconds before returning an error. For
* example the no delay on error option is not honored
* for RPC_XPRTFAILED errors (see clnt_cots_kcallit).
*/
if (NLM_STALE_CLNT(stat)) {
}
}
}
return (ret);
}
/*
* Get RPC handle that can be used to talk to the NLM
* of given version running on given host.
* Saves obtained RPC handle to rpcpp argument.
*
* If error occures, return nonzero error code.
*/
int
{
int rc;
/*
* If this handle is either uninitialized, or was
* initialized using binding that's now stale
* do the init or re-init.
* See comments to enum nlm_rpcb_state for more
* details.
*/
if (rc == 0) {
return (EINTR);
}
}
/*
* Check if RPC binding was marked for update.
* If so, start RPC binding update operation.
* NOTE: the operation can be executed by only
* one thread at time.
*/
/*
* Check if RPC error occured during RPC binding
* update operation. If so, report a correspoding
* error.
*/
return (ENOENT);
}
}
/*
* There weren't any RPC handles in a host
* cache. No luck, just create a new one.
*/
}
/*
* Refresh RPC binding
*/
if (rc != 0) {
/*
* Host's RPC binding is stale, we have
* to update it. Put the RPC handle back
* to the cache and mark the host as
* "need update".
*/
goto again;
}
return (rc);
}
return (0);
}
void
{
}
static void
{
}
/*
* The function invalidates host's RPC binding by marking it
* as not fresh. In this case another time thread tries to
* get RPC handle from host's handles cache, host's RPC binding
* will be updated.
*
* The function should be executed when RPC call invoked via
* handle taken from RPC cache returns RPC_PROCUNAVAIL.
*/
void
{
}
void
nlm_rpc_init(void)
{
}
void
{
/*
* There's no need to lock host's mutex here,
* nlm_rpc_cache_destroy() should be called from
* only one place: nlm_host_destroy, when all
* resources host owns are already cleaned up.
* So there shouldn't be any raises.
*/
}
}
/* ARGSUSED */
static int
{
return (0);
}
/* ARGSUSED */
static void
{
}
static void
{
}
}