[PATCH] knfsd: register all RPC programs with portmapper by default
authorOlaf Kirch <okir@suse.de>
Wed, 4 Oct 2006 09:16:05 +0000 (02:16 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 4 Oct 2006 14:55:19 +0000 (07:55 -0700)
The NFSACL patches introduced support for multiple RPC services listening on
the same transport.  However, only the first of these services was registered
with portmapper.  This was perfectly fine for nfsacl, as you traditionally do
not want these to show up in a portmapper listing.

The patch below changes the default behavior to always register all services
listening on a given transport, but retains the old behavior for nfsacl
services.

Signed-off-by: Olaf Kirch <okir@suse.de>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
include/linux/sunrpc/svc.h
net/sunrpc/svc.c

index 71108da2e54ef53422535b0d54a6cfe9f417d4c7..9187755661df06d9aec879a08167e9848c26c399 100644 (file)
@@ -333,4 +333,5 @@ struct svc_version  nfsd_acl_version2 = {
                .vs_proc        = nfsd_acl_procedures2,
                .vs_dispatch    = nfsd_dispatch,
                .vs_xdrsize     = NFS3_SVC_XDRSIZE,
+               .vs_hidden      = 1,
 };
index f813b054f4a12a125d069491118ebcc24bb32ea4..d4bdc00c1169cc3f462a1fe11e2ebae0e72b15a9 100644 (file)
@@ -263,5 +263,6 @@ struct svc_version  nfsd_acl_version3 = {
                .vs_proc        = nfsd_acl_procedures3,
                .vs_dispatch    = nfsd_dispatch,
                .vs_xdrsize     = NFS3_SVC_XDRSIZE,
+               .vs_hidden      = 1,
 };
 
index 74e52c245da4b1f43f74f8a1a1a811d59e94b11b..d6288e89fd9d64308113cc0035afd29ea1f71528 100644 (file)
@@ -321,6 +321,9 @@ struct svc_version {
        struct svc_procedure *  vs_proc;        /* per-procedure info */
        u32                     vs_xdrsize;     /* xdrsize needed for this version */
 
+       unsigned int            vs_hidden : 1;  /* Don't register with portmapper.
+                                                * Only used for nfsacl so far. */
+
        /* Override dispatch function (e.g. when caching replies).
         * A return value of 0 means drop the request. 
         * vs_dispatch == NULL means use default dispatcher.
index b252401c86016d4104401dadf7258b14a7ca6b51..550441d13a081fc9566acd0f71fcb15a1d37d54d 100644 (file)
@@ -644,23 +644,32 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)
        unsigned long           flags;
        int                     i, error = 0, dummy;
 
-       progp = serv->sv_program;
-
-       dprintk("RPC: svc_register(%s, %s, %d)\n",
-               progp->pg_name, proto == IPPROTO_UDP? "udp" : "tcp", port);
-
        if (!port)
                clear_thread_flag(TIF_SIGPENDING);
 
-       for (i = 0; i < progp->pg_nvers; i++) {
-               if (progp->pg_vers[i] == NULL)
-                       continue;
-               error = rpc_register(progp->pg_prog, i, proto, port, &dummy);
-               if (error < 0)
-                       break;
-               if (port && !dummy) {
-                       error = -EACCES;
-                       break;
+       for (progp = serv->sv_program; progp; progp = progp->pg_next) {
+               for (i = 0; i < progp->pg_nvers; i++) {
+                       if (progp->pg_vers[i] == NULL)
+                               continue;
+
+                       dprintk("RPC: svc_register(%s, %s, %d, %d)%s\n",
+                                       progp->pg_name,
+                                       proto == IPPROTO_UDP?  "udp" : "tcp",
+                                       port,
+                                       i,
+                                       progp->pg_vers[i]->vs_hidden?
+                                               " (but not telling portmap)" : "");
+
+                       if (progp->pg_vers[i]->vs_hidden)
+                               continue;
+
+                       error = rpc_register(progp->pg_prog, i, proto, port, &dummy);
+                       if (error < 0)
+                               break;
+                       if (port && !dummy) {
+                               error = -EACCES;
+                               break;
+                       }
                }
        }