Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/rpcbind merge RUMP changes.



details:   https://anonhg.NetBSD.org/src/rev/e780f611f1f5
branches:  trunk
changeset: 341488:e780f611f1f5
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Nov 08 16:36:28 2015 +0000

description:
merge RUMP changes.

diffstat:

 usr.sbin/rpcbind/check_bound.c  |  11 +++++-
 usr.sbin/rpcbind/pmap_svc.c     |  12 +++---
 usr.sbin/rpcbind/rpcb_svc_com.c |  71 +++++++++++++++++++++++++++-------------
 usr.sbin/rpcbind/rpcbind.c      |  52 ++++++++++++++++++++++++++++-
 usr.sbin/rpcbind/util.c         |   7 +++-
 5 files changed, 119 insertions(+), 34 deletions(-)

diffs (truncated from 413 to 300 lines):

diff -r c6328e501ed6 -r e780f611f1f5 usr.sbin/rpcbind/check_bound.c
--- a/usr.sbin/rpcbind/check_bound.c    Sun Nov 08 02:46:53 2015 +0000
+++ b/usr.sbin/rpcbind/check_bound.c    Sun Nov 08 16:36:28 2015 +0000
@@ -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 @@
 #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 @@
 
        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 -r c6328e501ed6 -r e780f611f1f5 usr.sbin/rpcbind/pmap_svc.c
--- a/usr.sbin/rpcbind/pmap_svc.c       Sun Nov 08 02:46:53 2015 +0000
+++ b/usr.sbin/rpcbind/pmap_svc.c       Sun Nov 08 16:36:28 2015 +0000
@@ -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 @@
        struct sockcred *sc;
        char uidbuf[32];
 
+       if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
+               svcerr_decode(xprt);
+               return (FALSE);
+       }
+
 #ifdef RPCBIND_DEBUG
        if (debugging)
                fprintf(stderr, "%s request for (%lu, %lu) : ",
@@ -180,11 +185,6 @@
                    reg.pm_prog, reg.pm_vers);
 #endif
 
-       if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (char *)&reg)) {
-               svcerr_decode(xprt);
-               return (FALSE);
-       }
-
        if (!check_access(xprt, op, &reg, PMAPVERS)) {
                svcerr_weakauth(xprt);
                return FALSE;
diff -r c6328e501ed6 -r e780f611f1f5 usr.sbin/rpcbind/rpcb_svc_com.c
--- a/usr.sbin/rpcbind/rpcb_svc_com.c   Sun Nov 08 02:46:53 2015 +0000
+++ b/usr.sbin/rpcbind/rpcb_svc_com.c   Sun Nov 08 16:36:28 2015 +0000
@@ -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 @@
 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 @@
                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 @@
 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 @@
        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 @@
 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 @@
                        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 @@
                                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 @@
                }
 #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 @@
 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 @@
 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 -r c6328e501ed6 -r e780f611f1f5 usr.sbin/rpcbind/rpcbind.c
--- a/usr.sbin/rpcbind/rpcbind.c        Sun Nov 08 02:46:53 2015 +0000
+++ b/usr.sbin/rpcbind/rpcbind.c        Sun Nov 08 16:36:28 2015 +0000
@@ -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 @@
 #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 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 @@
        (void) signal(SIGQUIT, terminate);



Home | Main Index | Thread Index | Old Index