diff options
Diffstat (limited to 'lib/libc/rpc')
87 files changed, 568 insertions, 668 deletions
diff --git a/lib/libc/rpc/DISCLAIMER b/lib/libc/rpc/DISCLAIMER index d8dcb7ffd4a6..8e0763a0e4dd 100644 --- a/lib/libc/rpc/DISCLAIMER +++ b/lib/libc/rpc/DISCLAIMER @@ -1,5 +1,4 @@ /* $NetBSD: DISCLAIMER,v 1.2 1998/01/09 04:11:51 perry Exp $ */ -/* $FreeBSD$ */ /*- * Copyright (c) 2009, Sun Microsystems, Inc. diff --git a/lib/libc/rpc/Makefile.inc b/lib/libc/rpc/Makefile.inc index 5ca9bd3757c0..87963d10eec1 100644 --- a/lib/libc/rpc/Makefile.inc +++ b/lib/libc/rpc/Makefile.inc @@ -1,6 +1,3 @@ -# @(#)Makefile 5.11 (Berkeley) 9/6/90 -# $FreeBSD$ - .PATH: ${LIBC_SRCTOP}/rpc ${LIBC_SRCTOP}/. CONFS+= rpc/netconfig rpc/rpc SRCS+= auth_none.c auth_unix.c authunix_prot.c bindresvport.c clnt_bcast.c \ @@ -11,7 +8,7 @@ SRCS+= auth_none.c auth_unix.c authunix_prot.c bindresvport.c clnt_bcast.c \ rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \ rpcb_st_xdr.c rpcsec_gss_stub.c svc.c svc_auth.c svc_dg.c \ svc_auth_unix.c svc_generic.c svc_raw.c svc_run.c svc_simple.c \ - svc_vc.c + svc_vc.c svc_nl.c # Secure-RPC SRCS+= auth_time.c auth_des.c authdes_prot.c des_crypt.c des_soft.c \ @@ -50,7 +47,7 @@ MAN+= bindresvport.3 des_crypt.3 getnetconfig.3 getnetpath.3 getrpcent.3 \ rpc_clnt_create.3 rpc_svc_calls.3 rpc_svc_create.3 rpc_svc_err.3 \ rpc_svc_reg.3 rpc_xdr.3 rpcbind.3 publickey.3 rpc_secure.3 \ rtime.3 -MAN+= publickey.5 rpc.5 netconfig.5 +MAN+= rpc.5 netconfig.5 MLINKS+= bindresvport.3 bindresvport_sa.3 \ des_crypt.3 ecb_crypt.3 \ des_crypt.3 cbc_crypt.3 \ @@ -168,6 +165,7 @@ MLINKS+= bindresvport.3 bindresvport_sa.3 \ rpc_soc.3 svc_fds.3 \ rpc_soc.3 svc_fdset.3 \ rpc_soc.3 svc_getcaller.3 \ + rpc_soc.3 svc_getreq.3 \ rpc_soc.3 svc_register.3 \ rpc_soc.3 svc_unregister.3 \ rpc_soc.3 svcfd_create.3 \ @@ -176,5 +174,6 @@ MLINKS+= bindresvport.3 bindresvport_sa.3 \ rpc_soc.3 svctcp_create.3 \ rpc_soc.3 svcudp_bufcreate.3 \ rpc_soc.3 svcunix_create.3 \ + rpc_soc.3 xdr_authunix_parms.3 \ rpc_soc.3 xdr_pmap.3 \ rpc_soc.3 xdr_pmaplist.3 diff --git a/lib/libc/rpc/README b/lib/libc/rpc/README index 129fe0082d6d..60e9f2649bba 100644 --- a/lib/libc/rpc/README +++ b/lib/libc/rpc/README @@ -1,4 +1,3 @@ -$FreeBSD$ PLEASE READ THE DISCLAIMER FILE. DO NOT CALL THE SUN MICROSYSTEMS SUPPORT LINE WITH QUESTIONS ON THIS RELEASE. THEY CANNOT ANSWER QUESTIONS ABOUT THIS diff --git a/lib/libc/rpc/Symbol.map b/lib/libc/rpc/Symbol.map index 4f356de99748..105d6fb6b54e 100644 --- a/lib/libc/rpc/Symbol.map +++ b/lib/libc/rpc/Symbol.map @@ -1,7 +1,3 @@ -/* - * $FreeBSD$ - */ - FBSD_1.0 { /* From crypt_clnt.c (generated by rpcgen - include/rpcsvc/crypt.x) */ des_crypt_1; @@ -12,37 +8,6 @@ FBSD_1.0 { xdr_desargs; xdr_desresp; - /* From yp_xdr.c (generated by rpcgen - include/rpcsvc/yp.x) */ - xdr_domainname; - xdr_keydat; - xdr_mapname; - xdr_peername; - xdr_valdat; - xdr_ypbind_binding; - xdr_ypbind_resp; - xdr_ypbind_resptype; - xdr_ypbind_setdom; - xdr_ypmap_parms; - xdr_ypmaplist; - xdr_yppush_status; - xdr_yppushresp_xfr; - xdr_ypreq_key; - xdr_ypreq_nokey; - xdr_ypreq_xfr; - xdr_ypreqtype; - xdr_yprequest; - xdr_ypresp_all; - xdr_ypresp_key_val; - xdr_ypresp_maplist; - xdr_ypresp_master; - xdr_ypresp_order; - xdr_ypresp_val; - xdr_ypresp_xfr; - xdr_ypresponse; - xdr_ypresptype; - xdr_ypstat; - xdr_ypxfrstat; - authdes_seccreate; authdes_pk_seccreate; authnone_create; @@ -234,6 +199,10 @@ FBSD_1.0 { __rpc_get_local_uid; }; +FBSD_1.8 { + svc_nl_create; +}; + FBSDprivate_1.0 { __des_crypt_LOCAL; __key_encryptsession_pk_LOCAL; diff --git a/lib/libc/rpc/auth_des.c b/lib/libc/rpc/auth_des.c index f2ad0349a6a8..c9b20de25cda 100644 --- a/lib/libc/rpc/auth_des.c +++ b/lib/libc/rpc/auth_des.c @@ -41,7 +41,6 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> -#include <sys/cdefs.h> #include <rpc/des_crypt.h> #include <syslog.h> #include <rpc/types.h> @@ -55,12 +54,6 @@ #include "un-namespace.h" #include "mt_misc.h" -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)auth_des.c 2.2 88/07/29 4.0 RPCSRC; from 1.9 88/02/08 SMI"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define USEC_PER_SEC 1000000 #define RTIME_TIMEOUT 5 /* seconds to wait for sync */ diff --git a/lib/libc/rpc/auth_none.c b/lib/libc/rpc/auth_none.c index 4422802c4c5c..c116ce242707 100644 --- a/lib/libc/rpc/auth_none.c +++ b/lib/libc/rpc/auth_none.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * auth_none.c * Creates a client authentication handle for passing "null" diff --git a/lib/libc/rpc/auth_time.c b/lib/libc/rpc/auth_time.c index 4b714468b92e..d8ea585c8ee7 100644 --- a/lib/libc/rpc/auth_time.c +++ b/lib/libc/rpc/auth_time.c @@ -1,5 +1,3 @@ -/* #pragma ident "@(#)auth_time.c 1.4 92/11/10 SMI" */ - /* * auth_time.c * @@ -27,9 +25,6 @@ * needed to deal with TCP connections. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <stdio.h> #include <syslog.h> diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index 08df14b54491..22c65ddfb8f0 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * auth_unix.c, Implements UNIX style authentication parameters. * diff --git a/lib/libc/rpc/authdes_prot.c b/lib/libc/rpc/authdes_prot.c index 663261d631a9..79a0e5baa084 100644 --- a/lib/libc/rpc/authdes_prot.c +++ b/lib/libc/rpc/authdes_prot.c @@ -1,9 +1,3 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)authdes_prot.c 2.1 88/07/29 4.0 RPCSRC; from 1.6 88/02/08 SMI"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /*- * SPDX-License-Identifier: BSD-3-Clause * diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c index bb590c350429..777f262f5c33 100644 --- a/lib/libc/rpc/authunix_prot.c +++ b/lib/libc/rpc/authunix_prot.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * authunix_prot.c * XDR for UNIX style authentication parameters for RPC diff --git a/lib/libc/rpc/bindresvport.3 b/lib/libc/rpc/bindresvport.3 index 28e86e5f2a6f..25483a623e56 100644 --- a/lib/libc/rpc/bindresvport.3 +++ b/lib/libc/rpc/bindresvport.3 @@ -1,6 +1,4 @@ -.\" @(#)bindresvport.3n 2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI .\" $NetBSD: bindresvport.3,v 1.8 2000/07/05 15:45:33 msaitoh Exp $ -.\" $FreeBSD$ .\" .Dd November 22, 1987 .Dt BINDRESVPORT 3 diff --git a/lib/libc/rpc/bindresvport.c b/lib/libc/rpc/bindresvport.c index 44d3b0c1eacd..4cdd037afd1a 100644 --- a/lib/libc/rpc/bindresvport.c +++ b/lib/libc/rpc/bindresvport.c @@ -30,14 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "from: @(#)bindresvport.c 1.8 88/02/08 SMI"; -static char *sccsid = "from: @(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC"; -#endif /* from: $OpenBSD: bindresvport.c,v 1.7 1996/07/30 16:25:47 downsj Exp $ */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Copyright (c) 1987 by Sun Microsystems, Inc. * diff --git a/lib/libc/rpc/clnt_bcast.c b/lib/libc/rpc/clnt_bcast.c index 649cab05a474..07e6d0a0fa20 100644 --- a/lib/libc/rpc/clnt_bcast.c +++ b/lib/libc/rpc/clnt_bcast.c @@ -33,14 +33,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -#if defined(LIBC_SCCS) && !defined(lint) -#ident "@(#)clnt_bcast.c 1.18 94/05/03 SMI" -static char sccsid[] = "@(#)clnt_bcast.c 1.15 89/04/21 Copyr 1988 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - - /* * clnt_bcast.c * Client interface to broadcast service. diff --git a/lib/libc/rpc/clnt_dg.c b/lib/libc/rpc/clnt_dg.c index 26bf34633623..78fc5e47d444 100644 --- a/lib/libc/rpc/clnt_dg.c +++ b/lib/libc/rpc/clnt_dg.c @@ -33,13 +33,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -#if defined(LIBC_SCCS) && !defined(lint) -#ident "@(#)clnt_dg.c 1.23 94/04/22 SMI" -static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Implements a connectionless client side RPC. */ @@ -51,13 +44,17 @@ __FBSDID("$FreeBSD$"); #include <sys/time.h> #include <sys/socket.h> #include <sys/ioctl.h> +#include <sys/tree.h> #include <arpa/inet.h> #include <rpc/rpc.h> #include <rpc/rpcsec_gss.h> +#include <assert.h> #include <errno.h> +#include <pthread.h> #include <stdlib.h> #include <string.h> #include <signal.h> +#include <stdbool.h> #include <unistd.h> #include <err.h> #include "un-namespace.h" @@ -92,28 +89,65 @@ static void clnt_dg_destroy(CLIENT *); * This machinery implements per-fd locks for MT-safety. It is not * sufficient to do per-CLIENT handle locks for MT-safety because a * user may create more than one CLIENT handle with the same fd behind - * it. Therefore, we allocate an array of flags (dg_fd_locks), protected - * by the clnt_fd_lock mutex, and an array (dg_cv) of condition variables - * similarly protected. Dg_fd_lock[fd] == 1 => a call is active on some - * CLIENT handle created for that fd. - * The current implementation holds locks across the entire RPC and reply, - * including retransmissions. Yes, this is silly, and as soon as this - * code is proven to work, this should be the first thing fixed. One step - * at a time. + * it. Therefore, we allocate an associative array of flags and condition + * variables (dg_fd). The flags and the array are protected by the + * clnt_fd_lock mutex. dg_fd[fd].lock == 1 => a call is active on some + * CLIENT handle created for that fd. The current implementation holds + * locks across the entire RPC and reply, including retransmissions. Yes, + * this is silly, and as soon as this code is proven to work, this should + * be the first thing fixed. One step at a time. */ -static int *dg_fd_locks; -static cond_t *dg_cv; -#define release_fd_lock(fd, mask) { \ - mutex_lock(&clnt_fd_lock); \ - dg_fd_locks[fd] = 0; \ - mutex_unlock(&clnt_fd_lock); \ - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); \ - cond_signal(&dg_cv[fd]); \ +struct dg_fd { + RB_ENTRY(dg_fd) dg_link; + int fd; + mutex_t mtx; +}; +static inline int +cmp_dg_fd(struct dg_fd *a, struct dg_fd *b) +{ + if (a->fd > b->fd) { + return (1); + } else if (a->fd < b->fd) { + return (-1); + } else { + return (0); + } +} +RB_HEAD(dg_fd_list, dg_fd); +RB_PROTOTYPE(dg_fd_list, dg_fd, dg_link, cmp_dg_fd); +RB_GENERATE(dg_fd_list, dg_fd, dg_link, cmp_dg_fd); +struct dg_fd_list dg_fd_head = RB_INITIALIZER(&dg_fd_head); + +/* + * Find the lock structure for the given file descriptor, or initialize it if + * it does not already exist. The clnt_fd_lock mutex must be held. + */ +static struct dg_fd * +dg_fd_find(int fd) +{ + struct dg_fd key, *elem; + + key.fd = fd; + elem = RB_FIND(dg_fd_list, &dg_fd_head, &key); + if (elem == NULL) { + elem = calloc(1, sizeof(*elem)); + elem->fd = fd; + mutex_init(&elem->mtx, NULL); + RB_INSERT(dg_fd_list, &dg_fd_head, elem); + } + return (elem); +} + +static void +release_fd_lock(struct dg_fd *elem, sigset_t mask) +{ + mutex_unlock(&elem->mtx); + thr_sigsetmask(SIG_SETMASK, &mask, NULL); } static const char mem_err_clnt_dg[] = "clnt_dg_create: out of memory"; -/* VARIABLES PROTECTED BY clnt_fd_lock: dg_fd_locks, dg_cv */ +/* VARIABLES PROTECTED BY clnt_fd_lock: dg_fd */ #define MCALL_MSG_SIZE 24 @@ -171,47 +205,9 @@ clnt_dg_create(int fd, const struct netbuf *svcaddr, rpcprog_t program, struct cu_data *cu = NULL; /* private data */ struct timeval now; struct rpc_msg call_msg; - sigset_t mask; - sigset_t newmask; struct __rpc_sockinfo si; int one = 1; - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - if (dg_fd_locks == (int *) NULL) { - int cv_allocsz; - size_t fd_allocsz; - int dtbsize = __rpc_dtbsize(); - - fd_allocsz = dtbsize * sizeof (int); - dg_fd_locks = (int *) mem_alloc(fd_allocsz); - if (dg_fd_locks == (int *) NULL) { - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - goto err1; - } else - memset(dg_fd_locks, '\0', fd_allocsz); - - cv_allocsz = dtbsize * sizeof (cond_t); - dg_cv = (cond_t *) mem_alloc(cv_allocsz); - if (dg_cv == (cond_t *) NULL) { - mem_free(dg_fd_locks, fd_allocsz); - dg_fd_locks = (int *) NULL; - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - goto err1; - } else { - int i; - - for (i = 0; i < dtbsize; i++) - cond_init(&dg_cv[i], 0, (void *) 0); - } - } - - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - if (svcaddr == NULL) { rpc_createerr.cf_stat = RPC_UNKNOWNADDR; return (NULL); @@ -332,25 +328,21 @@ clnt_dg_call(CLIENT *cl, rpcproc_t proc, xdrproc_t xargs, void *argsp, struct timespec ts; struct kevent kv; struct sockaddr *sa; + struct dg_fd *elem; sigset_t mask; sigset_t newmask; socklen_t salen; ssize_t recvlen = 0; - int kin_len, n, rpc_lock_value; + int kin_len, n; u_int32_t xid; outlen = 0; sigfillset(&newmask); thr_sigsetmask(SIG_SETMASK, &newmask, &mask); mutex_lock(&clnt_fd_lock); - while (dg_fd_locks[cu->cu_fd]) - cond_wait(&dg_cv[cu->cu_fd], &clnt_fd_lock); - if (__isthreaded) - rpc_lock_value = 1; - else - rpc_lock_value = 0; - dg_fd_locks[cu->cu_fd] = rpc_lock_value; + elem = dg_fd_find(cu->cu_fd); mutex_unlock(&clnt_fd_lock); + mutex_lock(&elem->mtx); if (cu->cu_total.tv_usec == -1) { timeout = utimeout; /* use supplied timeout */ } else { @@ -604,7 +596,7 @@ out: if (cu->cu_kq >= 0) _close(cu->cu_kq); cu->cu_kq = -1; - release_fd_lock(cu->cu_fd, mask); + release_fd_lock(elem, mask); return (cu->cu_error.re_status); } @@ -620,6 +612,7 @@ static bool_t clnt_dg_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr) { struct cu_data *cu = (struct cu_data *)cl->cl_private; + struct dg_fd *elem; XDR *xdrs = &(cu->cu_outxdrs); bool_t dummy; sigset_t mask; @@ -628,13 +621,12 @@ clnt_dg_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr) sigfillset(&newmask); thr_sigsetmask(SIG_SETMASK, &newmask, &mask); mutex_lock(&clnt_fd_lock); - while (dg_fd_locks[cu->cu_fd]) - cond_wait(&dg_cv[cu->cu_fd], &clnt_fd_lock); + elem = dg_fd_find(cu->cu_fd); + mutex_lock(&elem->mtx); xdrs->x_op = XDR_FREE; dummy = (*xdr_res)(xdrs, res_ptr); mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &mask, NULL); - cond_signal(&dg_cv[cu->cu_fd]); + release_fd_lock(elem, mask); return (dummy); } @@ -649,41 +641,36 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info) { struct cu_data *cu = (struct cu_data *)cl->cl_private; struct netbuf *addr; + struct dg_fd *elem; sigset_t mask; sigset_t newmask; - int rpc_lock_value; sigfillset(&newmask); thr_sigsetmask(SIG_SETMASK, &newmask, &mask); mutex_lock(&clnt_fd_lock); - while (dg_fd_locks[cu->cu_fd]) - cond_wait(&dg_cv[cu->cu_fd], &clnt_fd_lock); - if (__isthreaded) - rpc_lock_value = 1; - else - rpc_lock_value = 0; - dg_fd_locks[cu->cu_fd] = rpc_lock_value; + elem = dg_fd_find(cu->cu_fd); mutex_unlock(&clnt_fd_lock); + mutex_lock(&elem->mtx); switch (request) { case CLSET_FD_CLOSE: cu->cu_closeit = TRUE; - release_fd_lock(cu->cu_fd, mask); + release_fd_lock(elem, mask); return (TRUE); case CLSET_FD_NCLOSE: cu->cu_closeit = FALSE; - release_fd_lock(cu->cu_fd, mask); + release_fd_lock(elem, mask); return (TRUE); } /* for other requests which use info */ if (info == NULL) { - release_fd_lock(cu->cu_fd, mask); + release_fd_lock(elem, mask); return (FALSE); } switch (request) { case CLSET_TIMEOUT: if (time_not_ok((struct timeval *)info)) { - release_fd_lock(cu->cu_fd, mask); + release_fd_lock(elem, mask); return (FALSE); } cu->cu_total = *(struct timeval *)info; @@ -697,7 +684,7 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info) break; case CLSET_RETRY_TIMEOUT: if (time_not_ok((struct timeval *)info)) { - release_fd_lock(cu->cu_fd, mask); + release_fd_lock(elem, mask); return (FALSE); } cu->cu_wait = *(struct timeval *)info; @@ -717,7 +704,7 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info) case CLSET_SVC_ADDR: /* set to new address */ addr = (struct netbuf *)info; if (addr->len < sizeof cu->cu_raddr) { - release_fd_lock(cu->cu_fd, mask); + release_fd_lock(elem, mask); return (FALSE); } (void) memcpy(&cu->cu_raddr, addr->buf, addr->len); @@ -780,10 +767,10 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info) cu->cu_connect = *(int *)info; break; default: - release_fd_lock(cu->cu_fd, mask); + release_fd_lock(elem, mask); return (FALSE); } - release_fd_lock(cu->cu_fd, mask); + release_fd_lock(elem, mask); return (TRUE); } @@ -791,6 +778,7 @@ static void clnt_dg_destroy(CLIENT *cl) { struct cu_data *cu = (struct cu_data *)cl->cl_private; + struct dg_fd *elem; int cu_fd = cu->cu_fd; sigset_t mask; sigset_t newmask; @@ -798,8 +786,8 @@ clnt_dg_destroy(CLIENT *cl) sigfillset(&newmask); thr_sigsetmask(SIG_SETMASK, &newmask, &mask); mutex_lock(&clnt_fd_lock); - while (dg_fd_locks[cu_fd]) - cond_wait(&dg_cv[cu_fd], &clnt_fd_lock); + elem = dg_fd_find(cu_fd); + mutex_lock(&elem->mtx); if (cu->cu_closeit) (void)_close(cu_fd); if (cu->cu_kq >= 0) @@ -812,8 +800,7 @@ clnt_dg_destroy(CLIENT *cl) mem_free(cl->cl_tp, strlen(cl->cl_tp) +1); mem_free(cl, sizeof (CLIENT)); mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &mask, NULL); - cond_signal(&dg_cv[cu_fd]); + release_fd_lock(elem, mask); } static struct clnt_ops * diff --git a/lib/libc/rpc/clnt_generic.c b/lib/libc/rpc/clnt_generic.c index d3cdf1f08fb8..f55fb9d44c9f 100644 --- a/lib/libc/rpc/clnt_generic.c +++ b/lib/libc/rpc/clnt_generic.c @@ -30,15 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* #ident "@(#)clnt_generic.c 1.40 99/04/21 SMI" */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "from: @(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI"; -static char *sccsid = "from: @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Copyright (c) 1986-1996,1998 by Sun Microsystems, Inc. * All rights reserved. diff --git a/lib/libc/rpc/clnt_perror.c b/lib/libc/rpc/clnt_perror.c index b9243ff4d558..83ed2f600452 100644 --- a/lib/libc/rpc/clnt_perror.c +++ b/lib/libc/rpc/clnt_perror.c @@ -31,13 +31,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * clnt_perror.c * diff --git a/lib/libc/rpc/clnt_raw.c b/lib/libc/rpc/clnt_raw.c index f6a488be7e8d..b355f827140b 100644 --- a/lib/libc/rpc/clnt_raw.c +++ b/lib/libc/rpc/clnt_raw.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * clnt_raw.c * diff --git a/lib/libc/rpc/clnt_simple.c b/lib/libc/rpc/clnt_simple.c index de9ec6543d15..0df3fd8dee09 100644 --- a/lib/libc/rpc/clnt_simple.c +++ b/lib/libc/rpc/clnt_simple.c @@ -33,13 +33,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "from: @(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "from: @(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * clnt_simple.c * Simplified front end to client rpc. diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c index ebd4e303916f..60e381168ed3 100644 --- a/lib/libc/rpc/clnt_vc.c +++ b/lib/libc/rpc/clnt_vc.c @@ -30,14 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC"; -static char sccsid3[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * clnt_tcp.c, Implements a TCP/IP based, client side RPC. * @@ -63,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include <sys/poll.h> #include <sys/syslog.h> #include <sys/socket.h> +#include <sys/tree.h> #include <sys/un.h> #include <sys/uio.h> @@ -71,7 +64,9 @@ __FBSDID("$FreeBSD$"); #include <err.h> #include <errno.h> #include <netdb.h> +#include <pthread.h> #include <stdio.h> +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -123,22 +118,60 @@ struct ct_data { * This machinery implements per-fd locks for MT-safety. It is not * sufficient to do per-CLIENT handle locks for MT-safety because a * user may create more than one CLIENT handle with the same fd behind - * it. Therefore, we allocate an array of flags (vc_fd_locks), protected - * by the clnt_fd_lock mutex, and an array (vc_cv) of condition variables - * similarly protected. Vc_fd_lock[fd] == 1 => a call is active on some - * CLIENT handle created for that fd. - * The current implementation holds locks across the entire RPC and reply. - * Yes, this is silly, and as soon as this code is proven to work, this - * should be the first thing fixed. One step at a time. + * it. Therefore, we allocate an associative array of flags and condition + * variables (vc_fd). The flags and the array are protected by the + * clnt_fd_lock mutex. vc_fd_lock[fd] == 1 => a call is active on some + * CLIENT handle created for that fd. The current implementation holds + * locks across the entire RPC and reply. Yes, this is silly, and as soon + * as this code is proven to work, this should be the first thing fixed. + * One step at a time. + */ +struct vc_fd { + RB_ENTRY(vc_fd) vc_link; + int fd; + mutex_t mtx; +}; +static inline int +cmp_vc_fd(struct vc_fd *a, struct vc_fd *b) +{ + if (a->fd > b->fd) { + return (1); + } else if (a->fd < b->fd) { + return (-1); + } else { + return (0); + } +} +RB_HEAD(vc_fd_list, vc_fd); +RB_PROTOTYPE(vc_fd_list, vc_fd, vc_link, cmp_vc_fd); +RB_GENERATE(vc_fd_list, vc_fd, vc_link, cmp_vc_fd); +struct vc_fd_list vc_fd_head = RB_INITIALIZER(&vc_fd_head); + +/* + * Find the lock structure for the given file descriptor, or initialize it if + * it does not already exist. The clnt_fd_lock mutex must be held. */ -static int *vc_fd_locks; -static cond_t *vc_cv; -#define release_fd_lock(fd, mask) { \ - mutex_lock(&clnt_fd_lock); \ - vc_fd_locks[fd] = 0; \ - mutex_unlock(&clnt_fd_lock); \ - thr_sigsetmask(SIG_SETMASK, &(mask), (sigset_t *) NULL); \ - cond_signal(&vc_cv[fd]); \ +static struct vc_fd * +vc_fd_find(int fd) +{ + struct vc_fd key, *elem; + + key.fd = fd; + elem = RB_FIND(vc_fd_list, &vc_fd_head, &key); + if (elem == NULL) { + elem = calloc(1, sizeof(*elem)); + elem->fd = fd; + mutex_init(&elem->mtx, NULL); + RB_INSERT(vc_fd_list, &vc_fd_head, elem); + } + return (elem); +} + +static void +release_fd_lock(struct vc_fd *elem, sigset_t mask) +{ + mutex_unlock(&elem->mtx); + thr_sigsetmask(SIG_SETMASK, &mask, NULL); } static const char clnt_vc_errstr[] = "%s : %s"; @@ -172,8 +205,6 @@ clnt_vc_create(int fd, const struct netbuf *raddr, const rpcprog_t prog, struct timeval now; struct rpc_msg call_msg; static u_int32_t disrupt; - sigset_t mask; - sigset_t newmask; struct sockaddr_storage ss; socklen_t slen; struct __rpc_sockinfo si; @@ -191,39 +222,6 @@ clnt_vc_create(int fd, const struct netbuf *raddr, const rpcprog_t prog, goto err; } ct->ct_addr.buf = NULL; - sigfillset(&newmask); - thr_sigsetmask(SIG_SETMASK, &newmask, &mask); - mutex_lock(&clnt_fd_lock); - if (vc_fd_locks == (int *) NULL) { - int cv_allocsz, fd_allocsz; - int dtbsize = __rpc_dtbsize(); - - fd_allocsz = dtbsize * sizeof (int); - vc_fd_locks = (int *) mem_alloc(fd_allocsz); - if (vc_fd_locks == (int *) NULL) { - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - goto err; - } else - memset(vc_fd_locks, '\0', fd_allocsz); - - assert(vc_cv == (cond_t *) NULL); - cv_allocsz = dtbsize * sizeof (cond_t); - vc_cv = (cond_t *) mem_alloc(cv_allocsz); - if (vc_cv == (cond_t *) NULL) { - mem_free(vc_fd_locks, fd_allocsz); - vc_fd_locks = (int *) NULL; - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - goto err; - } else { - int i; - - for (i = 0; i < dtbsize; i++) - cond_init(&vc_cv[i], 0, (void *) 0); - } - } else - assert(vc_cv != (cond_t *) NULL); /* * XXX - fvdl connecting while holding a mutex? @@ -234,19 +232,16 @@ clnt_vc_create(int fd, const struct netbuf *raddr, const rpcprog_t prog, rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); goto err; } if (_connect(fd, (struct sockaddr *)raddr->buf, raddr->len) < 0){ rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); goto err; } } mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); if (!__rpc_fd2sockinfo(fd, &si)) goto err; @@ -321,12 +316,12 @@ clnt_vc_call(CLIENT *cl, rpcproc_t proc, xdrproc_t xdr_args, void *args_ptr, struct ct_data *ct = (struct ct_data *) cl->cl_private; XDR *xdrs = &(ct->ct_xdrs); struct rpc_msg reply_msg; + struct vc_fd *elem; u_int32_t x_id; u_int32_t *msg_x_id = &ct->ct_u.ct_mcalli; /* yuk */ bool_t shipnow; int refreshes = 2; sigset_t mask, newmask; - int rpc_lock_value; bool_t reply_stat; assert(cl != NULL); @@ -334,14 +329,9 @@ clnt_vc_call(CLIENT *cl, rpcproc_t proc, xdrproc_t xdr_args, void *args_ptr, sigfillset(&newmask); thr_sigsetmask(SIG_SETMASK, &newmask, &mask); mutex_lock(&clnt_fd_lock); - while (vc_fd_locks[ct->ct_fd]) - cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock); - if (__isthreaded) - rpc_lock_value = 1; - else - rpc_lock_value = 0; - vc_fd_locks[ct->ct_fd] = rpc_lock_value; + elem = vc_fd_find(ct->ct_fd); mutex_unlock(&clnt_fd_lock); + mutex_lock(&elem->mtx); if (!ct->ct_waitset) { /* If time is not within limits, we ignore it. */ if (time_not_ok(&timeout) == FALSE) @@ -365,7 +355,7 @@ call_again: if (ct->ct_error.re_status == RPC_SUCCESS) ct->ct_error.re_status = RPC_CANTENCODEARGS; (void)xdrrec_endofrecord(xdrs, TRUE); - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (ct->ct_error.re_status); } } else { @@ -376,23 +366,23 @@ call_again: if (ct->ct_error.re_status == RPC_SUCCESS) ct->ct_error.re_status = RPC_CANTENCODEARGS; (void)xdrrec_endofrecord(xdrs, TRUE); - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (ct->ct_error.re_status); } } if (! xdrrec_endofrecord(xdrs, shipnow)) { - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (ct->ct_error.re_status = RPC_CANTSEND); } if (! shipnow) { - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (RPC_SUCCESS); } /* * Hack to provide rpc-based message passing */ if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return(ct->ct_error.re_status = RPC_TIMEDOUT); } @@ -406,14 +396,14 @@ call_again: reply_msg.acpted_rply.ar_results.where = NULL; reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void; if (! xdrrec_skiprecord(xdrs)) { - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (ct->ct_error.re_status); } /* now decode and validate the response header */ if (! xdr_replymsg(xdrs, &reply_msg)) { if (ct->ct_error.re_status == RPC_SUCCESS) continue; - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (ct->ct_error.re_status); } if (reply_msg.rm_xid == x_id) @@ -454,7 +444,7 @@ call_again: if (refreshes-- && AUTH_REFRESH(cl->cl_auth, &reply_msg)) goto call_again; } /* end of unsuccessful completion */ - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (ct->ct_error.re_status); } @@ -474,6 +464,7 @@ static bool_t clnt_vc_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr) { struct ct_data *ct; + struct vc_fd *elem; XDR *xdrs; bool_t dummy; sigset_t mask; @@ -487,14 +478,13 @@ clnt_vc_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr) sigfillset(&newmask); thr_sigsetmask(SIG_SETMASK, &newmask, &mask); mutex_lock(&clnt_fd_lock); - while (vc_fd_locks[ct->ct_fd]) - cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock); + elem = vc_fd_find(ct->ct_fd); + mutex_lock(&elem->mtx); xdrs->x_op = XDR_FREE; dummy = (*xdr_res)(xdrs, res_ptr); - mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - cond_signal(&vc_cv[ct->ct_fd]); + mutex_unlock(&clnt_fd_lock); + release_fd_lock(elem, mask); return dummy; } @@ -522,10 +512,10 @@ static bool_t clnt_vc_control(CLIENT *cl, u_int request, void *info) { struct ct_data *ct; + struct vc_fd *elem; void *infop = info; sigset_t mask; sigset_t newmask; - int rpc_lock_value; assert(cl != NULL); @@ -534,23 +524,18 @@ clnt_vc_control(CLIENT *cl, u_int request, void *info) sigfillset(&newmask); thr_sigsetmask(SIG_SETMASK, &newmask, &mask); mutex_lock(&clnt_fd_lock); - while (vc_fd_locks[ct->ct_fd]) - cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock); - if (__isthreaded) - rpc_lock_value = 1; - else - rpc_lock_value = 0; - vc_fd_locks[ct->ct_fd] = rpc_lock_value; + elem = vc_fd_find(ct->ct_fd); mutex_unlock(&clnt_fd_lock); + mutex_lock(&elem->mtx); switch (request) { case CLSET_FD_CLOSE: ct->ct_closeit = TRUE; - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (TRUE); case CLSET_FD_NCLOSE: ct->ct_closeit = FALSE; - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (TRUE); default: break; @@ -558,13 +543,13 @@ clnt_vc_control(CLIENT *cl, u_int request, void *info) /* for other requests which use info */ if (info == NULL) { - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (FALSE); } switch (request) { case CLSET_TIMEOUT: if (time_not_ok((struct timeval *)info)) { - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (FALSE); } ct->ct_wait = *(struct timeval *)infop; @@ -584,7 +569,7 @@ clnt_vc_control(CLIENT *cl, u_int request, void *info) *(struct netbuf *)info = ct->ct_addr; break; case CLSET_SVC_ADDR: /* set to new address */ - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (FALSE); case CLGET_XID: /* @@ -628,10 +613,10 @@ clnt_vc_control(CLIENT *cl, u_int request, void *info) break; default: - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (FALSE); } - release_fd_lock(ct->ct_fd, mask); + release_fd_lock(elem, mask); return (TRUE); } @@ -640,6 +625,7 @@ static void clnt_vc_destroy(CLIENT *cl) { struct ct_data *ct = (struct ct_data *) cl->cl_private; + struct vc_fd *elem; int ct_fd = ct->ct_fd; sigset_t mask; sigset_t newmask; @@ -651,8 +637,8 @@ clnt_vc_destroy(CLIENT *cl) sigfillset(&newmask); thr_sigsetmask(SIG_SETMASK, &newmask, &mask); mutex_lock(&clnt_fd_lock); - while (vc_fd_locks[ct_fd]) - cond_wait(&vc_cv[ct_fd], &clnt_fd_lock); + elem = vc_fd_find(ct_fd); + mutex_lock(&elem->mtx); if (ct->ct_closeit && ct->ct_fd != -1) { (void)_close(ct->ct_fd); } @@ -665,8 +651,7 @@ clnt_vc_destroy(CLIENT *cl) mem_free(cl->cl_tp, strlen(cl->cl_tp) +1); mem_free(cl, sizeof(CLIENT)); mutex_unlock(&clnt_fd_lock); - thr_sigsetmask(SIG_SETMASK, &(mask), NULL); - cond_signal(&vc_cv[ct_fd]); + release_fd_lock(elem, mask); } /* diff --git a/lib/libc/rpc/crypt_client.c b/lib/libc/rpc/crypt_client.c index c2ed109e10bb..4173a14811f9 100644 --- a/lib/libc/rpc/crypt_client.c +++ b/lib/libc/rpc/crypt_client.c @@ -32,9 +32,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <err.h> #include <sys/types.h> diff --git a/lib/libc/rpc/des_crypt.3 b/lib/libc/rpc/des_crypt.3 index 1ae637ceded5..063e4bf247f0 100644 --- a/lib/libc/rpc/des_crypt.3 +++ b/lib/libc/rpc/des_crypt.3 @@ -1,5 +1,3 @@ -.\" @(#)des_crypt.3 2.1 88/08/11 4.0 RPCSRC; from 1.16 88/03/02 SMI; -.\" $FreeBSD$ .\" .Dd October 6, 1987 .Dt DES_CRYPT 3 diff --git a/lib/libc/rpc/des_crypt.c b/lib/libc/rpc/des_crypt.c index 589ff7b3b88b..beaa11c5fc15 100644 --- a/lib/libc/rpc/des_crypt.c +++ b/lib/libc/rpc/des_crypt.c @@ -36,12 +36,6 @@ #include <rpc/des_crypt.h> #include <rpc/des.h> -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)des_crypt.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - static int common_crypt( char *, char *, unsigned, unsigned, struct desparams * ); int (*__des_crypt_LOCAL)(char *, unsigned, struct desparams *) = 0; extern int _des_crypt_call(char *, int, struct desparams *); diff --git a/lib/libc/rpc/des_soft.c b/lib/libc/rpc/des_soft.c index 4992c1650b46..426b0a1bc116 100644 --- a/lib/libc/rpc/des_soft.c +++ b/lib/libc/rpc/des_soft.c @@ -28,12 +28,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)des_soft.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Table giving odd parity in the low bit for ASCII characters */ diff --git a/lib/libc/rpc/getnetconfig.3 b/lib/libc/rpc/getnetconfig.3 index e67b9bbb75c9..a3b7fd37174f 100644 --- a/lib/libc/rpc/getnetconfig.3 +++ b/lib/libc/rpc/getnetconfig.3 @@ -1,6 +1,4 @@ -.\" @(#)getnetconfig.3n 1.28 93/06/02 SMI; from SVr4 .\" $NetBSD: getnetconfig.3,v 1.1 2000/06/02 23:11:11 fvdl Exp $ -.\" $FreeBSD$ .\" Copyright 1989 AT&T .Dd April 22, 2000 .Dt GETNETCONFIG 3 diff --git a/lib/libc/rpc/getnetconfig.c b/lib/libc/rpc/getnetconfig.c index abd5eadf3917..03a4497b21ec 100644 --- a/lib/libc/rpc/getnetconfig.c +++ b/lib/libc/rpc/getnetconfig.c @@ -30,12 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetconfig.c 1.12 91/12/19 SMI"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Copyright (c) 1989 by Sun Microsystems, Inc. */ diff --git a/lib/libc/rpc/getnetpath.3 b/lib/libc/rpc/getnetpath.3 index 5dfe68ad6ec9..79185c5f50b9 100644 --- a/lib/libc/rpc/getnetpath.3 +++ b/lib/libc/rpc/getnetpath.3 @@ -1,6 +1,4 @@ -.\" @(#)getnetpath.3n 1.26 93/05/07 SMI; from SVr4 .\" $NetBSD: getnetpath.3,v 1.1 2000/06/02 23:11:11 fvdl Exp $ -.\" $FreeBSD$ .\" Copyright 1989 AT&T .Dd April 22, 2000 .Dt GETNETPATH 3 diff --git a/lib/libc/rpc/getnetpath.c b/lib/libc/rpc/getnetpath.c index 37e30ad019aa..06098af87dc1 100644 --- a/lib/libc/rpc/getnetpath.c +++ b/lib/libc/rpc/getnetpath.c @@ -30,12 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetpath.c 1.11 91/12/19 SMI"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Copyright (c) 1989 by Sun Microsystems, Inc. */ diff --git a/lib/libc/rpc/getpublickey.c b/lib/libc/rpc/getpublickey.c index a0604836d973..2afd5b8c2a8a 100644 --- a/lib/libc/rpc/getpublickey.c +++ b/lib/libc/rpc/getpublickey.c @@ -28,12 +28,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)publickey.c 1.10 91/03/11 Copyr 1986 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * publickey.c * Copyright (C) 1986, Sun Microsystems, Inc. diff --git a/lib/libc/rpc/getrpcent.3 b/lib/libc/rpc/getrpcent.3 index e36d31c4a7ba..b2a4f71375a6 100644 --- a/lib/libc/rpc/getrpcent.3 +++ b/lib/libc/rpc/getrpcent.3 @@ -1,6 +1,4 @@ -.\" @(#)getrpcent.3n 2.2 88/08/02 4.0 RPCSRC; from 1.11 88/03/14 SMI .\" $NetBSD: getrpcent.3,v 1.6 1998/02/05 18:49:06 perry Exp $ -.\" $FreeBSD$ .\" .Dd February 26, 2016 .Dt GETRPCENT 3 diff --git a/lib/libc/rpc/getrpcent.c b/lib/libc/rpc/getrpcent.c index e4770e4e88c5..ee36c11b303f 100644 --- a/lib/libc/rpc/getrpcent.c +++ b/lib/libc/rpc/getrpcent.c @@ -30,12 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid = "@(#)getrpcent.c 1.14 91/03/11 Copyr 1984 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Copyright (c) 1984 by Sun Microsystems, Inc. */ diff --git a/lib/libc/rpc/getrpcport.3 b/lib/libc/rpc/getrpcport.3 index 6e1f199e7b3c..c4d5a053626e 100644 --- a/lib/libc/rpc/getrpcport.3 +++ b/lib/libc/rpc/getrpcport.3 @@ -1,5 +1,3 @@ -.\" @(#)getrpcport.3r 2.2 88/08/02 4.0 RPCSRC; from 1.12 88/02/26 SMI -.\" $FreeBSD$ .\" .Dd October 6, 1987 .Dt GETRPCPORT 3 diff --git a/lib/libc/rpc/getrpcport.c b/lib/libc/rpc/getrpcport.c index 4abc9a0c16af..5065c37cab7b 100644 --- a/lib/libc/rpc/getrpcport.c +++ b/lib/libc/rpc/getrpcport.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)getrpcport.c 1.3 87/08/11 SMI"; -static char *sccsid = "@(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Copyright (c) 1985 by Sun Microsystems, Inc. */ diff --git a/lib/libc/rpc/key_call.c b/lib/libc/rpc/key_call.c index 66bd3b4eaaf3..5c87881c815c 100644 --- a/lib/libc/rpc/key_call.c +++ b/lib/libc/rpc/key_call.c @@ -31,10 +31,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -#ident "@(#)key_call.c 1.25 94/04/24 SMI" -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * key_call.c, Interface to keyserver * diff --git a/lib/libc/rpc/key_prot_xdr.c b/lib/libc/rpc/key_prot_xdr.c index 5a69bb437e3e..aadde38e39c6 100644 --- a/lib/libc/rpc/key_prot_xdr.c +++ b/lib/libc/rpc/key_prot_xdr.c @@ -37,10 +37,6 @@ */ /* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ -/* #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Compiled from key_prot.x using rpcgen. * DO NOT EDIT THIS FILE! diff --git a/lib/libc/rpc/mt_misc.c b/lib/libc/rpc/mt_misc.c index a1b8057bef80..1f8bcfc0cb5d 100644 --- a/lib/libc/rpc/mt_misc.c +++ b/lib/libc/rpc/mt_misc.c @@ -1,9 +1,5 @@ /* $NetBSD: mt_misc.c,v 1.1 2000/06/02 23:11:11 fvdl Exp $ */ -/* #pragma ident "@(#)mt_misc.c 1.24 93/04/29 SMI" */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include "reentrant.h" #include <rpc/rpc.h> diff --git a/lib/libc/rpc/mt_misc.h b/lib/libc/rpc/mt_misc.h index 7f3ced02c148..f60dc80ce737 100644 --- a/lib/libc/rpc/mt_misc.h +++ b/lib/libc/rpc/mt_misc.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 2006 The FreeBSD Project. All rights reserved. * @@ -23,8 +23,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _MT_MISC_H #define _MT_MISC_H diff --git a/lib/libc/rpc/netconfig b/lib/libc/rpc/netconfig index 109f2e36ad43..c6d24a6788b8 100644 --- a/lib/libc/rpc/netconfig +++ b/lib/libc/rpc/netconfig @@ -1,4 +1,3 @@ -# $FreeBSD$ # # The network configuration file. This file is currently only used in # conjunction with the (TI-) RPC code in the C library, unlike its diff --git a/lib/libc/rpc/netconfig.5 b/lib/libc/rpc/netconfig.5 index edd2f63a0f53..d1ffe4f6c2e8 100644 --- a/lib/libc/rpc/netconfig.5 +++ b/lib/libc/rpc/netconfig.5 @@ -1,6 +1,5 @@ .\" $NetBSD: netconfig.5,v 1.2 2000/11/08 13:18:28 lukem Exp $ .\" $NetBSD: netconfig.5,v 1.2 2000/11/08 13:18:28 lukem Exp $ -.\" $FreeBSD$ .Dd November 17, 2000 .Dt NETCONFIG 5 .Os diff --git a/lib/libc/rpc/netname.c b/lib/libc/rpc/netname.c index a9ccf1d2ef99..6ab016ef968a 100644 --- a/lib/libc/rpc/netname.c +++ b/lib/libc/rpc/netname.c @@ -28,12 +28,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)netname.c 1.8 91/03/11 Copyr 1986 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * netname utility routines * convert from unix names to network names and vice-versa diff --git a/lib/libc/rpc/netnamer.c b/lib/libc/rpc/netnamer.c index 591f6d5c91e5..96ece9cc1885 100644 --- a/lib/libc/rpc/netnamer.c +++ b/lib/libc/rpc/netnamer.c @@ -28,12 +28,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)netnamer.c 1.13 91/03/11 Copyr 1986 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * netname utility routines convert from unix names to network names and * vice-versa This module is operating system dependent! What we define here @@ -64,7 +58,7 @@ static char *NETID = "netid.byname"; static char *NETIDFILE = "/etc/netid"; static int getnetid( char *, char * ); -static int _getgroups( char *, gid_t * ); +static int _getgroups( char *, gid_t [NGRPS] ); /* * Convert network-name into unix credential diff --git a/lib/libc/rpc/pmap_clnt.c b/lib/libc/rpc/pmap_clnt.c index f91d33abae23..ad592b8da3de 100644 --- a/lib/libc/rpc/pmap_clnt.c +++ b/lib/libc/rpc/pmap_clnt.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * pmap_clnt.c * Client interface to pmap rpc service. diff --git a/lib/libc/rpc/pmap_getmaps.c b/lib/libc/rpc/pmap_getmaps.c index 598de6baf8c2..594ea1879ab4 100644 --- a/lib/libc/rpc/pmap_getmaps.c +++ b/lib/libc/rpc/pmap_getmaps.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * pmap_getmap.c * Client interface to pmap rpc service. diff --git a/lib/libc/rpc/pmap_getport.c b/lib/libc/rpc/pmap_getport.c index 03feff190813..065cb73c70c7 100644 --- a/lib/libc/rpc/pmap_getport.c +++ b/lib/libc/rpc/pmap_getport.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "from: @(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "from: @(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * pmap_getport.c * Client interface to pmap rpc service. diff --git a/lib/libc/rpc/pmap_prot.c b/lib/libc/rpc/pmap_prot.c index cfb69d795bea..3f4dba89494c 100644 --- a/lib/libc/rpc/pmap_prot.c +++ b/lib/libc/rpc/pmap_prot.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)pmap_prot.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * pmap_prot.c * Protocol for the local binder service, or pmap. diff --git a/lib/libc/rpc/pmap_prot2.c b/lib/libc/rpc/pmap_prot2.c index 20d92250ed9d..98be43a15202 100644 --- a/lib/libc/rpc/pmap_prot2.c +++ b/lib/libc/rpc/pmap_prot2.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)pmap_prot2.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * pmap_prot2.c * Protocol for the local binder service, or pmap. diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index 95efae582e57..3bf22a676382 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * pmap_rmt.c * Client interface to pmap rpc service. diff --git a/lib/libc/rpc/publickey.3 b/lib/libc/rpc/publickey.3 index ff8a615a28df..450fbd037371 100644 --- a/lib/libc/rpc/publickey.3 +++ b/lib/libc/rpc/publickey.3 @@ -1,5 +1,3 @@ -.\" @(#)publickey.3r 2.1 88/08/07 4.0 RPCSRC -.\" $FreeBSD$ .\" .Dd October 6, 1987 .Dt PUBLICKEY 3 diff --git a/lib/libc/rpc/publickey.5 b/lib/libc/rpc/publickey.5 index 71f4ef6aca40..db95c4617b50 100644 --- a/lib/libc/rpc/publickey.5 +++ b/lib/libc/rpc/publickey.5 @@ -1,5 +1,3 @@ -.\" $FreeBSD$ -.\" @(#)publickey.5 2.1 88/08/07 4.0 RPCSRC; from 1.6 88/02/29 SMI; .Dd October 19, 1987 .Dt PUBLICKEY 5 .Os diff --git a/lib/libc/rpc/rpc b/lib/libc/rpc/rpc index 935ea2f1b592..686012d061bc 100644 --- a/lib/libc/rpc/rpc +++ b/lib/libc/rpc/rpc @@ -1,5 +1,4 @@ # -# $FreeBSD$ # rpc 88/08/01 4.0 RPCSRC; from 1.12 99/07/25 SMI # rpcbind 100000 portmap sunrpc rpcbind diff --git a/lib/libc/rpc/rpc.3 b/lib/libc/rpc/rpc.3 index 988b5f1ec233..12d19df117ad 100644 --- a/lib/libc/rpc/rpc.3 +++ b/lib/libc/rpc/rpc.3 @@ -1,7 +1,5 @@ -.\" @(#)rpc.3n 1.31 93/08/31 SMI; from SVr4 .\" Copyright 1989 AT&T .\" $NetBSD: rpc.3,v 1.10 2000/06/02 23:11:12 fvdl Exp $ -.\" $FreeBSD$ .Dd May 7, 1993 .Dt RPC 3 .Os diff --git a/lib/libc/rpc/rpc.5 b/lib/libc/rpc/rpc.5 index 398d9aa4b420..ac8219fc57fc 100644 --- a/lib/libc/rpc/rpc.5 +++ b/lib/libc/rpc/rpc.5 @@ -1,6 +1,4 @@ .\" $NetBSD: rpc.5,v 1.3 2000/06/15 20:05:54 fvdl Exp $ -.\" $FreeBSD$ -.\" @(#)rpc.4 1.17 93/08/30 SMI; from SVr4 .\" Copyright 1989 AT&T .Dd December 10, 1991 .Dt RPC 5 diff --git a/lib/libc/rpc/rpc_callmsg.c b/lib/libc/rpc/rpc_callmsg.c index 05294965c091..a06010cadc2f 100644 --- a/lib/libc/rpc/rpc_callmsg.c +++ b/lib/libc/rpc/rpc_callmsg.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * rpc_callmsg.c * diff --git a/lib/libc/rpc/rpc_clnt_auth.3 b/lib/libc/rpc/rpc_clnt_auth.3 index 863707e3da5e..36aafe85c677 100644 --- a/lib/libc/rpc/rpc_clnt_auth.3 +++ b/lib/libc/rpc/rpc_clnt_auth.3 @@ -1,9 +1,6 @@ -.\" @(#)rpc_clnt_auth.3n 1.21 93/05/07 SMI; from SVr4 .\" Copyright 1989 AT&T -.\" @(#)rpc_clnt_auth 1.4 89/07/20 SMI; .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. .\" $NetBSD: rpc_clnt_auth.3,v 1.1 2000/06/03 09:29:50 fvdl Exp $ -.\" $FreeBSD$ .Dd May 7, 1993 .Dt RPC_CLNT_AUTH 3 .Os diff --git a/lib/libc/rpc/rpc_clnt_calls.3 b/lib/libc/rpc/rpc_clnt_calls.3 index 213a7d184811..894ed8e92cc4 100644 --- a/lib/libc/rpc/rpc_clnt_calls.3 +++ b/lib/libc/rpc/rpc_clnt_calls.3 @@ -1,8 +1,5 @@ -.\" @(#)rpc_clnt_calls.3n 1.30 93/08/31 SMI; from SVr4 .\" Copyright 1989 AT&T -.\" @(#)rpc_clnt_calls 1.4 89/07/20 SMI; .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $FreeBSD$ .Dd May 7, 1993 .Dt RPC_CLNT_CALLS 3 .Os diff --git a/lib/libc/rpc/rpc_clnt_create.3 b/lib/libc/rpc/rpc_clnt_create.3 index 079c9eb729bf..75bc3471faaa 100644 --- a/lib/libc/rpc/rpc_clnt_create.3 +++ b/lib/libc/rpc/rpc_clnt_create.3 @@ -1,9 +1,6 @@ -.\" @(#)rpc_clnt_create.3n 1.36 93/08/31 SMI; from SVr4 .\" Copyright 1989 AT&T -.\" @(#)rpc_clnt_create 1.5 89/07/24 SMI; .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. .\" $NetBSD: rpc_clnt_create.3,v 1.2 2000/06/20 00:53:08 fvdl Exp $ -.\" $FreeBSD$ .Dd May 7, 1993 .Dt RPC_CLNT_CREATE 3 .Os diff --git a/lib/libc/rpc/rpc_com.h b/lib/libc/rpc/rpc_com.h index c0c144fc589d..e641e2d3e731 100644 --- a/lib/libc/rpc/rpc_com.h +++ b/lib/libc/rpc/rpc_com.h @@ -28,8 +28,6 @@ * 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. - * - * $FreeBSD$ */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. @@ -46,9 +44,6 @@ #ifndef _RPC_RPCCOM_H #define _RPC_RPCCOM_H -#include <sys/cdefs.h> - -/* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */ /* * The max size of the transport, if the size cannot be determined @@ -62,7 +57,6 @@ __BEGIN_DECLS extern u_int __rpc_get_a_size(int); -extern int __rpc_dtbsize(void); extern struct netconfig * __rpcgettp(int); extern int __rpc_get_default_domain(char **); diff --git a/lib/libc/rpc/rpc_commondata.c b/lib/libc/rpc/rpc_commondata.c index 4506f3068e95..7b07dff11874 100644 --- a/lib/libc/rpc/rpc_commondata.c +++ b/lib/libc/rpc/rpc_commondata.c @@ -30,12 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid = "@(#)rpc_commondata.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <rpc/rpc.h> #include "un-namespace.h" diff --git a/lib/libc/rpc/rpc_dtablesize.c b/lib/libc/rpc/rpc_dtablesize.c index 59036dd23abf..c2cffecec24e 100644 --- a/lib/libc/rpc/rpc_dtablesize.c +++ b/lib/libc/rpc/rpc_dtablesize.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro"; -static char *sccsid = "@(#)rpc_dtablesize.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <unistd.h> #include "un-namespace.h" diff --git a/lib/libc/rpc/rpc_generic.c b/lib/libc/rpc/rpc_generic.c index 6fbeaf77a7e7..0e563f6a5996 100644 --- a/lib/libc/rpc/rpc_generic.c +++ b/lib/libc/rpc/rpc_generic.c @@ -33,10 +33,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -/* #pragma ident "@(#)rpc_generic.c 1.17 94/04/24 SMI" */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * rpc_generic.c, Miscl routines for RPC. * @@ -99,7 +95,8 @@ static const struct netid_af na_cvt[] = { { "udp6", AF_INET6, IPPROTO_UDP }, { "tcp6", AF_INET6, IPPROTO_TCP }, #endif - { "local", AF_LOCAL, 0 } + { "local", AF_LOCAL, 0 }, + { "netlink", AF_NETLINK, 0 }, }; #if 0 @@ -107,29 +104,6 @@ static char *strlocase(char *); #endif static int getnettype(const char *); -/* - * Cache the result of getrlimit(), so we don't have to do an - * expensive call every time. - */ -int -__rpc_dtbsize(void) -{ - static int tbsize; - struct rlimit rl; - - if (tbsize) { - return (tbsize); - } - if (getrlimit(RLIMIT_NOFILE, &rl) == 0) { - return (tbsize = (int)rl.rlim_max); - } - /* - * Something wrong. I'll try to save face by returning a - * pessimistic number. - */ - return (32); -} - /* * Find the appropriate buffer size diff --git a/lib/libc/rpc/rpc_prot.c b/lib/libc/rpc/rpc_prot.c index a865d43fc185..48671462a52e 100644 --- a/lib/libc/rpc/rpc_prot.c +++ b/lib/libc/rpc/rpc_prot.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * rpc_prot.c * diff --git a/lib/libc/rpc/rpc_secure.3 b/lib/libc/rpc/rpc_secure.3 index 07c6314c9402..ce59bba7115f 100644 --- a/lib/libc/rpc/rpc_secure.3 +++ b/lib/libc/rpc/rpc_secure.3 @@ -1,5 +1,3 @@ -.\" @(#)rpc_secure.3n 2.1 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI -.\" $FreeBSD$ .\" .Dd February 16, 1988 .Dt RPC 3 @@ -268,8 +266,7 @@ Inverse of .Fn netname2user . .Sh SEE ALSO .Xr rpc 3 , -.Xr xdr 3 , -.Xr keyserv 8 +.Xr xdr 3 .Pp The following manuals: .Rs diff --git a/lib/libc/rpc/rpc_soc.3 b/lib/libc/rpc/rpc_soc.3 index 1af57280916f..4abd4b14c475 100644 --- a/lib/libc/rpc/rpc_soc.3 +++ b/lib/libc/rpc/rpc_soc.3 @@ -1,6 +1,4 @@ -.\" @(#)rpc.3n 2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI .\" $NetBSD: rpc_soc.3,v 1.2 2000/06/07 13:39:43 simonb Exp $ -.\" $FreeBSD$ .\" .Dd February 16, 1988 .Dt RPC_SOC 3 diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c index ae23442e9a16..c63b89594ce6 100644 --- a/lib/libc/rpc/rpc_soc.c +++ b/lib/libc/rpc/rpc_soc.c @@ -30,8 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* #ident "@(#)rpc_soc.c 1.17 94/04/24 SMI" */ - /* * Copyright (c) 1986-1991 by Sun Microsystems Inc. * In addition, portions of such source code were derived from Berkeley @@ -39,12 +37,6 @@ * California. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #ifdef PORTMAP /* * rpc_soc.c diff --git a/lib/libc/rpc/rpc_svc_calls.3 b/lib/libc/rpc/rpc_svc_calls.3 index 873296210cb4..503cf6a53b9c 100644 --- a/lib/libc/rpc/rpc_svc_calls.3 +++ b/lib/libc/rpc/rpc_svc_calls.3 @@ -1,9 +1,6 @@ -.\" @(#)rpc_svc_calls.3n 1.28 93/05/10 SMI; from SVr4 .\" Copyright 1989 AT&T -.\" @(#)rpc_svc_calls 1.5 89/07/25 SMI; .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. .\" $NetBSD: rpc_svc_calls.3,v 1.1 2000/06/02 23:11:13 fvdl Exp $ -.\" $FreeBSD$ .Dd May 3, 1993 .Dt RPC_SVC_CALLS 3 .Os diff --git a/lib/libc/rpc/rpc_svc_create.3 b/lib/libc/rpc/rpc_svc_create.3 index 4016a6c36b03..4c5dde45aabd 100644 --- a/lib/libc/rpc/rpc_svc_create.3 +++ b/lib/libc/rpc/rpc_svc_create.3 @@ -1,8 +1,5 @@ -.\" @(#)rpc_svc_create.3n 1.26 93/08/26 SMI; from SVr4 .\" Copyright 1989 AT&T -.\" @(#)rpc_svc_create 1.3 89/06/28 SMI; .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $FreeBSD$ .Dd May 3, 1993 .Dt RPC_SVC_CREATE 3 .Os diff --git a/lib/libc/rpc/rpc_svc_err.3 b/lib/libc/rpc/rpc_svc_err.3 index 7a6b1f132f4c..c2724cefac5a 100644 --- a/lib/libc/rpc/rpc_svc_err.3 +++ b/lib/libc/rpc/rpc_svc_err.3 @@ -1,9 +1,6 @@ -.\" @(#)rpc_svc_err.3n 1.23 93/08/31 SMI; from SVr4 .\" Copyright 1989 AT&T -.\" @(#)rpc_svc_err 1.4 89/06/28 SMI; .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. .\" $NetBSD: rpc_svc_err.3,v 1.1 2000/06/02 23:11:14 fvdl Exp $ -.\" $FreeBSD$ .Dd May 3, 1993 .Dt RPC_SVC_ERR 3 .Os diff --git a/lib/libc/rpc/rpc_svc_reg.3 b/lib/libc/rpc/rpc_svc_reg.3 index 81a749a107e4..00c8259f6ef4 100644 --- a/lib/libc/rpc/rpc_svc_reg.3 +++ b/lib/libc/rpc/rpc_svc_reg.3 @@ -1,9 +1,6 @@ -.\" @(#)rpc_svc_reg.3n 1.32 93/08/31 SMI; from SVr4 .\" Copyright 1989 AT&T -.\" @(#)rpc_svc_call 1.6 89/07/20 SMI; .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. .\" $NetBSD: rpc_svc_reg.3,v 1.1 2000/06/02 23:11:14 fvdl Exp $ -.\" $FreeBSD$ .Dd May 3, 1993 .Dt RPC_SVC_REG 3 .Os diff --git a/lib/libc/rpc/rpc_xdr.3 b/lib/libc/rpc/rpc_xdr.3 index 62754fe7e285..1918684101c2 100644 --- a/lib/libc/rpc/rpc_xdr.3 +++ b/lib/libc/rpc/rpc_xdr.3 @@ -1,8 +1,5 @@ -.\" @(#)rpc_xdr.3n 1.24 93/08/31 SMI; from SVr4 .\" Copyright 1989 AT&T -.\" @(#)rpc_xdr.new 1.1 89/04/06 SMI; .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $FreeBSD$ .Dd May 3, 1993 .Dt RPC_XDR 3 .Os diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c index f39d99bfeee3..a08cd82b4359 100644 --- a/lib/libc/rpc/rpcb_clnt.c +++ b/lib/libc/rpc/rpcb_clnt.c @@ -30,15 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* #ident "@(#)rpcb_clnt.c 1.27 94/04/24 SMI" */ - - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rpcb_clnt.c 1.30 89/06/21 Copyr 1988 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * rpcb_clnt.c * interface to rpcbind rpc service. @@ -742,6 +733,16 @@ __rpcb_findaddr_timed(rpcprog_t program, rpcvers_t version, struct pmap pmapparms; /* + * The comment below is now very old, having + * been committed to FreeBSD during an import + * from NetBSD in 2001. I do not believe there + * will still be any rpcbind servers that do + * UDP only and, since Azure requires use of + * TCP for NFSv3 mounts, comment this out + * so that NFSv3 mounts on Azure can work. + */ +#ifdef notnow + /* * Try UDP only - there are some portmappers out * there that use UDP only. */ @@ -754,9 +755,9 @@ __rpcb_findaddr_timed(rpcprog_t program, rpcvers_t version, } client = getclnthandle(host, newnconf, &parms.r_addr); freenetconfigent(newnconf); - } else { + } else +#endif client = getclnthandle(host, nconf, &parms.r_addr); - } if (client == NULL) return (NULL); diff --git a/lib/libc/rpc/rpcb_prot.c b/lib/libc/rpc/rpcb_prot.c index 6cb7204f1a66..c6de3465898f 100644 --- a/lib/libc/rpc/rpcb_prot.c +++ b/lib/libc/rpc/rpcb_prot.c @@ -33,14 +33,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -/* #ident "@(#)rpcb_prot.c 1.13 94/04/24 SMI" */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rpcb_prot.c 1.9 89/04/21 Copyr 1984 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * rpcb_prot.c * XDR routines for the rpcbinder version 3. diff --git a/lib/libc/rpc/rpcb_st_xdr.c b/lib/libc/rpc/rpcb_st_xdr.c index 5b0462715aec..ece2f284a980 100644 --- a/lib/libc/rpc/rpcb_st_xdr.c +++ b/lib/libc/rpc/rpcb_st_xdr.c @@ -39,9 +39,6 @@ * routines used with the rpcbind stats facility. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <rpc/rpc.h> #include <rpc/rpc_com.h> diff --git a/lib/libc/rpc/rpcbind.3 b/lib/libc/rpc/rpcbind.3 index 3bf8be9ffa90..aa5ffe62af7e 100644 --- a/lib/libc/rpc/rpcbind.3 +++ b/lib/libc/rpc/rpcbind.3 @@ -1,8 +1,6 @@ -.\" @(#)rpcbind.3n 1.25 93/05/07 SMI; from SVr4 .\" Copyright 1989 AT&T .\" Copyright (c) 1988 Sun Microsystem's, Inc. - All Right's Reserved. .\" $NetBSD: rpcbind.3,v 1.2 2000/06/03 18:47:28 fvdl Exp $ -.\" $FreeBSD$ .Dd May 7, 1993 .Dt RPCBIND 3 .Os diff --git a/lib/libc/rpc/rpcdname.c b/lib/libc/rpc/rpcdname.c index 3e7c4a7c2f1a..dff2ca464572 100644 --- a/lib/libc/rpc/rpcdname.c +++ b/lib/libc/rpc/rpcdname.c @@ -28,12 +28,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rpcdname.c 1.7 91/03/11 Copyr 1989 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * rpcdname.c * Gets the default domain name diff --git a/lib/libc/rpc/rpcsec_gss_stub.c b/lib/libc/rpc/rpcsec_gss_stub.c index a24f250521f7..66f1663de307 100644 --- a/lib/libc/rpc/rpcsec_gss_stub.c +++ b/lib/libc/rpc/rpcsec_gss_stub.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Doug Rabson * All rights reserved. @@ -24,8 +24,6 @@ * 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. - * - * $FreeBSD$ */ #include <rpc/rpc.h> diff --git a/lib/libc/rpc/rtime.3 b/lib/libc/rpc/rtime.3 index e657ca50aa18..3c245ab398ac 100644 --- a/lib/libc/rpc/rtime.3 +++ b/lib/libc/rpc/rtime.3 @@ -1,5 +1,3 @@ -.\" @(#)rtime.3n 2.1 88/08/08 4.0 RPCSRC; from 1.5 88/02/08 SMI -.\" $FreeBSD$ .\" .Dd May 13, 2021 .Dt RTIME 3 diff --git a/lib/libc/rpc/rtime.c b/lib/libc/rpc/rtime.c index 4adca5c5f13d..0d4177142bf2 100644 --- a/lib/libc/rpc/rtime.c +++ b/lib/libc/rpc/rtime.c @@ -55,12 +55,6 @@ #include <netdb.h> #include "un-namespace.h" -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rtime.c 2.2 88/08/10 4.0 RPCSRC; from 1.8 88/02/08 SMI"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - extern int _rpc_dtablesize( void ); #define NYEARS (unsigned long)(1970 - 1900) diff --git a/lib/libc/rpc/svc.c b/lib/libc/rpc/svc.c index 801b32081a26..d3877a95b742 100644 --- a/lib/libc/rpc/svc.c +++ b/lib/libc/rpc/svc.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * svc.c, Server-side remote procedure call interface. * diff --git a/lib/libc/rpc/svc_auth.c b/lib/libc/rpc/svc_auth.c index 48560a3bc872..eb61171733d6 100644 --- a/lib/libc/rpc/svc_auth.c +++ b/lib/libc/rpc/svc_auth.c @@ -33,13 +33,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -#if defined(LIBC_SCCS) && !defined(lint) -#ident "@(#)svc_auth.c 1.16 94/04/24 SMI" -static char sccsid[] = "@(#)svc_auth.c 1.26 89/02/07 Copyr 1984 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * svc_auth.c, Server-side rpc authenticator interface. * diff --git a/lib/libc/rpc/svc_auth_des.c b/lib/libc/rpc/svc_auth_des.c index 8f742c39718a..d4736cc851e8 100644 --- a/lib/libc/rpc/svc_auth_des.c +++ b/lib/libc/rpc/svc_auth_des.c @@ -65,12 +65,6 @@ #include <rpc/svc_auth.h> #include "libc_private.h" -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)svcauth_des.c 2.3 89/07/11 4.0 RPCSRC; from 1.15 88/02/08 SMI"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - extern int key_decryptsession_pk(const char *, netobj *, des_block *); #define debug(msg) printf("svcauth_des: %s\n", msg) diff --git a/lib/libc/rpc/svc_auth_unix.c b/lib/libc/rpc/svc_auth_unix.c index de146b821600..2caab6fe9d9e 100644 --- a/lib/libc/rpc/svc_auth_unix.c +++ b/lib/libc/rpc/svc_auth_unix.c @@ -28,13 +28,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * svc_auth_unix.c * Handles UNIX flavor authentication parameters on the service side of rpc. diff --git a/lib/libc/rpc/svc_dg.c b/lib/libc/rpc/svc_dg.c index c7e0726270b7..892fe5ceaa53 100644 --- a/lib/libc/rpc/svc_dg.c +++ b/lib/libc/rpc/svc_dg.c @@ -34,12 +34,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -#if defined(LIBC_SCCS) && !defined(lint) -#ident "@(#)svc_dg.c 1.17 94/04/24 SMI" -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * svc_dg.c, Server side for connectionless RPC. * diff --git a/lib/libc/rpc/svc_generic.c b/lib/libc/rpc/svc_generic.c index 37ad3513c716..ea08811ba1ae 100644 --- a/lib/libc/rpc/svc_generic.c +++ b/lib/libc/rpc/svc_generic.c @@ -34,13 +34,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -#if defined(LIBC_SCCS) && !defined(lint) -#ident "@(#)svc_generic.c 1.19 94/04/24 SMI" -static char sccsid[] = "@(#)svc_generic.c 1.21 89/02/28 Copyr 1988 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * svc_generic.c, Server side for RPC. * diff --git a/lib/libc/rpc/svc_nl.c b/lib/libc/rpc/svc_nl.c new file mode 100644 index 000000000000..cff364063c5c --- /dev/null +++ b/lib/libc/rpc/svc_nl.c @@ -0,0 +1,373 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 Gleb Smirnoff <glebius@FreeBSD.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + */ + +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <pthread.h> +#include <rpc/rpc.h> +#include <rpc/clnt_nl.h> + +#include <netlink/netlink.h> +#include <netlink/netlink_generic.h> +#include <netlink/netlink_snl.h> +#include <netlink/netlink_snl_generic.h> + +#include "rpc_com.h" +#include "libc_private.h" + +/* + * RPC server to serve a kernel RPC client(s) over netlink(4). See clnt_nl.c + * in sys/rpc as the counterpart. + * + * Upon creation the client will seek for specified multicast group within the + * generic netlink family named "rpc". Then it would listen for incoming + * messages, process them and send replies over the same netlink socket. + * See clnt_nl.c for more transport protocol implementation details. + */ + +static void svc_nl_destroy(SVCXPRT *); +static bool_t svc_nl_recv(SVCXPRT *, struct rpc_msg *); +static bool_t svc_nl_reply(SVCXPRT *, struct rpc_msg *); +static enum xprt_stat svc_nl_stat(SVCXPRT *); +static bool_t svc_nl_getargs(SVCXPRT *, xdrproc_t, void *); +static bool_t svc_nl_freeargs(SVCXPRT *, xdrproc_t, void *); +static bool_t svc_nl_control(SVCXPRT *, const u_int, void *); + +static struct xp_ops nl_ops = { + .xp_recv = svc_nl_recv, + .xp_reply = svc_nl_reply, + .xp_stat = svc_nl_stat, + .xp_getargs = svc_nl_getargs, + .xp_freeargs = svc_nl_freeargs, + .xp_destroy = svc_nl_destroy, +}; +static struct xp_ops2 nl_ops2 = { + .xp_control = svc_nl_control, +}; + +struct nl_softc { + struct snl_state snl; + XDR xdrs; + struct nlmsghdr *hdr; + pthread_key_t xidkey; + size_t mlen; + enum xprt_stat stat; + uint32_t xid; + uint32_t group; + uint16_t family; + u_int errline; + int error; +}; + +SVCXPRT * +svc_nl_create(const char *service) +{ + static struct sockaddr_nl snl_null = { + .nl_len = sizeof(struct sockaddr_nl), + .nl_family = PF_NETLINK, + }; + struct nl_softc *sc; + SVCXPRT *xprt = NULL; + void *buf = NULL; + uint16_t family; + ssize_t len = 1024; + + if ((sc = calloc(1, sizeof(struct nl_softc))) == NULL) + return (NULL); + if (!snl_init(&sc->snl, NETLINK_GENERIC) || (sc->group = + snl_get_genl_mcast_group(&sc->snl, "rpc", service, &family)) == 0) + goto fail; + if (setsockopt(sc->snl.fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, + &sc->group, sizeof(sc->group)) == -1) + goto fail; + if ((buf = malloc(len)) == NULL) + goto fail; + if ((xprt = svc_xprt_alloc()) == NULL) + goto fail; + + sc->hdr = buf, + sc->mlen = len, + sc->stat = XPRT_IDLE, + sc->family = family; + + if (__isthreaded && + (pthread_key_create(&sc->xidkey, NULL) != 0 || + pthread_setspecific(sc->xidkey, &sc->xid) != 0)) + goto fail; + + xprt->xp_fd = sc->snl.fd, + xprt->xp_p1 = sc, + xprt->xp_ops = &nl_ops, + xprt->xp_ops2 = &nl_ops2, + xprt->xp_rtaddr = (struct netbuf){ + .maxlen = sizeof(struct sockaddr_nl), + .len = sizeof(struct sockaddr_nl), + .buf = &snl_null, + }; + xprt_register(xprt); + + return (xprt); +fail: + free(xprt); + free(buf); + snl_free(&sc->snl); + free(sc); + return (NULL); +} + +static void +svc_nl_destroy(SVCXPRT *xprt) +{ + struct nl_softc *sc = xprt->xp_p1; + + snl_free(&sc->snl); + free(sc->hdr); + free(xprt->xp_p1); + svc_xprt_free(xprt); +} + +#define DIE(sc) do { \ + (sc)->stat = XPRT_DIED; \ + (sc)->errline = __LINE__; \ + (sc)->error = errno; \ + return (FALSE); \ +} while (0) + +struct nl_request_parsed { + uint32_t group; + struct nlattr *data; +}; +static const struct snl_attr_parser rpcnl_attr_parser[] = { +#define OUT(field) offsetof(struct nl_request_parsed, field) + { .type = RPCNL_REQUEST_GROUP, .off = OUT(group), + .cb = snl_attr_get_uint32 }, + { .type = RPCNL_REQUEST_BODY, .off = OUT(data), .cb = snl_attr_get_nla }, +#undef OUT +}; +SNL_DECLARE_GENL_PARSER(request_parser, rpcnl_attr_parser); + +static bool_t +svc_nl_recv(SVCXPRT *xprt, struct rpc_msg *msg) +{ + struct nl_request_parsed req; + struct nl_softc *sc = xprt->xp_p1; + struct nlmsghdr *hdr = sc->hdr; + + switch (sc->stat) { + case XPRT_IDLE: + if (recv(xprt->xp_fd, hdr, sizeof(struct nlmsghdr), + MSG_PEEK) != sizeof(struct nlmsghdr)) + DIE(sc); + break; + case XPRT_MOREREQS: + sc->stat = XPRT_IDLE; + break; + case XPRT_DIED: + return (FALSE); + } + + if (sc->mlen < hdr->nlmsg_len) { + if ((hdr = sc->hdr = realloc(hdr, hdr->nlmsg_len)) == NULL) + DIE(sc); + else + sc->mlen = hdr->nlmsg_len; + } + if (read(xprt->xp_fd, hdr, hdr->nlmsg_len) != hdr->nlmsg_len) + DIE(sc); + + if (hdr->nlmsg_type != sc->family) + return (FALSE); + + if (((struct genlmsghdr *)(hdr + 1))->cmd != RPCNL_REQUEST) + return (FALSE); + + if (!snl_parse_nlmsg(NULL, hdr, &request_parser, &req)) + return (FALSE); + + if (req.group != sc->group) + return (FALSE); + + xdrmem_create(&sc->xdrs, NLA_DATA(req.data), NLA_DATA_LEN(req.data), + XDR_DECODE); + if (xdr_callmsg(&sc->xdrs, msg)) { + /* XXX: assert that xid == nlmsg_seq? */ + sc->xid = msg->rm_xid; + return (TRUE); + } else + return (FALSE); +} + +/* + * Reenterable reply method. Note that both the softc and xprt are declared + * const. The qualifier for xprt is commented out to match the library + * prototype. If doing any substantial changes to the function please + * temporarily uncomment the const for xprt and check your changes. + * + * Applications that want to use svc_nl_reply in a spawned thread context + * should do the following hacks in self: + * 1) - Create xprt with svc_nl_create() with libc in threaded mode, e.g. + * at least one pthread_create() shall happen before svc_nl_create(). + * - After xprt creation query it for the pthread_key_t with the + * SVCNL_GET_XIDKEY control and save this key. + * 2) In the RPC function body that wants to become multithreaded: + * - Make a copy of the arguments and of the xid with help of + * pthread_getspecific() using the key. + * - pthread_create() the worker function, pointing it at the copy of + * arguments and xid. + * - return FALSE, so that RPC generated code doesn't do anything. + * 3) In the spawned thread: + * - Use arguments provided in the copy by the parent. + * - Allocate appropriately typed result on stack. + * - *** do the actual work *** + * - Populate the on-stack result same way as pointed result is populated + * in a regular RPC function. + * - Point the thread specific storage to the copy of xid provided by the + * parent with help of pthread_setspecific(). + * - Call svc_sendreply() just like the rpcgen(1) generated code does. + * + * If all done correctly svc_nl_reply() will use thread specific xid for + * a call that was processed asynchronously and most recent xid when entered + * synchronously. So you can make only some methods of your application + * reentrable, keeping others as is. + */ + +static bool_t +svc_nl_reply(/* const */ SVCXPRT *xprt, struct rpc_msg *msg) +{ + const struct nl_softc *sc = xprt->xp_p1; + struct snl_state snl; + struct snl_writer nw; + XDR xdrs; + struct nlattr *body; + bool_t rv; + + msg->rm_xid = __isthreaded ? + *(uint32_t *)pthread_getspecific(sc->xidkey) : + sc->xid; + + if (__predict_false(!snl_clone(&snl, &sc->snl))) + return (FALSE); + snl_init_writer(&snl, &nw); + snl_create_genl_msg_request(&nw, sc->family, RPCNL_REPLY); + snl_add_msg_attr_u32(&nw, RPCNL_REPLY_GROUP, sc->group); + body = snl_reserve_msg_attr_raw(&nw, RPCNL_REPLY_BODY, RPC_MAXDATASIZE); + + xdrmem_create(&xdrs, (char *)(body + 1), RPC_MAXDATASIZE, XDR_ENCODE); + + if (msg->rm_reply.rp_stat == MSG_ACCEPTED && + msg->rm_reply.rp_acpt.ar_stat == SUCCESS) { + xdrproc_t xdr_proc; + char *xdr_where; + u_int pos; + + xdr_proc = msg->acpted_rply.ar_results.proc; + xdr_where = msg->acpted_rply.ar_results.where; + msg->acpted_rply.ar_results.proc = (xdrproc_t) xdr_void; + msg->acpted_rply.ar_results.where = NULL; + + pos = xdr_getpos(&xdrs); + if (!xdr_replymsg(&xdrs, msg) || + !SVCAUTH_WRAP(&SVC_AUTH(xprt), &xdrs, xdr_proc, + xdr_where)) { + xdr_setpos(&xdrs, pos); + rv = FALSE; + } else + rv = TRUE; + } else + rv = xdr_replymsg(&xdrs, msg); + + if (rv) { + /* snl_finalize_msg() really doesn't work for us */ + body->nla_len = sizeof(struct nlattr) + xdr_getpos(&xdrs); + nw.hdr->nlmsg_len = ((char *)body - (char *)nw.hdr) + + body->nla_len; + nw.hdr->nlmsg_type = sc->family; + nw.hdr->nlmsg_flags = NLM_F_REQUEST; + nw.hdr->nlmsg_seq = msg->rm_xid; + if (write(xprt->xp_fd, nw.hdr, nw.hdr->nlmsg_len) != + nw.hdr->nlmsg_len) + DIE(__DECONST(struct nl_softc *, sc)); + } + + snl_free(&snl); + + return (rv); +} + +static bool_t +svc_nl_control(SVCXPRT *xprt, const u_int req, void *v) +{ + struct nl_softc *sc = xprt->xp_p1; + + switch (req) { + case SVCNL_GET_XIDKEY: + if (!__isthreaded) { + /* + * Report to application that it had created xprt not + * in threaded mode, but definitly plans to use it with + * threads. If it tries so, it would very likely crash. + */ + errno = EDOOFUS; + DIE(sc); + }; + *(pthread_key_t *)v = sc->xidkey; + return (TRUE); + default: + return (FALSE); + } +} + +static enum xprt_stat +svc_nl_stat(SVCXPRT *xprt) +{ + struct nl_softc *sc = xprt->xp_p1; + + if (sc->stat == XPRT_IDLE && + recv(xprt->xp_fd, sc->hdr, sizeof(struct nlmsghdr), + MSG_PEEK | MSG_DONTWAIT) == sizeof(struct nlmsghdr)) + sc->stat = XPRT_MOREREQS; + + return (sc->stat); +} + +static bool_t +svc_nl_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr) +{ + struct nl_softc *sc = xprt->xp_p1; + + return (SVCAUTH_UNWRAP(&SVC_AUTH(xprt), &sc->xdrs, xdr_args, args_ptr)); +} + +static bool_t +svc_nl_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr) +{ + struct nl_softc *sc = xprt->xp_p1; + + sc->xdrs.x_op = XDR_FREE; + return ((*xdr_args)(&sc->xdrs, args_ptr)); +} diff --git a/lib/libc/rpc/svc_raw.c b/lib/libc/rpc/svc_raw.c index 05da6231af37..ceedb083eae6 100644 --- a/lib/libc/rpc/svc_raw.c +++ b/lib/libc/rpc/svc_raw.c @@ -33,14 +33,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -/* #ident "@(#)svc_raw.c 1.16 94/04/24 SMI" */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)svc_raw.c 1.25 89/01/31 Copyr 1984 Sun Micro"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * svc_raw.c, This a toy for simple testing and timing. * Interface to create an rpc client and server in the same UNIX process. diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c index a4723c42144f..2c71d2bd082c 100644 --- a/lib/libc/rpc/svc_run.c +++ b/lib/libc/rpc/svc_run.c @@ -30,13 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "from: @(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro"; -static char *sccsid = "from: @(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * This is the rpc server side idle loop * Wait for input, call server program. diff --git a/lib/libc/rpc/svc_simple.c b/lib/libc/rpc/svc_simple.c index fcf4199e611e..f4ce90f19bb4 100644 --- a/lib/libc/rpc/svc_simple.c +++ b/lib/libc/rpc/svc_simple.c @@ -33,10 +33,6 @@ * Copyright (c) 1986-1991 by Sun Microsystems Inc. */ -/* #pragma ident "@(#)svc_simple.c 1.18 94/04/24 SMI" */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * svc_simple.c * Simplified front end to rpc. diff --git a/lib/libc/rpc/svc_vc.c b/lib/libc/rpc/svc_vc.c index a045903c8285..e5826fdb6543 100644 --- a/lib/libc/rpc/svc_vc.c +++ b/lib/libc/rpc/svc_vc.c @@ -30,18 +30,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *sccsid2 = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro"; -static char *sccsid = "@(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * svc_vc.c, Server side for Connection Oriented based RPC. * * Actually implements two flavors of transporter - - * a tcp rendezvouser (a listner and connection establisher) + * a tcp rendezvouser (a listener and connection establisher) * and a record/tcp stream. */ |