diff options
| author | christos <christos@NetBSD.org> | 2015-11-08 16:36:28 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2015-11-08 16:36:28 +0000 |
| commit | e835c7f0fe647157ae907440ac2e13af2cdf3a8d (patch) | |
| tree | 7fd3575146f68533fd94235bc41293f9d8066780 | |
| parent | 690198481f4a4e7c89dbb64626f22a7b6b9a7a3c (diff) | |
merge RUMP changes.
| -rw-r--r-- | usr.sbin/rpcbind/check_bound.c | 11 | ||||
| -rw-r--r-- | usr.sbin/rpcbind/pmap_svc.c | 12 | ||||
| -rw-r--r-- | usr.sbin/rpcbind/rpcb_svc_com.c | 71 | ||||
| -rw-r--r-- | usr.sbin/rpcbind/rpcbind.c | 52 | ||||
| -rw-r--r-- | usr.sbin/rpcbind/util.c | 7 |
5 files changed, 119 insertions, 34 deletions
diff --git a/usr.sbin/rpcbind/check_bound.c b/usr.sbin/rpcbind/check_bound.c index 0df4c381549..1993b5f9498 100644 --- a/usr.sbin/rpcbind/check_bound.c +++ b/usr.sbin/rpcbind/check_bound.c @@ -1,4 +1,4 @@ -/* $NetBSD: check_bound.c,v 1.5 2007/08/27 19:53:33 dsl Exp $ */ +/* $NetBSD: check_bound.c,v 1.6 2015/11/08 16:36:28 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -57,6 +57,11 @@ static char sccsid[] = "@(#)check_bound.c 1.11 89/04/21 Copyr 1989 Sun Micro"; #include <unistd.h> #include <stdlib.h> +#ifdef RPCBIND_RUMP +#include <rump/rump.h> +#include <rump/rump_syscalls.h> +#endif + #include "rpcbind.h" struct fdlist { @@ -99,7 +104,11 @@ check_bound(struct fdlist *fdl, const char *uaddr) ans = bind(fd, (struct sockaddr *)na->buf, na->len); +#ifdef RPCBIND_RUMP + rump_sys_close(fd); +#else close(fd); +#endif free(na); return (ans == 0 ? FALSE : TRUE); diff --git a/usr.sbin/rpcbind/pmap_svc.c b/usr.sbin/rpcbind/pmap_svc.c index cffc07eebc4..f40bdb2b2ba 100644 --- a/usr.sbin/rpcbind/pmap_svc.c +++ b/usr.sbin/rpcbind/pmap_svc.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_svc.c,v 1.7 2013/10/19 17:16:38 christos Exp $ */ +/* $NetBSD: pmap_svc.c,v 1.8 2015/11/08 16:36:28 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -173,6 +173,11 @@ pmapproc_change(struct svc_req *rqstp, SVCXPRT *xprt, unsigned long op) struct sockcred *sc; char uidbuf[32]; + if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)®)) { + svcerr_decode(xprt); + return (FALSE); + } + #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "%s request for (%lu, %lu) : ", @@ -180,11 +185,6 @@ pmapproc_change(struct svc_req *rqstp, SVCXPRT *xprt, unsigned long op) reg.pm_prog, reg.pm_vers); #endif - if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)®)) { - svcerr_decode(xprt); - return (FALSE); - } - if (!check_access(xprt, op, ®, PMAPVERS)) { svcerr_weakauth(xprt); return FALSE; diff --git a/usr.sbin/rpcbind/rpcb_svc_com.c b/usr.sbin/rpcbind/rpcb_svc_com.c index 9282076b031..5ba0230ae91 100644 --- a/usr.sbin/rpcbind/rpcb_svc_com.c +++ b/usr.sbin/rpcbind/rpcb_svc_com.c @@ -1,4 +1,4 @@ -/* $NetBSD: rpcb_svc_com.c,v 1.16 2011/08/31 16:25:00 plunky Exp $ */ +/* $NetBSD: rpcb_svc_com.c,v 1.17 2015/11/08 16:36:28 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -58,8 +58,16 @@ #include <string.h> #include <stdlib.h> +#ifdef RPCBIND_RUMP +#include <rump/rump.h> +#include <rump/rump_syscalls.h> +#endif + #include "rpcbind.h" #include "svc_dg.h" +#ifdef RPCBIND_RUMP +#include "svc_fdset.h" +#endif #define RPC_BUF_MAX 65536 /* can be raised if required */ @@ -287,7 +295,7 @@ void delete_prog(rpcprog_t prog) { RPCB reg; - register rpcblist_ptr rbl; + rpcblist_ptr rbl; for (rbl = list_rbl; rbl != NULL; rbl = rbl->rpcb_next) { if ((rbl->rpcb_map.r_prog != prog)) @@ -518,10 +526,7 @@ create_rmtcall_fd(struct netconfig *nconf) rmttail->next = rmt; rmttail = rmt; } - /* XXX not threadsafe */ - if (fd > svc_maxfd) - svc_maxfd = fd; - FD_SET(fd, &svc_fdset); + svc_fdset_set(fd); return (fd); } @@ -594,7 +599,7 @@ void rpcbproc_callit_com(struct svc_req *rqstp, SVCXPRT *transp, rpcproc_t reply_type, rpcvers_t versnum) { - register rpcblist_ptr rbl; + rpcblist_ptr rbl; struct netconfig *nconf; struct netbuf *caller; struct r_rmtcall_args a; @@ -1028,8 +1033,8 @@ free_slot_by_index(int idx) if (fi->flag & FINFO_ACTIVE) { netbuffree(fi->caller_addr); /* XXX may be too big, but can't access xprt array here */ - if (fi->forward_fd >= svc_maxfd) - svc_maxfd--; + if (fi->forward_fd >= *svc_fdset_getmax()) + (*svc_fdset_getmax())--; free((void *) fi->uaddr); fi->flag &= ~FINFO_ACTIVE; rpcb_rmtcalls--; @@ -1072,19 +1077,27 @@ void my_svc_run(void) { size_t nfds; - struct pollfd pollfds[FD_SETSIZE]; + struct pollfd *pollfds; + int npollfds; int poll_ret, check_ret; - int n; + int n, m; #ifdef SVC_RUN_DEBUG int i; #endif - register struct pollfd *p; - fd_set cleanfds; + struct pollfd *p; + + pollfds = NULL; + npollfds = 0; for (;;) { + if (svc_fdset_getsize(0) != npollfds) { + npollfds = svc_fdset_getsize(0); + pollfds = realloc(pollfds, npollfds * sizeof(*pollfds)); + } p = pollfds; - for (n = 0; n <= svc_maxfd; n++) { - if (FD_ISSET(n, &svc_fdset)) { + m = *svc_fdset_getmax(); + for (n = 0; n <= m; n++) { + if (svc_fdset_isset(n)) { p->fd = n; p->events = MASKVAL; p++; @@ -1101,16 +1114,26 @@ my_svc_run(void) fprintf(stderr, ">\n"); } #endif - switch (poll_ret = poll(pollfds, nfds, 30 * 1000)) { +#ifdef RPCBIND_RUMP + poll_ret = rump_sys_poll(pollfds, nfds, 30 * 1000); +#else + poll_ret = poll(pollfds, nfds, 30 * 1000); +#endif + switch (poll_ret) { case -1: /* * We ignore all errors, continuing with the assumption * that it was set by the signal handlers (or any * other outside event) and not caused by poll(). */ +#ifdef SVC_RUN_DEBUG + if (debugging) { + fprintf(stderr, "poll returned %d (%s)\n", + poll_ret, strerror(errno)); + } +#endif case 0: - cleanfds = svc_fdset; - __svc_clean_idle(&cleanfds, 30, FALSE); + __svc_clean_idle(NULL, 30, FALSE); continue; default: #ifdef SVC_RUN_DEBUG @@ -1118,7 +1141,8 @@ my_svc_run(void) fprintf(stderr, "poll returned read fds < "); for (i = 0, p = pollfds; i < nfds; i++, p++) if (p->revents) - fprintf(stderr, "%d ", p->fd); + fprintf(stderr, "%d (0x%x)", + p->fd, p->revents); fprintf(stderr, ">\n"); } #endif @@ -1136,7 +1160,8 @@ my_svc_run(void) } #ifdef SVC_RUN_DEBUG if (debugging) { - fprintf(stderr, "svc_maxfd now %u\n", svc_maxfd); + fprintf(stderr, "svc_maxfd now %u\n", + *svc_fdset_getmax()); } #endif } @@ -1294,7 +1319,7 @@ done: static void find_versions(rpcprog_t prog, char *netid, rpcvers_t *lowvp, rpcvers_t *highvp) { - register rpcblist_ptr rbl; + rpcblist_ptr rbl; rpcvers_t lowv = 0; rpcvers_t highv = 0; @@ -1331,8 +1356,8 @@ find_versions(rpcprog_t prog, char *netid, rpcvers_t *lowvp, rpcvers_t *highvp) static rpcblist_ptr find_service(rpcprog_t prog, rpcvers_t vers, char *netid) { - register rpcblist_ptr hit = NULL; - register rpcblist_ptr rbl; + rpcblist_ptr hit = NULL; + rpcblist_ptr rbl; for (rbl = list_rbl; rbl != NULL; rbl = rbl->rpcb_next) { if ((rbl->rpcb_map.r_prog != prog) || diff --git a/usr.sbin/rpcbind/rpcbind.c b/usr.sbin/rpcbind/rpcbind.c index 26b36ca18c3..29ac5c023a1 100644 --- a/usr.sbin/rpcbind/rpcbind.c +++ b/usr.sbin/rpcbind/rpcbind.c @@ -1,4 +1,4 @@ -/* $NetBSD: rpcbind.c,v 1.22 2015/05/09 21:22:18 christos Exp $ */ +/* $NetBSD: rpcbind.c,v 1.23 2015/11/08 16:36:28 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -72,8 +72,22 @@ static char sccsid[] = "@(#)rpcbind.c 1.35 89/04/21 Copyr 1984 Sun Micro"; #include <errno.h> #include "rpcbind.h" +#ifdef RPCBIND_RUMP +#include <semaphore.h> + +#include <rump/rump.h> +#include <rump/rump_syscalls.h> + +#include "svc_fdset.h" + +extern sem_t gensem; +#define DEBUGGING 1 +#else +#define DEBUGGING 0 +#endif + /* Global variables */ -int debugging = 0; /* Tell me what's going on */ +int debugging = DEBUGGING; /* Tell me what's going on */ int doabort = 0; /* When debugging, do an abort on errors */ rpcblist_ptr list_rbl; /* A list of version 3/4 rpcbind services */ @@ -106,17 +120,27 @@ static int init_transport(struct netconfig *); static void rbllist_add(rpcprog_t, rpcvers_t, struct netconfig *, struct netbuf *); __dead static void terminate(int); +#ifndef RPCBIND_RUMP static void parseargs(int, char *[]); int main(int argc, char *argv[]) +#else +int rpcbind_main(void *); +int +rpcbind_main(void *arg) +#endif { struct netconfig *nconf; void *nc_handle; /* Net config handle */ struct rlimit rl; int maxrec = RPC_MAXDATASIZE; +#ifdef RPCBIND_RUMP + svc_fdset_init(SVC_FDSET_MT); +#else parseargs(argc, argv); +#endif if (getrlimit(RLIMIT_NOFILE, &rl) == -1) err(EXIT_FAILURE, "getrlimit(RLIMIT_NOFILE)"); @@ -158,7 +182,9 @@ main(int argc, char *argv[]) (void) signal(SIGQUIT, terminate); /* ignore others that could get sent */ (void) signal(SIGPIPE, SIG_IGN); +#ifndef RPCBIND_RUMP (void) signal(SIGHUP, SIG_IGN); +#endif (void) signal(SIGUSR1, SIG_IGN); (void) signal(SIGUSR2, SIG_IGN); #ifdef WARMSTART @@ -196,6 +222,9 @@ main(int argc, char *argv[]) network_init(); +#ifdef RPCBIND_RUMP + sem_post(&gensem); +#endif my_svc_run(); syslog(LOG_ERR, "svc_run returned unexpectedly"); rpcbind_abort(); @@ -272,7 +301,11 @@ init_transport(struct netconfig *nconf) if (!strcmp(nconf->nc_netid, "local")) { (void)memset(&sun, 0, sizeof sun); sun.sun_family = AF_LOCAL; +#ifdef RPCBIND_RUMP + (void)rump_sys_unlink(_PATH_RPCBINDSOCK); +#else (void)unlink(_PATH_RPCBINDSOCK); +#endif (void)strlcpy(sun.sun_path, _PATH_RPCBINDSOCK, sizeof(sun.sun_path)); sun.sun_len = SUN_LEN(&sun); @@ -301,9 +334,11 @@ init_transport(struct netconfig *nconf) freeaddrinfo(res); return 1; } +#ifndef RPCBIND_RUMP if (sa->sa_family == AF_LOCAL) if (chmod(sun.sun_path, S_IRWXU|S_IRWXG|S_IRWXO) == -1) warn("Cannot chmod `%s'", sun.sun_path); +#endif /* Copy the address */ taddr.addr.len = taddr.addr.maxlen = addrlen; @@ -325,7 +360,8 @@ init_transport(struct netconfig *nconf) nb.buf = sa; nb.len = nb.maxlen = sa->sa_len; uaddr = taddr2uaddr(nconf, &nb); - (void)fprintf(stderr, "rpcbind: my address is %s\n", uaddr); + (void)fprintf(stderr, "rpcbind: my address is %s fd=%d\n", + uaddr, fd); (void)free(uaddr); } #endif @@ -486,7 +522,11 @@ init_transport(struct netconfig *nconf) } return (0); error: +#ifdef RPCBIND_RUMP + (void)rump_sys_close(fd); +#else (void)close(fd); +#endif return (1); } @@ -522,7 +562,11 @@ terminate(int dummy) "rpcbind terminating on signal. Restart with \"rpcbind -w\""); write_warmstart(); /* Dump yourself */ #endif +#ifdef RPCBIND_RUMP + exit(2); +#else exit(EXIT_FAILURE); +#endif } void @@ -534,6 +578,7 @@ rpcbind_abort() abort(); } +#ifndef RPCBIND_RUMP /* get command line options */ static void parseargs(int argc, char *argv[]) @@ -577,6 +622,7 @@ parseargs(int argc, char *argv[]) doabort = 0; } } +#endif void reap(int dummy) diff --git a/usr.sbin/rpcbind/util.c b/usr.sbin/rpcbind/util.c index ad54e3dc738..fc47859c624 100644 --- a/usr.sbin/rpcbind/util.c +++ b/usr.sbin/rpcbind/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.19 2015/05/09 18:32:04 dholland Exp $ */ +/* $NetBSD: util.c,v 1.20 2015/11/08 16:36:28 christos Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -48,6 +48,11 @@ #include <arpa/inet.h> #include <err.h> +#ifdef RPCBIND_RUMP +#include <rump/rump.h> +#include <rump/rump_syscalls.h> +#endif + #include "rpcbind.h" static struct sockaddr_in *local_in4; |
