SUNRPC: register services with per-net rpcbind
Subsystems (4)
v2 cover SUNRPC: register services with per-net rpcbind
This patch-set was created in context of clone of git branch:git://git.linux-nfs.org/projects/trondmy/nfs-2.6.git.
head: devel
v2:
1) Rebased on up-to-date state ("devel" head).
2) 3 patches from previous series:
a) [1/7] "SUNRPC: create rpcbind client in passed network namespace context"
b) [2/7] "SUNRPC: register rpcbind programs in passed network namespase context"
c) [4/7] "SUNRPC: parametrize local rpcbind clients creation with net ns" moved to series:
[PATCH v5 0/6] SUNRPC: rcbind clients virtualization
This patch set makes service registered with per-net rpcbind and required for making Lockd and NFSd services able to handle requests from and to different network namespaces.
The following series consists of:
---
Stanislav Kinsbursky (4):
SUNRPC: use proper network namespace in rpcbind RPCBPROC_GETADDR procedure
SUNRPC: pass network namespace to service registering routines
SUNRPC: register service on creation in current network namespace
SUNRPC: unregister service on creation in current network namespace
fs/nfsd/nfssvc.c | 4 +-- include/linux/sunrpc/svc.h | 11 ++++---- net/sunrpc/rpcb_clnt.c | 3 +- net/sunrpc/svc.c | 61 ++++++++++++++++++++++++-------------------- net/sunrpc/svcsock.c | 3 +- 5 files changed, 45 insertions(+), 37 deletions(-)
Signature · 1 line
Signature
PATCH v2 1/4 SUNRPC: use proper network namespace in rpcbind RPCBPROC_GETADDR procedure
Pass request socket network namespace to rpc_uaddr2sockaddr() instead of hardcoded "init_net", when decoding address in RPCBPROC_GETADDR procedure.
--- net/sunrpc/rpcb_clnt.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
net/sunrpc/rpcb_clnt.c +2 -1
@@ -934,7 +934,8 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,dprintk ("RPC: %5u RPCB_%s reply: %s\n" , task->tk_pid, task->tk_msg.rpc_proc->p_name, (char *)p); -if (rpc_uaddr2sockaddr (&init_net, (char *)p, len, sap,sizeof (address)) ==0 ) +if (rpc_uaddr2sockaddr (req->rq_xprt->xprt_net, (char *)p, len, + sap,sizeof (address)) ==0 ) goto out_fail; rpcb->r_port =rpc_get_port (sap);
PATCH v2 2/4 SUNRPC: pass network namespace to service registering routines
In reply to Stanislav KinsburskyLockd and NFSd services will handle requests from and to many network nsamespaces. And thus have to be registered and unregistered per network namespace.
--- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 42 +++++++++++++++++++++++------------------- net/sunrpc/svcsock.c | 3 ++- 3 files changed, 26 insertions(+), 21 deletions(-)
include/linux/sunrpc/svc.h +1 -1
@@ -428,7 +428,7 @@ void svc_destroy(struct svc_serv *);int svc_process (struct svc_rqst *);int bc_svc_process (struct svc_serv *,struct rpc_rqst *,struct svc_rqst *); -int svc_register (const struct svc_serv *,const int , +int svc_register (const struct svc_serv *,struct net *,const int ,const unsigned short ,const unsigned short );void svc_wake_up (struct svc_serv *);
net/sunrpc/svc.c +23 -19
151 lines not on this page · raw message
net/sunrpc/svcsock.c +2 -1
@@ -1409,7 +1409,8 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,/* Register socket with portmapper */ if (*errp >=0 && pmap_register) - *errp =svc_register (serv, inet->sk_family, inet->sk_protocol, + *errp =svc_register (serv, sock->sk->sk_net, inet->sk_family, + inet->sk_protocol,ntohs (inet_sk (inet)->inet_sport));if (*errp <0 ) {
PATCH v2 3/4 SUNRPC: register service on creation in current network namespace
In reply to Stanislav KinsburskyService, using rpcbind (Lockd, NFSd) are starting from userspace call and thus we can use current network namespace.
There could be a problem with NFSd service, because it's creation can be called through NFSd fs from different network namespace. But this is a part of "NFSd per net ns" task and will be fixed in future.
--- net/sunrpc/svc.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
net/sunrpc/svc.c +5 -4
@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/kthread.h> #include <linux/slab.h> +#include <linux/nsproxy.h> #include <linux/sunrpc/types.h> #include <linux/sunrpc/xdr.h>
@@ -366,16 +367,16 @@ svc_pool_for_cpu(struct svc_serv *serv, int cpu)return &serv->sv_pools[pidx % serv->sv_nrpools]; } -static int svc_rpcb_setup (struct svc_serv *serv) +static int svc_rpcb_setup (struct svc_serv *serv,struct net *net) {int err; - err =rpcb_create_local (&init_net); + err =rpcb_create_local (net);if (err)return err;/* Remove any stale portmap registrations */ -svc_unregister (serv, &init_net); +svc_unregister (serv, net);return 0 ; }
@@ -468,7 +469,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, }if (svc_uses_rpcbind (serv)) { -if (svc_rpcb_setup (serv) <0 ) { +if (svc_rpcb_setup (serv, current->nsproxy->net_ns) <0 ) {kfree (serv->sv_pools);kfree (serv);return NULL ;
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 4/4 SUNRPC: unregister service on creation in current network namespace
In reply to Stanislav KinsburskyOn service shutdown we can be sure, that no more users of it left except current. Thus it looks like using current network namespace context is safe in this case.
--- fs/nfsd/nfssvc.c | 4 ++-- include/linux/sunrpc/svc.h | 9 +++++---- net/sunrpc/svc.c | 14 +++++++------- 3 files changed, 14 insertions(+), 13 deletions(-)
fs/nfsd/nfssvc.c +2 -2
@@ -251,13 +251,13 @@ static void nfsd_shutdown(void) nfsd_up = false; } -static void nfsd_last_thread (struct svc_serv *serv) +static void nfsd_last_thread (struct svc_serv *serv,struct net *net) {/* When last nfsd thread exits we need to do some clean-up */ nfsd_serv =NULL ;nfsd_shutdown (); -svc_rpcb_cleanup (serv); +svc_rpcb_cleanup (serv, net);printk (KERN_WARNING "nfsd: last server has exited, flushing export " "cache\n" );
include/linux/sunrpc/svc.h +5 -4
@@ -84,7 +84,8 @@ struct svc_serv {unsigned int sv_nrpools;/* number of thread pools */ struct svc_pool * sv_pools;/* array of thread pools */ -void (*sv_shutdown)(struct svc_serv *serv); +void (*sv_shutdown)(struct svc_serv *serv, +struct net *net);/* Callback to use when last thread * exits. */
@@ -413,14 +414,14 @@ struct svc_procedure {/* * Function prototypes. */ -void svc_rpcb_cleanup (struct svc_serv *serv); +void svc_rpcb_cleanup (struct svc_serv *serv,struct net *net);struct svc_serv *svc_create (struct svc_program *,unsigned int , -void (*shutdown)(struct svc_serv *)); +void (*shutdown)(struct svc_serv *,struct net *net));struct svc_rqst *svc_prepare_thread (struct svc_serv *serv,struct svc_pool *pool,int node);void svc_exit_thread (struct svc_rqst *);struct svc_serv *svc_create_pooled (struct svc_program *,unsigned int , -void (*shutdown)(struct svc_serv *), +void (*shutdown)(struct svc_serv *,struct net *net),svc_thread_fn ,struct module *);int svc_set_num_threads (struct svc_serv *,struct svc_pool *,int );int svc_pool_stats_open (struct svc_serv *serv,struct file *file);
net/sunrpc/svc.c +7 -7
@@ -380,10 +380,10 @@ static int svc_rpcb_setup(struct svc_serv *serv, struct net *net)return 0 ; } -void svc_rpcb_cleanup (struct svc_serv *serv) +void svc_rpcb_cleanup (struct svc_serv *serv,struct net *net) { -svc_unregister (serv, &init_net); -rpcb_put_local (&init_net); +svc_unregister (serv, net); +rpcb_put_local (net); }EXPORT_SYMBOL_GPL (svc_rpcb_cleanup);
@@ -409,7 +409,7 @@ static int svc_uses_rpcbind(struct svc_serv *serv)*/ static struct svc_serv *__svc_create (struct svc_program *prog,unsigned int bufsize,int npools, -void (*shutdown)(struct svc_serv *serv)) +void (*shutdown)(struct svc_serv *serv,struct net *net)) {struct svc_serv *serv;unsigned int vers;
@@ -483,7 +483,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,struct svc_serv *svc_create (struct svc_program *prog,unsigned int bufsize, -void (*shutdown)(struct svc_serv *serv)) +void (*shutdown)(struct svc_serv *serv,struct net *net)) {return __svc_create (prog, bufsize,/*npools*/ 1 , shutdown); }
@@ -491,7 +491,7 @@ EXPORT_SYMBOL_GPL(svc_create);struct svc_serv *svc_create_pooled (struct svc_program *prog,unsigned int bufsize, -void (*shutdown)(struct svc_serv *serv), +void (*shutdown)(struct svc_serv *serv,struct net *net),svc_thread_fn func,struct module *mod) {struct svc_serv *serv;
@@ -532,7 +532,7 @@ svc_destroy(struct svc_serv *serv)svc_close_all (&serv->sv_tempsocks);if (serv->sv_shutdown) - serv->sv_shutdown (serv); + serv->sv_shutdown (serv, current->nsproxy->net_ns);svc_close_all (&serv->sv_permsocks);