2021-08-22 02:00:30 +03:00
|
|
|
/* $NetBSD: svc.c,v 1.40 2021/08/21 23:00:30 andvar Exp $ */
|
1995-02-25 06:01:33 +03:00
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
/*
|
2013-03-12 00:19:28 +04:00
|
|
|
* Copyright (c) 2010, Oracle America, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials
|
|
|
|
* provided with the distribution.
|
|
|
|
* * Neither the name of the "Oracle America, Inc." nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
|
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1993-10-07 10:29:33 +03:00
|
|
|
*/
|
|
|
|
|
1997-07-14 00:13:02 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-10-07 10:29:33 +03:00
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
1997-07-14 00:13:02 +04:00
|
|
|
#if 0
|
|
|
|
static char *sccsid = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";
|
|
|
|
static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC";
|
|
|
|
#else
|
2021-08-22 02:00:30 +03:00
|
|
|
__RCSID("$NetBSD: svc.c,v 1.40 2021/08/21 23:00:30 andvar Exp $");
|
1997-07-14 00:13:02 +04:00
|
|
|
#endif
|
1993-10-07 10:29:33 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* svc.c, Server-side remote procedure call interface.
|
|
|
|
*
|
|
|
|
* There are two sets of procedures here. The xprt routines are
|
|
|
|
* for handling transport handles. The svc routines handle the
|
|
|
|
* list of service routines.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1984, Sun Microsystems, Inc.
|
|
|
|
*/
|
|
|
|
|
1997-07-21 18:06:24 +04:00
|
|
|
#include "namespace.h"
|
2000-06-03 03:11:05 +04:00
|
|
|
#include "reentrant.h"
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/poll.h>
|
1999-09-16 15:44:54 +04:00
|
|
|
#include <assert.h>
|
1998-02-13 08:52:11 +03:00
|
|
|
#include <errno.h>
|
1994-12-04 04:12:39 +03:00
|
|
|
#include <stdlib.h>
|
1996-05-17 02:52:21 +04:00
|
|
|
#include <string.h>
|
2008-04-25 21:44:44 +04:00
|
|
|
#include <err.h>
|
1994-12-04 04:12:39 +03:00
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
#include <rpc/rpc.h>
|
2000-06-03 03:11:05 +04:00
|
|
|
#ifdef PORTMAP
|
1993-10-07 10:29:33 +03:00
|
|
|
#include <rpc/pmap_clnt.h>
|
2000-06-03 03:11:05 +04:00
|
|
|
#endif
|
|
|
|
|
2013-03-05 23:55:22 +04:00
|
|
|
#include "svc_fdset.h"
|
2002-11-08 03:13:07 +03:00
|
|
|
#include "rpc_internal.h"
|
1993-10-07 10:29:33 +03:00
|
|
|
|
1997-07-21 18:06:24 +04:00
|
|
|
#ifdef __weak_alias
|
2000-01-23 01:19:07 +03:00
|
|
|
__weak_alias(svc_getreq,_svc_getreq)
|
|
|
|
__weak_alias(svc_getreqset,_svc_getreqset)
|
2000-06-03 03:11:05 +04:00
|
|
|
__weak_alias(svc_getreq_common,_svc_getreq_common)
|
2000-01-23 01:19:07 +03:00
|
|
|
__weak_alias(svc_register,_svc_register)
|
2000-06-03 03:11:05 +04:00
|
|
|
__weak_alias(svc_reg,_svc_reg)
|
|
|
|
__weak_alias(svc_unreg,_svc_unreg)
|
2000-01-23 01:19:07 +03:00
|
|
|
__weak_alias(svc_sendreply,_svc_sendreply)
|
|
|
|
__weak_alias(svc_unregister,_svc_unregister)
|
|
|
|
__weak_alias(svcerr_auth,_svcerr_auth)
|
|
|
|
__weak_alias(svcerr_decode,_svcerr_decode)
|
|
|
|
__weak_alias(svcerr_noproc,_svcerr_noproc)
|
|
|
|
__weak_alias(svcerr_noprog,_svcerr_noprog)
|
|
|
|
__weak_alias(svcerr_progvers,_svcerr_progvers)
|
|
|
|
__weak_alias(svcerr_systemerr,_svcerr_systemerr)
|
|
|
|
__weak_alias(svcerr_weakauth,_svcerr_weakauth)
|
|
|
|
__weak_alias(xprt_register,_xprt_register)
|
|
|
|
__weak_alias(xprt_unregister,_xprt_unregister)
|
2002-11-08 03:13:07 +03:00
|
|
|
__weak_alias(rpc_control,_rpc_control)
|
1997-07-21 18:06:24 +04:00
|
|
|
#endif
|
|
|
|
|
2015-11-06 22:34:13 +03:00
|
|
|
/* __svc_xports[-1] is reserved for raw */
|
2002-11-08 03:13:07 +03:00
|
|
|
SVCXPRT **__svc_xports;
|
2015-11-06 22:34:13 +03:00
|
|
|
int __svc_maxxports;
|
2002-11-08 03:13:07 +03:00
|
|
|
int __svc_maxrec;
|
1993-10-07 10:29:33 +03:00
|
|
|
|
|
|
|
#define RQCRED_SIZE 400 /* this size is excessive */
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
#define SVC_VERSQUIET 0x0001 /* keep quiet about vers mismatch */
|
|
|
|
#define version_keepquiet(xp) ((u_long)(xp)->xp_p3 & SVC_VERSQUIET)
|
|
|
|
|
1994-08-20 04:55:26 +04:00
|
|
|
#define max(a, b) (a > b ? a : b)
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
/*
|
|
|
|
* The services list
|
|
|
|
* Each entry represents a set of procedures (an rpc program).
|
|
|
|
* The dispatch routine takes request structs and runs the
|
2021-08-22 02:00:30 +03:00
|
|
|
* appropriate procedure.
|
1993-10-07 10:29:33 +03:00
|
|
|
*/
|
|
|
|
static struct svc_callout {
|
|
|
|
struct svc_callout *sc_next;
|
2000-06-03 03:11:05 +04:00
|
|
|
rpcprog_t sc_prog;
|
|
|
|
rpcvers_t sc_vers;
|
|
|
|
char *sc_netid;
|
2012-03-20 21:14:50 +04:00
|
|
|
void (*sc_dispatch)(struct svc_req *, SVCXPRT *);
|
1993-10-07 10:29:33 +03:00
|
|
|
} *svc_head;
|
|
|
|
|
2003-01-18 13:52:16 +03:00
|
|
|
#ifdef _REENTRANT
|
2000-06-03 03:11:05 +04:00
|
|
|
extern rwlock_t svc_lock;
|
|
|
|
extern rwlock_t svc_fd_lock;
|
|
|
|
#endif
|
|
|
|
|
2012-03-20 21:14:50 +04:00
|
|
|
static struct svc_callout *svc_find(rpcprog_t, rpcvers_t,
|
|
|
|
struct svc_callout **, char *);
|
|
|
|
static void __xprt_do_unregister(SVCXPRT *xprt, bool_t dolock);
|
1993-10-07 10:29:33 +03:00
|
|
|
|
|
|
|
/* *************** SVCXPRT related stuff **************** */
|
|
|
|
|
2015-11-06 22:34:13 +03:00
|
|
|
static bool_t
|
|
|
|
xprt_alloc(int sock)
|
|
|
|
{
|
2015-11-13 18:22:12 +03:00
|
|
|
int oldmaxxports, newmaxxports;
|
2015-11-13 13:43:32 +03:00
|
|
|
SVCXPRT **oldxports, **newxports;
|
2015-11-06 22:34:13 +03:00
|
|
|
|
|
|
|
if (++sock < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2015-11-13 18:22:12 +03:00
|
|
|
newmaxxports = svc_fdset_getsize(sock);
|
|
|
|
if (newmaxxports == -1)
|
2015-11-06 22:34:13 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2015-11-13 18:22:12 +03:00
|
|
|
if (__svc_xports != NULL && newmaxxports < __svc_maxxports)
|
2015-11-06 22:34:13 +03:00
|
|
|
return TRUE;
|
|
|
|
|
2015-11-13 13:43:32 +03:00
|
|
|
oldxports = __svc_xports;
|
2015-11-13 18:22:12 +03:00
|
|
|
oldmaxxports = __svc_maxxports;
|
|
|
|
if (oldxports != NULL) {
|
|
|
|
/* revert saving [-1] slot */
|
2015-11-13 13:43:32 +03:00
|
|
|
--oldxports;
|
2015-11-13 18:22:12 +03:00
|
|
|
++oldmaxxports;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reserve an extra slot for [-1] */
|
|
|
|
newmaxxports++;
|
|
|
|
newxports = realloc(oldxports, newmaxxports * sizeof(SVCXPRT *));
|
2015-11-06 22:34:13 +03:00
|
|
|
if (newxports == NULL) {
|
|
|
|
warn("%s: out of memory", __func__);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-11-13 18:22:12 +03:00
|
|
|
memset(&newxports[oldmaxxports], 0,
|
|
|
|
(newmaxxports - oldmaxxports) * sizeof(SVCXPRT *));
|
2015-11-06 22:34:13 +03:00
|
|
|
|
2015-11-13 18:22:12 +03:00
|
|
|
/* save one slot for [-1] */
|
|
|
|
__svc_xports = newxports + 1;
|
|
|
|
__svc_maxxports = newmaxxports - 1;
|
2015-11-06 22:34:13 +03:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
/*
|
|
|
|
* Activate a transport handle.
|
|
|
|
*/
|
2013-03-04 21:29:03 +04:00
|
|
|
bool_t
|
2012-03-20 21:14:50 +04:00
|
|
|
xprt_register(SVCXPRT *xprt)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
1999-09-16 15:44:54 +04:00
|
|
|
int sock;
|
|
|
|
|
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
2015-11-06 22:34:13 +03:00
|
|
|
rwlock_wrlock(&svc_fd_lock);
|
2000-06-03 03:11:05 +04:00
|
|
|
sock = xprt->xp_fd;
|
1993-10-07 10:29:33 +03:00
|
|
|
|
2015-11-06 22:34:13 +03:00
|
|
|
if (!xprt_alloc(sock))
|
2013-03-04 21:29:03 +04:00
|
|
|
goto out;
|
2015-11-06 22:34:13 +03:00
|
|
|
|
2013-03-04 21:29:03 +04:00
|
|
|
__svc_xports[sock] = xprt;
|
2015-11-06 22:34:13 +03:00
|
|
|
if (sock != -1) {
|
2015-11-07 20:34:33 +03:00
|
|
|
if (svc_fdset_set(sock) == -1)
|
|
|
|
return FALSE;
|
2015-11-06 22:34:13 +03:00
|
|
|
}
|
2013-03-04 21:29:03 +04:00
|
|
|
rwlock_unlock(&svc_fd_lock);
|
|
|
|
return (TRUE);
|
|
|
|
|
2008-04-25 21:44:44 +04:00
|
|
|
out:
|
2000-06-03 03:11:05 +04:00
|
|
|
rwlock_unlock(&svc_fd_lock);
|
2013-03-04 21:29:03 +04:00
|
|
|
return (FALSE);
|
1993-10-07 10:29:33 +03:00
|
|
|
}
|
|
|
|
|
2002-11-08 03:13:07 +03:00
|
|
|
void
|
|
|
|
xprt_unregister(SVCXPRT *xprt)
|
|
|
|
{
|
|
|
|
__xprt_do_unregister(xprt, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
__xprt_unregister_unlocked(SVCXPRT *xprt)
|
|
|
|
{
|
|
|
|
__xprt_do_unregister(xprt, FALSE);
|
|
|
|
}
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
/*
|
|
|
|
* De-activate a transport handle.
|
|
|
|
*/
|
2002-11-08 03:13:07 +03:00
|
|
|
static void
|
2012-03-20 21:14:50 +04:00
|
|
|
__xprt_do_unregister(SVCXPRT *xprt, bool_t dolock)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
2015-11-06 22:34:13 +03:00
|
|
|
int sock, *fdmax;
|
1999-09-16 15:44:54 +04:00
|
|
|
|
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
2002-11-08 03:13:07 +03:00
|
|
|
if (dolock)
|
|
|
|
rwlock_wrlock(&svc_fd_lock);
|
2015-11-06 22:34:13 +03:00
|
|
|
|
|
|
|
sock = xprt->xp_fd;
|
|
|
|
if (sock >= __svc_maxxports || __svc_xports[sock] != xprt)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
__svc_xports[sock] = NULL;
|
|
|
|
if (sock == -1)
|
|
|
|
goto out;
|
|
|
|
fdmax = svc_fdset_getmax();
|
2015-11-07 20:34:33 +03:00
|
|
|
if (fdmax == NULL || sock < *fdmax)
|
2015-11-06 22:34:13 +03:00
|
|
|
goto clr;
|
|
|
|
|
|
|
|
for ((*fdmax)--; *fdmax >= 0; (*fdmax)--)
|
|
|
|
if (__svc_xports[*fdmax])
|
|
|
|
break;
|
|
|
|
clr:
|
|
|
|
svc_fdset_clr(sock);
|
|
|
|
out:
|
2002-11-08 03:13:07 +03:00
|
|
|
if (dolock)
|
|
|
|
rwlock_unlock(&svc_fd_lock);
|
1993-10-07 10:29:33 +03:00
|
|
|
}
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
/*
|
|
|
|
* Add a service program to the callout list.
|
|
|
|
* The dispatch routine will be called when a rpc request for this
|
|
|
|
* program number comes in.
|
|
|
|
*/
|
|
|
|
bool_t
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_reg(SVCXPRT *xprt, const rpcprog_t prog, const rpcvers_t vers,
|
|
|
|
void (*dispatch)(struct svc_req *, SVCXPRT *),
|
|
|
|
const struct netconfig *nconf)
|
2000-06-03 03:11:05 +04:00
|
|
|
{
|
|
|
|
bool_t dummy;
|
|
|
|
struct svc_callout *prev;
|
2000-07-06 07:10:34 +04:00
|
|
|
struct svc_callout *s;
|
2000-06-03 03:11:05 +04:00
|
|
|
struct netconfig *tnconf;
|
2000-07-06 07:10:34 +04:00
|
|
|
char *netid = NULL;
|
2000-06-03 03:11:05 +04:00
|
|
|
int flag = 0;
|
|
|
|
|
2001-01-04 17:42:18 +03:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
/* XXX: dispatch may be NULL ??? */
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
/* VARIABLES PROTECTED BY svc_lock: s, prev, svc_head */
|
|
|
|
|
|
|
|
if (xprt->xp_netid) {
|
|
|
|
netid = strdup(xprt->xp_netid);
|
|
|
|
flag = 1;
|
|
|
|
} else if (nconf && nconf->nc_netid) {
|
|
|
|
netid = strdup(nconf->nc_netid);
|
|
|
|
flag = 1;
|
|
|
|
} else if ((tnconf = __rpcgettp(xprt->xp_fd)) != NULL) {
|
|
|
|
netid = strdup(tnconf->nc_netid);
|
|
|
|
flag = 1;
|
|
|
|
freenetconfigent(tnconf);
|
|
|
|
} /* must have been created with svc_raw_create */
|
|
|
|
if ((netid == NULL) && (flag == 1)) {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
rwlock_wrlock(&svc_lock);
|
2000-07-06 07:10:34 +04:00
|
|
|
if ((s = svc_find(prog, vers, &prev, netid)) != NULL) {
|
2000-06-03 03:11:05 +04:00
|
|
|
if (netid)
|
|
|
|
free(netid);
|
|
|
|
if (s->sc_dispatch == dispatch)
|
|
|
|
goto rpcb_it; /* he is registering another xptr */
|
|
|
|
rwlock_unlock(&svc_lock);
|
|
|
|
return (FALSE);
|
|
|
|
}
|
2000-07-06 07:10:34 +04:00
|
|
|
s = mem_alloc(sizeof (struct svc_callout));
|
|
|
|
if (s == NULL) {
|
2000-06-03 03:11:05 +04:00
|
|
|
if (netid)
|
|
|
|
free(netid);
|
|
|
|
rwlock_unlock(&svc_lock);
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
2008-04-25 21:44:44 +04:00
|
|
|
if ((xprt->xp_netid == NULL) && (flag == 1) && netid)
|
|
|
|
if ((((SVCXPRT *) xprt)->xp_netid = strdup(netid)) == NULL) {
|
|
|
|
warn("svc_reg");
|
|
|
|
mem_free(s, sizeof(struct svc_callout));
|
|
|
|
rwlock_unlock(&svc_lock);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
s->sc_prog = prog;
|
|
|
|
s->sc_vers = vers;
|
|
|
|
s->sc_dispatch = dispatch;
|
|
|
|
s->sc_netid = netid;
|
|
|
|
s->sc_next = svc_head;
|
|
|
|
svc_head = s;
|
|
|
|
|
|
|
|
rpcb_it:
|
|
|
|
rwlock_unlock(&svc_lock);
|
|
|
|
/* now register the information with the local binder service */
|
|
|
|
if (nconf) {
|
2005-11-29 06:11:58 +03:00
|
|
|
dummy = rpcb_set(prog, vers, __UNCONST(nconf),
|
2000-06-03 03:11:05 +04:00
|
|
|
&((SVCXPRT *) xprt)->xp_ltaddr);
|
|
|
|
return (dummy);
|
|
|
|
}
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove a service program from the callout list.
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_unreg(const rpcprog_t prog, const rpcvers_t vers)
|
2000-06-03 03:11:05 +04:00
|
|
|
{
|
|
|
|
struct svc_callout *prev;
|
2000-07-06 07:10:34 +04:00
|
|
|
struct svc_callout *s;
|
2000-06-03 03:11:05 +04:00
|
|
|
|
|
|
|
/* unregister the information anyway */
|
|
|
|
(void) rpcb_unset(prog, vers, NULL);
|
|
|
|
rwlock_wrlock(&svc_lock);
|
2000-07-06 07:10:34 +04:00
|
|
|
while ((s = svc_find(prog, vers, &prev, NULL)) != NULL) {
|
|
|
|
if (prev == NULL) {
|
2000-06-03 03:11:05 +04:00
|
|
|
svc_head = s->sc_next;
|
|
|
|
} else {
|
|
|
|
prev->sc_next = s->sc_next;
|
|
|
|
}
|
2000-07-06 07:10:34 +04:00
|
|
|
s->sc_next = NULL;
|
2000-06-03 03:11:05 +04:00
|
|
|
if (s->sc_netid)
|
2000-07-06 07:10:34 +04:00
|
|
|
mem_free(s->sc_netid, sizeof (s->sc_netid) + 1);
|
|
|
|
mem_free(s, sizeof (struct svc_callout));
|
2000-06-03 03:11:05 +04:00
|
|
|
}
|
|
|
|
rwlock_unlock(&svc_lock);
|
|
|
|
}
|
1993-10-07 10:29:33 +03:00
|
|
|
|
|
|
|
/* ********************** CALLOUT list related stuff ************* */
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
#ifdef PORTMAP
|
1993-10-07 10:29:33 +03:00
|
|
|
/*
|
|
|
|
* Add a service program to the callout list.
|
|
|
|
* The dispatch routine will be called when a rpc request for this
|
|
|
|
* program number comes in.
|
|
|
|
*/
|
|
|
|
bool_t
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_register(SVCXPRT *xprt, u_long prog, u_long vers,
|
|
|
|
void (*dispatch)(struct svc_req *, SVCXPRT *), int protocol)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
struct svc_callout *prev;
|
1998-02-13 08:52:11 +03:00
|
|
|
struct svc_callout *s;
|
1993-10-07 10:29:33 +03:00
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
_DIAGASSERT(dispatch != NULL);
|
|
|
|
|
2000-07-06 07:10:34 +04:00
|
|
|
if ((s = svc_find((rpcprog_t)prog, (rpcvers_t)vers, &prev, NULL)) !=
|
|
|
|
NULL) {
|
1993-10-07 10:29:33 +03:00
|
|
|
if (s->sc_dispatch == dispatch)
|
|
|
|
goto pmap_it; /* he is registering another xptr */
|
|
|
|
return (FALSE);
|
|
|
|
}
|
2000-07-06 07:10:34 +04:00
|
|
|
s = mem_alloc(sizeof(struct svc_callout));
|
|
|
|
if (s == NULL) {
|
1993-10-07 10:29:33 +03:00
|
|
|
return (FALSE);
|
|
|
|
}
|
2000-07-06 07:10:34 +04:00
|
|
|
s->sc_prog = (rpcprog_t)prog;
|
|
|
|
s->sc_vers = (rpcvers_t)vers;
|
1993-10-07 10:29:33 +03:00
|
|
|
s->sc_dispatch = dispatch;
|
|
|
|
s->sc_next = svc_head;
|
|
|
|
svc_head = s;
|
|
|
|
pmap_it:
|
|
|
|
/* now register the information with the local binder service */
|
|
|
|
if (protocol) {
|
|
|
|
return (pmap_set(prog, vers, protocol, xprt->xp_port));
|
|
|
|
}
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove a service program from the callout list.
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_unregister(u_long prog, u_long vers)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
struct svc_callout *prev;
|
1998-02-13 08:52:11 +03:00
|
|
|
struct svc_callout *s;
|
1993-10-07 10:29:33 +03:00
|
|
|
|
2000-07-06 07:10:34 +04:00
|
|
|
if ((s = svc_find((rpcprog_t)prog, (rpcvers_t)vers, &prev, NULL)) ==
|
|
|
|
NULL)
|
1993-10-07 10:29:33 +03:00
|
|
|
return;
|
2000-07-06 07:10:34 +04:00
|
|
|
if (prev == NULL) {
|
1993-10-07 10:29:33 +03:00
|
|
|
svc_head = s->sc_next;
|
|
|
|
} else {
|
|
|
|
prev->sc_next = s->sc_next;
|
|
|
|
}
|
2000-07-06 07:10:34 +04:00
|
|
|
s->sc_next = NULL;
|
1998-11-15 20:32:41 +03:00
|
|
|
mem_free(s, sizeof(struct svc_callout));
|
1993-10-07 10:29:33 +03:00
|
|
|
/* now unregister the information with the local binder service */
|
|
|
|
(void)pmap_unset(prog, vers);
|
|
|
|
}
|
2000-06-03 03:11:05 +04:00
|
|
|
#endif /* PORTMAP */
|
1993-10-07 10:29:33 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Search the callout list for a program number, return the callout
|
|
|
|
* struct.
|
|
|
|
*/
|
|
|
|
static struct svc_callout *
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_find(rpcprog_t prog, rpcvers_t vers, struct svc_callout **prev, char *netid)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
1998-02-13 08:52:11 +03:00
|
|
|
struct svc_callout *s, *p;
|
1993-10-07 10:29:33 +03:00
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(prev != NULL);
|
2001-01-04 17:42:18 +03:00
|
|
|
/* netid is handled below */
|
1999-09-16 15:44:54 +04:00
|
|
|
|
2000-07-06 07:10:34 +04:00
|
|
|
p = NULL;
|
|
|
|
for (s = svc_head; s != NULL; s = s->sc_next) {
|
2000-06-03 03:11:05 +04:00
|
|
|
if (((s->sc_prog == prog) && (s->sc_vers == vers)) &&
|
|
|
|
((netid == NULL) || (s->sc_netid == NULL) ||
|
|
|
|
(strcmp(netid, s->sc_netid) == 0)))
|
|
|
|
break;
|
1993-10-07 10:29:33 +03:00
|
|
|
p = s;
|
|
|
|
}
|
|
|
|
*prev = p;
|
|
|
|
return (s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ******************* REPLY GENERATION ROUTINES ************ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a reply to an rpc request
|
|
|
|
*/
|
|
|
|
bool_t
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_sendreply(SVCXPRT *xprt, xdrproc_t xdr_results, const char *xdr_location)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
struct rpc_msg rply;
|
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
rply.rm_direction = REPLY;
|
|
|
|
rply.rm_reply.rp_stat = MSG_ACCEPTED;
|
|
|
|
rply.acpted_rply.ar_verf = xprt->xp_verf;
|
|
|
|
rply.acpted_rply.ar_stat = SUCCESS;
|
|
|
|
rply.acpted_rply.ar_results.where = xdr_location;
|
|
|
|
rply.acpted_rply.ar_results.proc = xdr_results;
|
|
|
|
return (SVC_REPLY(xprt, &rply));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* No procedure error reply
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svcerr_noproc(SVCXPRT *xprt)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
struct rpc_msg rply;
|
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
rply.rm_direction = REPLY;
|
|
|
|
rply.rm_reply.rp_stat = MSG_ACCEPTED;
|
|
|
|
rply.acpted_rply.ar_verf = xprt->xp_verf;
|
|
|
|
rply.acpted_rply.ar_stat = PROC_UNAVAIL;
|
|
|
|
SVC_REPLY(xprt, &rply);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Can't decode args error reply
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svcerr_decode(SVCXPRT *xprt)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
struct rpc_msg rply;
|
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
rply.rm_direction = REPLY;
|
|
|
|
rply.rm_reply.rp_stat = MSG_ACCEPTED;
|
|
|
|
rply.acpted_rply.ar_verf = xprt->xp_verf;
|
|
|
|
rply.acpted_rply.ar_stat = GARBAGE_ARGS;
|
|
|
|
SVC_REPLY(xprt, &rply);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some system error
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svcerr_systemerr(SVCXPRT *xprt)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
struct rpc_msg rply;
|
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
rply.rm_direction = REPLY;
|
|
|
|
rply.rm_reply.rp_stat = MSG_ACCEPTED;
|
|
|
|
rply.acpted_rply.ar_verf = xprt->xp_verf;
|
|
|
|
rply.acpted_rply.ar_stat = SYSTEM_ERR;
|
|
|
|
SVC_REPLY(xprt, &rply);
|
|
|
|
}
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* Tell RPC package to not complain about version errors to the client. This
|
|
|
|
* is useful when revving broadcast protocols that sit on a fixed address.
|
|
|
|
* There is really one (or should be only one) example of this kind of
|
|
|
|
* protocol: the portmapper (or rpc binder).
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
__svc_versquiet_on(SVCXPRT *xprt)
|
2000-06-03 03:11:05 +04:00
|
|
|
{
|
|
|
|
u_long tmp;
|
|
|
|
|
2001-01-04 17:42:18 +03:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
tmp = ((u_long) xprt->xp_p3) | SVC_VERSQUIET;
|
|
|
|
xprt->xp_p3 = (caddr_t) tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
__svc_versquiet_off(SVCXPRT *xprt)
|
2000-06-03 03:11:05 +04:00
|
|
|
{
|
|
|
|
u_long tmp;
|
|
|
|
|
2001-01-04 17:42:18 +03:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
tmp = ((u_long) xprt->xp_p3) & ~SVC_VERSQUIET;
|
|
|
|
xprt->xp_p3 = (caddr_t) tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_versquiet(SVCXPRT *xprt)
|
2000-06-03 03:11:05 +04:00
|
|
|
{
|
|
|
|
__svc_versquiet_on(xprt);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-03-20 21:14:50 +04:00
|
|
|
__svc_versquiet_get(SVCXPRT *xprt)
|
2000-06-03 03:11:05 +04:00
|
|
|
{
|
2001-01-04 17:42:18 +03:00
|
|
|
|
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
return ((int) xprt->xp_p3) & SVC_VERSQUIET;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
/*
|
|
|
|
* Authentication error reply
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svcerr_auth(SVCXPRT *xprt, enum auth_stat why)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
struct rpc_msg rply;
|
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
rply.rm_direction = REPLY;
|
|
|
|
rply.rm_reply.rp_stat = MSG_DENIED;
|
|
|
|
rply.rjcted_rply.rj_stat = AUTH_ERROR;
|
|
|
|
rply.rjcted_rply.rj_why = why;
|
|
|
|
SVC_REPLY(xprt, &rply);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Auth too weak error reply
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svcerr_weakauth(SVCXPRT *xprt)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
svcerr_auth(xprt, AUTH_TOOWEAK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Program unavailable error reply
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svcerr_noprog(SVCXPRT *xprt)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
struct rpc_msg rply;
|
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
rply.rm_direction = REPLY;
|
|
|
|
rply.rm_reply.rp_stat = MSG_ACCEPTED;
|
|
|
|
rply.acpted_rply.ar_verf = xprt->xp_verf;
|
|
|
|
rply.acpted_rply.ar_stat = PROG_UNAVAIL;
|
|
|
|
SVC_REPLY(xprt, &rply);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Program version mismatch error reply
|
|
|
|
*/
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svcerr_progvers(SVCXPRT *xprt, rpcvers_t low_vers, rpcvers_t high_vers)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
|
|
|
struct rpc_msg rply;
|
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(xprt != NULL);
|
|
|
|
|
1993-10-07 10:29:33 +03:00
|
|
|
rply.rm_direction = REPLY;
|
|
|
|
rply.rm_reply.rp_stat = MSG_ACCEPTED;
|
|
|
|
rply.acpted_rply.ar_verf = xprt->xp_verf;
|
|
|
|
rply.acpted_rply.ar_stat = PROG_MISMATCH;
|
1998-11-15 20:32:41 +03:00
|
|
|
rply.acpted_rply.ar_vers.low = (u_int32_t)low_vers;
|
|
|
|
rply.acpted_rply.ar_vers.high = (u_int32_t)high_vers;
|
1993-10-07 10:29:33 +03:00
|
|
|
SVC_REPLY(xprt, &rply);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ******************* SERVER INPUT STUFF ******************* */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get server side input from some transport.
|
|
|
|
*
|
|
|
|
* Statement of authentication parameters management:
|
|
|
|
* This function owns and manages all authentication parameters, specifically
|
|
|
|
* the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and
|
|
|
|
* the "cooked" credentials (rqst->rq_clntcred).
|
|
|
|
* However, this function does not know the structure of the cooked
|
|
|
|
* credentials, so it make the following assumptions:
|
|
|
|
* a) the structure is contiguous (no pointers), and
|
|
|
|
* b) the cred structure size does not exceed RQCRED_SIZE bytes.
|
|
|
|
* In all events, all three parameters are freed upon exit from this routine.
|
|
|
|
* The storage is trivially management on the call stack in user land, but
|
|
|
|
* is mallocated in kernel land.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_getreq(int rdfds)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
2015-11-06 22:34:13 +03:00
|
|
|
fd_set *readfds = svc_fdset_copy(NULL);
|
2015-11-07 20:34:33 +03:00
|
|
|
if (readfds == NULL)
|
|
|
|
return;
|
1993-10-07 10:29:33 +03:00
|
|
|
|
2015-11-06 22:34:13 +03:00
|
|
|
readfds->fds_bits[0] = (unsigned int)rdfds;
|
|
|
|
svc_getreqset(readfds);
|
|
|
|
free(readfds);
|
1993-10-07 10:29:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-11-06 22:34:13 +03:00
|
|
|
svc_getreqset2(fd_set *readfds, int maxsize)
|
1993-10-07 10:29:33 +03:00
|
|
|
{
|
2010-07-08 18:45:08 +04:00
|
|
|
uint32_t mask, *maskp;
|
|
|
|
int sock, bit, fd;
|
1993-10-07 10:29:33 +03:00
|
|
|
|
1999-09-16 15:44:54 +04:00
|
|
|
_DIAGASSERT(readfds != NULL);
|
1993-10-07 10:29:33 +03:00
|
|
|
|
1994-12-04 04:12:39 +03:00
|
|
|
maskp = readfds->fds_bits;
|
2015-11-06 22:34:13 +03:00
|
|
|
for (sock = 0; sock < maxsize; sock += NFDBITS) {
|
2010-07-09 00:12:37 +04:00
|
|
|
for (mask = *maskp++; (bit = ffs((int)mask)) != 0;
|
1997-07-14 00:13:02 +04:00
|
|
|
mask ^= (1 << (bit - 1))) {
|
1993-10-07 10:29:33 +03:00
|
|
|
/* sock has input waiting */
|
2000-06-03 03:11:05 +04:00
|
|
|
fd = sock + bit - 1;
|
|
|
|
svc_getreq_common(fd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 22:34:13 +03:00
|
|
|
void
|
|
|
|
svc_getreqset(fd_set *readfds)
|
|
|
|
{
|
|
|
|
svc_getreqset2(readfds, FD_SETSIZE);
|
|
|
|
}
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_getreq_common(int fd)
|
2000-06-03 03:11:05 +04:00
|
|
|
{
|
|
|
|
SVCXPRT *xprt;
|
|
|
|
struct svc_req r;
|
|
|
|
struct rpc_msg msg;
|
|
|
|
int prog_found;
|
|
|
|
rpcvers_t low_vers;
|
|
|
|
rpcvers_t high_vers;
|
|
|
|
enum xprt_stat stat;
|
|
|
|
char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE];
|
|
|
|
|
|
|
|
msg.rm_call.cb_cred.oa_base = cred_area;
|
|
|
|
msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
|
|
|
|
r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]);
|
|
|
|
|
|
|
|
rwlock_rdlock(&svc_fd_lock);
|
2002-11-08 03:13:07 +03:00
|
|
|
xprt = __svc_xports[fd];
|
2000-06-03 03:11:05 +04:00
|
|
|
rwlock_unlock(&svc_fd_lock);
|
|
|
|
if (xprt == NULL)
|
|
|
|
/* But do we control sock? */
|
|
|
|
return;
|
|
|
|
/* now receive msgs from xprtprt (support batch calls) */
|
|
|
|
do {
|
|
|
|
if (SVC_RECV(xprt, &msg)) {
|
|
|
|
|
|
|
|
/* now find the exported program and call it */
|
|
|
|
struct svc_callout *s;
|
|
|
|
enum auth_stat why;
|
|
|
|
|
|
|
|
r.rq_xprt = xprt;
|
|
|
|
r.rq_prog = msg.rm_call.cb_prog;
|
|
|
|
r.rq_vers = msg.rm_call.cb_vers;
|
|
|
|
r.rq_proc = msg.rm_call.cb_proc;
|
|
|
|
r.rq_cred = msg.rm_call.cb_cred;
|
|
|
|
/* first authenticate the message */
|
|
|
|
if ((why = _authenticate(&r, &msg)) != AUTH_OK) {
|
|
|
|
svcerr_auth(xprt, why);
|
|
|
|
goto call_done;
|
1993-10-07 10:29:33 +03:00
|
|
|
}
|
2000-06-03 03:11:05 +04:00
|
|
|
/* now match message with a registered service*/
|
|
|
|
prog_found = FALSE;
|
|
|
|
low_vers = (rpcvers_t) -1L;
|
|
|
|
high_vers = (rpcvers_t) 0L;
|
2000-07-06 07:10:34 +04:00
|
|
|
for (s = svc_head; s != NULL; s = s->sc_next) {
|
2000-06-03 03:11:05 +04:00
|
|
|
if (s->sc_prog == r.rq_prog) {
|
|
|
|
if (s->sc_vers == r.rq_vers) {
|
|
|
|
(*s->sc_dispatch)(&r, xprt);
|
|
|
|
goto call_done;
|
|
|
|
} /* found correct version */
|
|
|
|
prog_found = TRUE;
|
|
|
|
if (s->sc_vers < low_vers)
|
|
|
|
low_vers = s->sc_vers;
|
|
|
|
if (s->sc_vers > high_vers)
|
|
|
|
high_vers = s->sc_vers;
|
|
|
|
} /* found correct program */
|
1993-10-07 10:29:33 +03:00
|
|
|
}
|
2000-06-03 03:11:05 +04:00
|
|
|
/*
|
|
|
|
* if we got here, the program or version
|
|
|
|
* is not served ...
|
|
|
|
*/
|
|
|
|
if (prog_found)
|
|
|
|
svcerr_progvers(xprt, low_vers, high_vers);
|
|
|
|
else
|
|
|
|
svcerr_noprog(xprt);
|
|
|
|
/* Fall through to ... */
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Check if the xprt has been disconnected in a
|
|
|
|
* recursive call in the service dispatch routine.
|
|
|
|
* If so, then break.
|
|
|
|
*/
|
|
|
|
rwlock_rdlock(&svc_fd_lock);
|
2002-11-08 03:13:07 +03:00
|
|
|
if (xprt != __svc_xports[fd]) {
|
2000-06-03 03:11:05 +04:00
|
|
|
rwlock_unlock(&svc_fd_lock);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rwlock_unlock(&svc_fd_lock);
|
|
|
|
call_done:
|
|
|
|
if ((stat = SVC_STAT(xprt)) == XPRT_DIED){
|
|
|
|
SVC_DESTROY(xprt);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (stat == XPRT_MOREREQS);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2012-03-20 21:14:50 +04:00
|
|
|
svc_getreq_poll(struct pollfd *pfdp, int pollretval)
|
2000-06-03 03:11:05 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int fds_found;
|
|
|
|
|
2001-01-04 17:42:18 +03:00
|
|
|
_DIAGASSERT(pfdp != NULL);
|
|
|
|
|
2000-06-03 03:11:05 +04:00
|
|
|
for (i = fds_found = 0; fds_found < pollretval; i++) {
|
2000-07-06 07:10:34 +04:00
|
|
|
struct pollfd *p = &pfdp[i];
|
2000-06-03 03:11:05 +04:00
|
|
|
|
|
|
|
if (p->revents) {
|
|
|
|
/* fd has input waiting */
|
|
|
|
fds_found++;
|
|
|
|
/*
|
|
|
|
* We assume that this function is only called
|
|
|
|
* via someone select()ing from svc_fdset or
|
2005-09-09 19:41:27 +04:00
|
|
|
* pollts()ing from svc_pollset[]. Thus it's safe
|
2000-06-03 03:11:05 +04:00
|
|
|
* to handle the POLLNVAL event by simply turning
|
2015-11-07 20:34:33 +03:00
|
|
|
* the corresponding bit off in the fdset. The
|
2000-06-03 03:11:05 +04:00
|
|
|
* svc_pollset[] array is derived from svc_fdset
|
|
|
|
* and so will also be updated eventually.
|
|
|
|
*
|
|
|
|
* XXX Should we do an xprt_unregister() instead?
|
|
|
|
*/
|
|
|
|
if (p->revents & POLLNVAL) {
|
|
|
|
rwlock_wrlock(&svc_fd_lock);
|
2015-11-06 22:34:13 +03:00
|
|
|
svc_fdset_clr(p->fd);
|
2000-06-03 03:11:05 +04:00
|
|
|
rwlock_unlock(&svc_fd_lock);
|
|
|
|
} else
|
|
|
|
svc_getreq_common(p->fd);
|
|
|
|
}
|
1993-10-07 10:29:33 +03:00
|
|
|
}
|
|
|
|
}
|
2002-11-08 03:13:07 +03:00
|
|
|
|
|
|
|
bool_t
|
|
|
|
rpc_control(int what, void *arg)
|
|
|
|
{
|
|
|
|
int val;
|
|
|
|
|
|
|
|
switch (what) {
|
|
|
|
case RPC_SVC_CONNMAXREC_SET:
|
|
|
|
val = *(int *)arg;
|
|
|
|
if (val <= 0)
|
|
|
|
return FALSE;
|
|
|
|
__svc_maxrec = val;
|
|
|
|
return TRUE;
|
|
|
|
case RPC_SVC_CONNMAXREC_GET:
|
|
|
|
*(int *)arg = __svc_maxrec;
|
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|