Commit 9ba02638 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Trond Myklebust

[PATCH] RPC: Allow the sunrpc server to multiplex serveral programs on a single port

 The NFS and NFSACL programs run on the same RPC transport.  This patch adds
 support for this by converting svc_program into a chained list of programs
 (server-side).
Signed-off-by: default avatarAndreas Gruenbacher <agruen@suse.de>
Signed-off-by: default avatarOlaf Kirch <okir@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent a838cc49
...@@ -240,9 +240,10 @@ struct svc_deferred_req { ...@@ -240,9 +240,10 @@ struct svc_deferred_req {
}; };
/* /*
* RPC program * List of RPC programs on the same transport endpoint
*/ */
struct svc_program { struct svc_program {
struct svc_program * pg_next; /* other programs (same xprt) */
u32 pg_prog; /* program number */ u32 pg_prog; /* program number */
unsigned int pg_lovers; /* lowest version */ unsigned int pg_lovers; /* lowest version */
unsigned int pg_hivers; /* lowest version */ unsigned int pg_hivers; /* lowest version */
......
...@@ -35,20 +35,24 @@ svc_create(struct svc_program *prog, unsigned int bufsize) ...@@ -35,20 +35,24 @@ svc_create(struct svc_program *prog, unsigned int bufsize)
if (!(serv = (struct svc_serv *) kmalloc(sizeof(*serv), GFP_KERNEL))) if (!(serv = (struct svc_serv *) kmalloc(sizeof(*serv), GFP_KERNEL)))
return NULL; return NULL;
memset(serv, 0, sizeof(*serv)); memset(serv, 0, sizeof(*serv));
serv->sv_name = prog->pg_name;
serv->sv_program = prog; serv->sv_program = prog;
serv->sv_nrthreads = 1; serv->sv_nrthreads = 1;
serv->sv_stats = prog->pg_stats; serv->sv_stats = prog->pg_stats;
serv->sv_bufsz = bufsize? bufsize : 4096; serv->sv_bufsz = bufsize? bufsize : 4096;
prog->pg_lovers = prog->pg_nvers-1;
xdrsize = 0; xdrsize = 0;
for (vers=0; vers<prog->pg_nvers ; vers++) while (prog) {
if (prog->pg_vers[vers]) { prog->pg_lovers = prog->pg_nvers-1;
prog->pg_hivers = vers; for (vers=0; vers<prog->pg_nvers ; vers++)
if (prog->pg_lovers > vers) if (prog->pg_vers[vers]) {
prog->pg_lovers = vers; prog->pg_hivers = vers;
if (prog->pg_vers[vers]->vs_xdrsize > xdrsize) if (prog->pg_lovers > vers)
xdrsize = prog->pg_vers[vers]->vs_xdrsize; prog->pg_lovers = vers;
} if (prog->pg_vers[vers]->vs_xdrsize > xdrsize)
xdrsize = prog->pg_vers[vers]->vs_xdrsize;
}
prog = prog->pg_next;
}
serv->sv_xdrsize = xdrsize; serv->sv_xdrsize = xdrsize;
INIT_LIST_HEAD(&serv->sv_threads); INIT_LIST_HEAD(&serv->sv_threads);
INIT_LIST_HEAD(&serv->sv_sockets); INIT_LIST_HEAD(&serv->sv_sockets);
...@@ -56,8 +60,6 @@ svc_create(struct svc_program *prog, unsigned int bufsize) ...@@ -56,8 +60,6 @@ svc_create(struct svc_program *prog, unsigned int bufsize)
INIT_LIST_HEAD(&serv->sv_permsocks); INIT_LIST_HEAD(&serv->sv_permsocks);
spin_lock_init(&serv->sv_lock); spin_lock_init(&serv->sv_lock);
serv->sv_name = prog->pg_name;
/* Remove any stale portmap registrations */ /* Remove any stale portmap registrations */
svc_register(serv, 0, 0); svc_register(serv, 0, 0);
...@@ -339,7 +341,10 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp) ...@@ -339,7 +341,10 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
goto sendit; goto sendit;
} }
if (prog != progp->pg_prog) for (progp = serv->sv_program; progp; progp = progp->pg_next)
if (prog == progp->pg_prog)
break;
if (progp == NULL)
goto err_bad_prog; goto err_bad_prog;
if (vers >= progp->pg_nvers || if (vers >= progp->pg_nvers ||
...@@ -452,11 +457,7 @@ err_bad_auth: ...@@ -452,11 +457,7 @@ err_bad_auth:
goto sendit; goto sendit;
err_bad_prog: err_bad_prog:
#ifdef RPC_PARANOIA dprintk("svc: unknown program %d\n", prog);
if (prog != 100227 || progp->pg_prog != 100003)
printk("svc: unknown program %d (me %d)\n", prog, progp->pg_prog);
/* else it is just a Solaris client seeing if ACLs are supported */
#endif
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
svc_putu32(resv, rpc_prog_unavail); svc_putu32(resv, rpc_prog_unavail);
goto sendit; goto sendit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment