sunrpc: Create sockets in namespaces
Subsystems (4)
cover sunrpc: Create sockets in namespaces
Hi!
This set implements pulling the net * argument down to the existing sock_create_kern calls in the sunrpc layer and creating the sockets in the given net.
Patch #7 opens the __sock_create for public and I hope we can do it not in the Dave's tree :)
Applies to git://linux-nfs.org/~bfields/linux.git nfsd-next after the ip_map_cache virtualization patch set I sent before.
Thanks,
Pavel
PATCH 1/8 sunrpc: Factor out rpc_xprt freeing
--- net/sunrpc/xprtsock.c | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-)
net/sunrpc/xprtsock.c +12 -8
@@ -759,6 +759,8 @@ static void xs_tcp_close(struct rpc_xprt *xprt)xs_tcp_shutdown (xprt); } +static void xs_free_xprt (struct rpc_xprt *xprt); +/** * xs_destroy - prepare to shutdown a transport * @xprt: doomed transport
@@ -774,8 +776,7 @@ static void xs_destroy(struct rpc_xprt *xprt)xs_close (xprt);xs_free_peer_addresses (xprt); -kfree (xprt->slot); -kfree (xprt); +xs_free_xprt (xprt);module_put (THIS_MODULE ); }
@@ -2298,6 +2299,12 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args,return xprt; } +static void xs_free_xprt (struct rpc_xprt *xprt) +{ +kfree (xprt->slot); +kfree (xprt); +} +static const struct rpc_timeout xs_udp_default_timeout = { .to_initval =5 *HZ , .to_maxval =30 *HZ ,
@@ -2371,8 +2378,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args)return xprt; ret =ERR_PTR (-EINVAL ); out_err: -kfree (xprt->slot); -kfree (xprt); +xs_free_xprt (xprt);return ret; }
@@ -2447,8 +2453,7 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)return xprt; ret =ERR_PTR (-EINVAL ); out_err: -kfree (xprt->slot); -kfree (xprt); +xs_free_xprt (xprt);return ret; }
@@ -2528,8 +2533,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)return xprt; ret =ERR_PTR (-EINVAL ); out_err: -kfree (xprt->slot); -kfree (xprt); +xs_free_xprt (xprt);return ret; }
Signature · 1 line
1.5.5.6
Re: [PATCH 1/8] sunrpc: Factor out rpc_xprt freeing
Quoted 11 lines · Pavel Emelyanov
Signed-off-by Pavel Emelyanov <[email protected]>---
net/sunrpc/xprtsock.c| 20 ++++++++++++--------1 files changed, 12 insertions(+), 8 deletions(-)net/sunrpc/xprtsock.c +0
-0
net/sunrpc/xprtsock.c static void xs_tcp_close(struct rpc_xprt *xprt) · line 762
Quoted 4 lines
net/sunrpc/xprtsock.c +1
-0@@ -759,6 +759,8 @@ static void xs_tcp_close(struct rpc_xprt *xprt)xs_tcp_shutdown (xprt); } +static void xs_free_xprt (struct rpc_xprt *xprt);
Style nit: we usually like forward declarations at the top of source files.
Do you need to fix up xprtrdma too? (eg. xprt_rdma_destroy) It looks like it has similar logic around freeing xprts. Even though it doesn't use sockets, do we need to be concerned about net namespaces for RDMA transports?
Quoted 60 lines
net/sunrpc/xprtsock.c +8
-2+/** * xs_destroy - prepare to shutdown a transport * @xprt: doomed transport @@ -774,8 +776,7 @@ static void xs_destroy(struct rpc_xprt *xprt)xs_close (xprt);xs_free_peer_addresses (xprt); -kfree (xprt->slot); -kfree (xprt); +xs_free_xprt (xprt);module_put (THIS_MODULE ); }@@ -2298,6 +2299,12 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args,return xprt; } +static void xs_free_xprt (struct rpc_xprt *xprt) +{ +kfree (xprt->slot); +kfree (xprt); +} +static const struct rpc_timeout xs_udp_default_timeout = { .to_initval =5 *HZ , .to_maxval =30 *HZ ,@@ -2371,8 +2378,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args)return xprt; ret =ERR_PTR (-EINVAL );
out_err:net/sunrpc/xprtsock.c +1
-2-kfree (xprt->slot); -kfree (xprt); +xs_free_xprt (xprt);return ret; }net/sunrpc/xprtsock.c +0
-0@@ -2447,8 +2453,7 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)return xprt; ret =ERR_PTR (-EINVAL );
out_err:net/sunrpc/xprtsock.c +1
-2-kfree (xprt->slot); -kfree (xprt); +xs_free_xprt (xprt);return ret; }net/sunrpc/xprtsock.c +0
-0@@ -2528,8 +2533,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)return xprt; ret =ERR_PTR (-EINVAL );
out_err:net/sunrpc/xprtsock.c +1
-2-kfree (xprt->slot); -kfree (xprt); +xs_free_xprt (xprt);return ret; }Signature · 1 line
1.5.5.6
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 1/8] sunrpc: Factor out rpc_xprt freeing
Quoted 17 lines · Chuck Lever
Quoted 14 lines · Pavel Emelyanov
Signed-off-by Pavel Emelyanov <[email protected]>---
net/sunrpc/xprtsock.c| 20 ++++++++++++--------1 files changed, 12 insertions(+), 8 deletions(-)net/sunrpc/xprtsock.c +0
-0@@ -759,6 +759,8 @@ static void xs_tcp_close(struct rpc_xprt *xprt)xs_tcp_shutdown (xprt); }
Quoted 3 lines
net/sunrpc/xprtsock.c static void xs_tcp_close(struct rpc_xprt *xprt) · line 762
Quoted 1 line
net/sunrpc/xprtsock.c +1
-0+static void xs_free_xprt (struct rpc_xprt *xprt);Style nit: we usually like forward declarations at the top of source files.
OK.
Quoted 2 lines
Do you need to fix up xprtrdma too? (eg.
xprt_rdma_destroy) It looks like it has similar logic around freeing xprts.
Indeed. Bruce, which way would you prefer - should I re-send the whole set or can apply this change incrementally?
Quoted 2 lines
Even though it doesn't use sockets, do we need to be concerned about net namespaces for RDMA transports?
I believe we should, since at least its initialization goes to the rdma_resolve_addr which in turn resolves the address using IP-level routing. But I wanted to finish with the tcp/udp transports first.
Thanks,
Pavel
Re: [PATCH 1/8] sunrpc: Factor out rpc_xprt freeing
Quoted 22 lines · Pavel Emelyanov
Quoted 17 lines · Chuck Lever
Quoted 14 lines · Pavel Emelyanov
Signed-off-by Pavel Emelyanov <[email protected]>---
net/sunrpc/xprtsock.c| 20 ++++++++++++--------1 files changed, 12 insertions(+), 8 deletions(-)net/sunrpc/xprtsock.c +0
-0@@ -759,6 +759,8 @@ static void xs_tcp_close(struct rpc_xprt *xprt)xs_tcp_shutdown (xprt); }Quoted 3 lines
net/sunrpc/xprtsock.c static void xs_tcp_close(struct rpc_xprt *xprt) · line 762
Quoted 1 line
net/sunrpc/xprtsock.c +1
-0+static void xs_free_xprt (struct rpc_xprt *xprt);Style nit: we usually like forward declarations at the top of source files.
Quoted 7 lines
OK.
Quoted 2 lines
Do you need to fix up xprtrdma too? (eg.
xprt_rdma_destroy) It looks like it has similar logic around freeing xprts.Indeed. Bruce, which way would you prefer - should I re-send the whole set or can apply this change incrementally?
I haven't pushed it out yet, so just do whichever you prefer.
--b.
Quoted 10 lines
Quoted 3 lines
Even though it doesn't use sockets, do we need to be concerned about net namespaces for RDMA transports?
I believe we should, since at least its initialization goes to the
rdma_resolve_addrwhich in turn resolves the address using IP-level routing. But I wanted to finish with the tcp/udp transports first.Thanks,
Pavel
Re: [PATCH 1/8] sunrpc: Factor out rpc_xprt freeing
In reply to Pavel EmelyanovQuoted 30 lines · Pavel Emelyanov
Quoted 17 lines · Chuck Lever
Quoted 14 lines · Pavel Emelyanov
Signed-off-by Pavel Emelyanov <[email protected]>---
net/sunrpc/xprtsock.c| 20 ++++++++++++--------1 files changed, 12 insertions(+), 8 deletions(-)net/sunrpc/xprtsock.c +0
-0@@ -759,6 +759,8 @@ static void xs_tcp_close(struct rpc_xprt *xprt)xs_tcp_shutdown (xprt); }Quoted 3 lines
net/sunrpc/xprtsock.c static void xs_tcp_close(struct rpc_xprt *xprt) · line 762
Quoted 1 line
net/sunrpc/xprtsock.c +1
-0+static void xs_free_xprt (struct rpc_xprt *xprt);Style nit: we usually like forward declarations at the top of source files.
OK.
Quoted 2 lines
Do you need to fix up xprtrdma too? (eg.
xprt_rdma_destroy) It looks like it has similar logic around freeing xprts.Indeed. Bruce, which way would you prefer - should I re-send the whole set or can apply this change incrementally?
Quoted 6 lines
Quoted 2 lines
Even though it doesn't use sockets, do we need to be concerned about net namespaces for RDMA transports?
I believe we should, since at least its initialization goes to the
rdma_resolve_addrwhich in turn resolves the address using IP-level routing. But I wanted to finish with the tcp/udp transports first.
If you are redoing the patch, then could you please just get rid of the above forward declaration for xs_free_xprt, and instead just move the function itself further up the file?
Cheers
Trond
A message that is not in the archive (sent off-list or not yet received): 1285682384.9185.16.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Re: [PATCH 1/8] sunrpc: Factor out rpc_xprt freeing
Quoted 3 lines
If you are redoing the patch, then could you please just get rid of the above forward declaration for
xs_free_xprt, and instead just move the function itself further up the file?
Sure. Will do it soon.
Quoted 2 lines
Cheers
Trond
PATCH 2/8 sunrpc: Add net argument to svc_create_xprt
In reply to Pavel Emelyanov--- fs/lockd/svc.c | 2 +- fs/nfs/callback.c | 4 ++-- fs/nfsd/nfsctl.c | 4 ++-- fs/nfsd/nfssvc.c | 5 +++-- include/linux/sunrpc/svc_xprt.h | 4 ++-- net/sunrpc/svc_xprt.c | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-)
fs/lockd/svc.c +1 -1
@@ -206,7 +206,7 @@ static int create_lockd_listener(struct svc_serv *serv, const char *name, xprt =svc_find_xprt (serv, name, family,0 );if (xprt ==NULL ) -return svc_create_xprt (serv, name, family, port, +return svc_create_xprt (serv, name, &init_net, family, port,SVC_SOCK_DEFAULTS );svc_xprt_put (xprt);return 0 ;
fs/nfs/callback.c +2 -2
@@ -109,7 +109,7 @@ nfs4_callback_up(struct svc_serv *serv) {int ret; - ret =svc_create_xprt (serv,"tcp" ,PF_INET , + ret =svc_create_xprt (serv,"tcp" , &init_net,PF_INET , nfs_callback_set_tcpport,SVC_SOCK_ANONYMOUS );if (ret <=0 ) goto out_err;
@@ -117,7 +117,7 @@ nfs4_callback_up(struct svc_serv *serv)dprintk ("NFS: Callback listener port = %u (af %u)\n" , nfs_callback_tcpport,PF_INET ); - ret =svc_create_xprt (serv,"tcp" ,PF_INET6 , + ret =svc_create_xprt (serv,"tcp" , &init_net,PF_INET6 , nfs_callback_set_tcpport,SVC_SOCK_ANONYMOUS );if (ret >0 ) { nfs_callback_tcpport6 = ret;
fs/nfsd/nfsctl.c +2 -2
@@ -1015,12 +1015,12 @@ static ssize_t __write_ports_addxprt(char *buf)if (err !=0 )return err; - err =svc_create_xprt (nfsd_serv, transport, + err =svc_create_xprt (nfsd_serv, transport, &init_net,PF_INET , port,SVC_SOCK_ANONYMOUS );if (err <0 ) goto out_err; - err =svc_create_xprt (nfsd_serv, transport, + err =svc_create_xprt (nfsd_serv, transport, &init_net,PF_INET6 , port,SVC_SOCK_ANONYMOUS );if (err <0 && err != -EAFNOSUPPORT ) goto out_close;
fs/nfsd/nfssvc.c +3 -2
@@ -16,6 +16,7 @@#include <linux/lockd/bind.h> #include <linux/nfsacl.h> #include <linux/seq_file.h> +#include <net/net_namespace.h> #include "nfsd.h" #include "cache.h" #include "vfs.h"
@@ -186,12 +187,12 @@ static int nfsd_init_socks(int port)if (!list_empty (&nfsd_serv->sv_permsocks))return 0 ; - error =svc_create_xprt (nfsd_serv,"udp" ,PF_INET , port, + error =svc_create_xprt (nfsd_serv,"udp" , &init_net,PF_INET , port,SVC_SOCK_DEFAULTS );if (error <0 )return error; - error =svc_create_xprt (nfsd_serv,"tcp" ,PF_INET , port, + error =svc_create_xprt (nfsd_serv,"tcp" , &init_net,PF_INET , port,SVC_SOCK_DEFAULTS );if (error <0 )return error;
include/linux/sunrpc/svc_xprt.h +2 -2
@@ -74,8 +74,8 @@ int svc_reg_xprt_class(struct svc_xprt_class *);void svc_unreg_xprt_class (struct svc_xprt_class *);void svc_xprt_init (struct svc_xprt_class *,struct svc_xprt *,struct svc_serv *); -int svc_create_xprt (struct svc_serv *,const char *,const int , -const unsigned short ,int ); +int svc_create_xprt (struct svc_serv *,const char *,struct net *, +const int ,const unsigned short ,int );void svc_xprt_enqueue (struct svc_xprt *xprt);void svc_xprt_received (struct svc_xprt *);void svc_xprt_put (struct svc_xprt *xprt);
net/sunrpc/svc_xprt.c +2 -2
@@ -204,8 +204,8 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl, }int svc_create_xprt (struct svc_serv *serv,const char *xprt_name, -const int family,const unsigned short port, -int flags) +struct net *net,const int family, +const unsigned short port,int flags) {struct svc_xprt_class *xcl;
Signature · 1 line
1.5.5.6
PATCH 3/8 sunrpc: Pull net argument downto svc_create_socket
In reply to Pavel EmelyanovAfter this the socket creation in it knows the context.
--- include/linux/sunrpc/svc_xprt.h | 1 + net/sunrpc/svc_xprt.c | 5 +++-- net/sunrpc/svcsock.c | 10 +++++++--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-)
include/linux/sunrpc/svc_xprt.h +1 -0
@@ -12,6 +12,7 @@struct svc_xprt_ops {struct svc_xprt *(*xpo_create)(struct svc_serv *, +struct net *net,struct sockaddr *,int ,int );struct svc_xprt *(*xpo_accept)(struct svc_xprt *);
net/sunrpc/svc_xprt.c +3 -2
@@ -166,6 +166,7 @@ EXPORT_SYMBOL_GPL(svc_xprt_init);static struct svc_xprt *__svc_xpo_create (struct svc_xprt_class *xcl,struct svc_serv *serv, +struct net *net,const int family,const unsigned short port,int flags)
@@ -200,7 +201,7 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl,return ERR_PTR (-EAFNOSUPPORT ); } -return xcl->xcl_ops->xpo_create (serv, sap, len, flags); +return xcl->xcl_ops->xpo_create (serv, net, sap, len, flags); } int svc_create_xprt(struct svc_serv *serv, const char *xprt_name,
@@ -221,7 +222,7 @@ int svc_create_xprt(struct svc_serv *serv, const char *xprt_name, goto err;spin_unlock (&svc_xprt_class_lock); - newxprt =__svc_xpo_create (xcl, serv, family, port, flags); + newxprt =__svc_xpo_create (xcl, serv, net, family, port, flags);if (IS_ERR (newxprt)) {module_put (xcl->xcl_owner);return PTR_ERR (newxprt);
net/sunrpc/svcsock.c +7 -3
@@ -64,7 +64,8 @@ static void svc_tcp_sock_detach(struct svc_xprt *);static void svc_sock_free (struct svc_xprt *);static struct svc_xprt *svc_create_socket (struct svc_serv *,int , -struct sockaddr *,int ,int ); +struct net *,struct sockaddr *, +int ,int );#ifdef CONFIG_DEBUG_LOCK_ALLOC static struct lock_class_key svc_key[2 ];static struct lock_class_key svc_slock_key[2 ];
@@ -657,10 +658,11 @@ static struct svc_xprt *svc_udp_accept(struct svc_xprt *xprt) }static struct svc_xprt *svc_udp_create (struct svc_serv *serv, +struct net *net,struct sockaddr *sa,int salen,int flags) { -return svc_create_socket (serv,IPPROTO_UDP , sa, salen, flags); +return svc_create_socket (serv,IPPROTO_UDP , net, sa, salen, flags); }static struct svc_xprt_ops svc_udp_ops = {
@@ -1178,10 +1180,11 @@ static int svc_tcp_has_wspace(struct svc_xprt *xprt) }static struct svc_xprt *svc_tcp_create (struct svc_serv *serv, +struct net *net,struct sockaddr *sa,int salen,int flags) { -return svc_create_socket (serv,IPPROTO_TCP , sa, salen, flags); +return svc_create_socket (serv,IPPROTO_TCP , net, sa, salen, flags); }static struct svc_xprt_ops svc_tcp_ops = {
@@ -1385,6 +1388,7 @@ EXPORT_SYMBOL_GPL(svc_addsock);*/ static struct svc_xprt *svc_create_socket (struct svc_serv *serv,int protocol, +struct net *net,struct sockaddr *sin,int len,int flags) {
net/sunrpc/xprtrdma/svc_rdma_transport.c +2 -0
@@ -52,6 +52,7 @@#define RPCDBG_FACILITY RPCDBG_SVCXPRTstatic struct svc_xprt *svc_rdma_create (struct svc_serv *serv, +struct net *net,struct sockaddr *sa,int salen,int flags);static struct svc_xprt *svc_rdma_accept (struct svc_xprt *xprt);
@@ -670,6 +671,7 @@ static int rdma_cma_handler(struct rdma_cm_id *cma_id,* Create a listening RDMA service endpoint. */ static struct svc_xprt *svc_rdma_create (struct svc_serv *serv, +struct net *net,struct sockaddr *sa,int salen,int flags) {
Signature · 1 line
1.5.5.6
PATCH 4/8 sunrpc: Add net to rpc_create_args
In reply to Pavel Emelyanov--- fs/lockd/host.c | 1 + fs/lockd/mon.c | 1 + fs/nfs/client.c | 1 + fs/nfs/mount_clnt.c | 2 ++ fs/nfsd/nfs4callback.c | 1 + include/linux/sunrpc/clnt.h | 1 + net/sunrpc/rpcb_clnt.c | 2 ++ 7 files changed, 9 insertions(+), 0 deletions(-)
fs/lockd/host.c +1 -0
@@ -353,6 +353,7 @@ nlm_bind_host(struct nlm_host *host) .to_retries = 5U, };struct rpc_create_args args = { + .net = &init_net, .protocol = host->h_proto, .address =nlm_addr (host), .addrsize = host->h_addrlen,
fs/lockd/mon.c +1 -0
@@ -69,6 +69,7 @@ static struct rpc_clnt *nsm_create(void) .sin_addr.s_addr = htonl(INADDR_LOOPBACK), };struct rpc_create_args args = { + .net = &init_net, .protocol =XPRT_TRANSPORT_UDP , .address = (struct sockaddr *)&sin, .addrsize =sizeof (sin),
fs/nfs/client.c +1 -0
@@ -601,6 +601,7 @@ static int nfs_create_rpc_client(struct nfs_client *clp, {struct rpc_clnt *clnt =NULL ;struct rpc_create_args args = { + .net = &init_net, .protocol = clp->cl_proto, .address = (struct sockaddr *)&clp->cl_addr, .addrsize = clp->cl_addrlen,
fs/nfs/mount_clnt.c +2 -0
@@ -153,6 +153,7 @@ int nfs_mount(struct nfs_mount_request *info) .rpc_resp = &result, };struct rpc_create_args args = { + .net = &init_net, .protocol = info->protocol, .address = info->sap, .addrsize = info->salen,
@@ -224,6 +225,7 @@ void nfs_umount(const struct nfs_mount_request *info) .to_retries = 2, };struct rpc_create_args args = { + .net = &init_net, .protocol =IPPROTO_UDP , .address = info->sap, .addrsize = info->salen,
fs/nfsd/nfs4callback.c +1 -0
@@ -479,6 +479,7 @@ int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *cb) .to_retries = 0, };struct rpc_create_args args = { + .net = &init_net, .protocol =XPRT_TRANSPORT_TCP , .address = (struct sockaddr *) &cb->cb_addr, .addrsize = cb->cb_addrlen,
include/linux/sunrpc/clnt.h +1 -0
@@ -102,6 +102,7 @@ struct rpc_procinfo { #ifdef __KERNEL__ struct rpc_create_args { + struct net *net; int protocol; struct sockaddr *address; size_t addrsize;
net/sunrpc/rpcb_clnt.c +2 -0
@@ -177,6 +177,7 @@ static DEFINE_MUTEX(rpcb_create_local_mutex);static int rpcb_create_local (void ) {struct rpc_create_args args = { + .net = &init_net, .protocol =XPRT_TRANSPORT_TCP , .address = (struct sockaddr *)&rpcb_inaddr_loopback, .addrsize =sizeof (rpcb_inaddr_loopback),
@@ -228,6 +229,7 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, size_t salen, int proto, u32 version) { struct rpc_create_args args = { + .net = &init_net, .protocol = proto, .address = srvaddr, .addrsize = salen,
Signature · 1 line
1.5.5.6
PATCH 5/8 sunrpc: Add net to xprt_create
In reply to Pavel Emelyanov--- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/clnt.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
include/linux/sunrpc/xprt.h +1 -0
@@ -249,6 +249,7 @@ static inline int bc_prealloc(struct rpc_rqst *req)struct xprt_create {int ident;/* XPRT_TRANSPORT identifier */ +struct net * net;struct sockaddr * srcaddr;/* optional local address */ struct sockaddr * dstaddr;/* remote peer address */ size_t addrlen;
net/sunrpc/clnt.c +1 -0
@@ -284,6 +284,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)struct rpc_xprt *xprt;struct rpc_clnt *clnt;struct xprt_create xprtargs = { + .net = args->net, .ident = args->protocol, .srcaddr = args->saddress, .dstaddr = args->address,
Signature · 1 line
1.5.5.6
PATCH 6/8 sunrpc: Tag rpc_xprt with net
In reply to Pavel EmelyanovThe net is known from the xprt_create and this tagging will also give us the context in the connection workers where real sockets are created.
--- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/xprtsock.c | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
include/linux/sunrpc/xprt.h +1 -0
@@ -224,6 +224,7 @@ struct rpc_xprt { bklog_u;/* backlog queue utilization */ } stat; +struct net *xprt_net;const char *address_strings[RPC_DISPLAY_MAX ]; };
net/sunrpc/xprtsock.c +2 -0
@@ -2296,11 +2296,13 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args,if (args->srcaddr)memcpy (&new->srcaddr, args->srcaddr, args->addrlen); + xprt->xprt_net =get_net (args->net);return xprt; }static void xs_free_xprt (struct rpc_xprt *xprt) { +put_net (xprt->xprt_net);kfree (xprt->slot);kfree (xprt); }
Signature · 1 line
1.5.5.6
PATCH 7/8 net: Export __sock_create
In reply to Pavel EmelyanovCan we can do it not through the Dave's tree?
--- include/linux/net.h | 2 ++ net/socket.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletions(-)
include/linux/net.h +2 -0
@@ -229,6 +229,8 @@ enum {extern int sock_wake_async (struct socket *sk,int how,int band);extern int sock_register (const struct net_proto_family *fam);extern void sock_unregister (int family); +extern int __sock_create (struct net *net,int family,int type,int proto, +struct socket **res,int kern);extern int sock_create (int family,int type,int proto,struct socket **res); extern int sock_create_kern(int family, int type, int proto,
net/socket.c +2 -1
@@ -1144,7 +1144,7 @@ call_kill: }EXPORT_SYMBOL (sock_wake_async); -static int __sock_create (struct net *net,int family,int type,int protocol, +int __sock_create (struct net *net,int family,int type,int protocol,struct socket **res,int kern) {int err;
@@ -1256,6 +1256,7 @@ out_release:rcu_read_unlock (); goto out_sock_release; } +EXPORT_SYMBOL (__sock_create);int sock_create (int family,int type,int protocol,struct socket **res) {
Signature · 1 line
1.5.5.6
Re: [PATCH 7/8] net: Export __sock_create
Quoted 1 line · Pavel Emelyanov
Can we can do it not through the Dave's tree?
I think we will still need Dave's approval for this. Either an Ack or a signed-off-by. Linus will very likely yell at us and refuse to take the patch if we don't.
Cheers
Trond
Quoted 40 lines
Signed-off-by Pavel Emelyanov <[email protected]>--- include/linux/net.h | 2 ++ net/socket.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletions(-)include/linux/net.h +2
-0@@ -229,6 +229,8 @@ enum {extern int sock_wake_async (struct socket *sk,int how,int band);extern int sock_register (const struct net_proto_family *fam);extern void sock_unregister (int family); +extern int __sock_create (struct net *net,int family,int type,int proto, +struct socket **res,int kern);extern int sock_create (int family,int type,int proto,struct socket **res); extern int sock_create_kern(int family, int type, int proto,net/socket.c +2
-1@@ -1144,7 +1144,7 @@ call_kill: }EXPORT_SYMBOL (sock_wake_async); -static int __sock_create (struct net *net,int family,int type,int protocol, +int __sock_create (struct net *net,int family,int type,int protocol,struct socket **res,int kern) {int err;@@ -1256,6 +1256,7 @@ out_release:rcu_read_unlock (); goto out_sock_release; } +EXPORT_SYMBOL (__sock_create);int sock_create (int family,int type,int protocol,struct socket **res) {
Re: [PATCH 7/8] net: Export __sock_create
Quoted 6 lines · Trond Myklebust
Quoted 1 line · Pavel Emelyanov
Can we can do it not through the Dave's tree?
I think we will still need Dave's approval for this. Either an Ack or a signed-off-by. Linus will very likely yell at us and refuse to take the patch if we don't.
OK, I then put Dave in Cc.
And a small background of the patch - I'm trying to make sunrpc layer work in net namespaces and in order to do this I need to turn existing calls to sock_create_kern() into __sock_create() to specify the net namespace the socket are to be created in.
Dave, can we go on with this, please? :)
Quoted 43 lines
Cheers
TrondQuoted 40 lines
Signed-off-by Pavel Emelyanov <[email protected]>--- include/linux/net.h | 2 ++ net/socket.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletions(-)include/linux/net.h +2
-0@@ -229,6 +229,8 @@ enum {extern int sock_wake_async (struct socket *sk,int how,int band);extern int sock_register (const struct net_proto_family *fam);extern void sock_unregister (int family); +extern int __sock_create (struct net *net,int family,int type,int proto, +struct socket **res,int kern);extern int sock_create (int family,int type,int proto,struct socket **res); extern int sock_create_kern(int family, int type, int proto,net/socket.c +2
-1@@ -1144,7 +1144,7 @@ call_kill: }EXPORT_SYMBOL (sock_wake_async); -static int __sock_create (struct net *net,int family,int type,int protocol, +int __sock_create (struct net *net,int family,int type,int protocol,struct socket **res,int kern) {int err;@@ -1256,6 +1256,7 @@ out_release:rcu_read_unlock (); goto out_sock_release; } +EXPORT_SYMBOL (__sock_create);int sock_create (int family,int type,int protocol,struct socket **res) {
Re: [PATCH 7/8] net: Export __sock_create
From: Pavel Emelyanov <[email protected]>
Date: Mon, 27 Sep 2010 17:41:23 +0400
Quoted 8 lines · Trond Myklebust
Quoted 6 lines · Pavel Emelyanov
Quoted 1 line
Can we can do it not through the Dave's tree?
I think we will still need Dave's approval for this. Either an Ack or a signed-off-by. Linus will very likely yell at us and refuse to take the patch if we don't.
Quoted 8 lines
OK, I then put Dave in Cc.
And a small background of the patch - I'm trying to make sunrpc layer work in net namespaces and in order to do this I need to turn existing calls to
sock_create_kern()into__sock_create()to specify the net namespace the socket are to be created in.Dave, can we go on with this, please? :)
This is fine:
PATCH 8/8 sunrpc: Create sockets in net namespaces
In reply to Pavel EmelyanovThe context is already known in all the sock_create callers.
--- net/sunrpc/svcsock.c | 2 +- net/sunrpc/xprtsock.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
net/sunrpc/svcsock.c +1 -1
@@ -1425,7 +1425,7 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv,return ERR_PTR (-EINVAL ); } - error =sock_create_kern (family, type, protocol, &sock); + error =__sock_create (net, family, type, protocol, &sock,1 );if (error <0 )return ERR_PTR (error);
net/sunrpc/xprtsock.c +4 -4
@@ -1682,7 +1682,7 @@ static void xs_udp_connect_worker4(struct work_struct *work)/* Start by resetting any existing state */ xs_reset_transport (transport); - err =sock_create_kern (PF_INET ,SOCK_DGRAM ,IPPROTO_UDP , &sock); + err =__sock_create (xprt->xprt_net,PF_INET ,SOCK_DGRAM ,IPPROTO_UDP , &sock,1 );if (err <0 ) {dprintk ("RPC: can't create UDP transport socket (%d).\n" , -err); goto out;
@@ -1727,7 +1727,7 @@ static void xs_udp_connect_worker6(struct work_struct *work)/* Start by resetting any existing state */ xs_reset_transport (transport); - err =sock_create_kern (PF_INET6 ,SOCK_DGRAM ,IPPROTO_UDP , &sock); + err =__sock_create (xprt->xprt_net,PF_INET6 ,SOCK_DGRAM ,IPPROTO_UDP , &sock,1 );if (err <0 ) {dprintk ("RPC: can't create UDP transport socket (%d).\n" , -err); goto out;
@@ -1933,7 +1933,7 @@ static struct socket *xs_create_tcp_sock4(struct rpc_xprt *xprt,int err;/* start from scratch */ - err =sock_create_kern (PF_INET ,SOCK_STREAM ,IPPROTO_TCP , &sock); + err =__sock_create (xprt->xprt_net,PF_INET ,SOCK_STREAM ,IPPROTO_TCP , &sock,1 );if (err <0 ) {dprintk ("RPC: can't create TCP transport socket (%d).\n" , -err);
@@ -1972,7 +1972,7 @@ static struct socket *xs_create_tcp_sock6(struct rpc_xprt *xprt,int err;/* start from scratch */ - err =sock_create_kern (PF_INET6 ,SOCK_STREAM ,IPPROTO_TCP , &sock); + err =__sock_create (xprt->xprt_net,PF_INET6 ,SOCK_STREAM ,IPPROTO_TCP , &sock,1 );if (err <0 ) {dprintk ("RPC: can't create TCP transport socket (%d).\n" , -err);
Signature · 1 line
1.5.5.6
Quoted 11 lines · Pavel Emelyanov
Hi!
This set implements pulling the net * argument down to the existing
sock_create_kerncalls in the sunrpc layer and creating the sockets in the given net.Patch #7 opens the
__sock_createfor public and I hope we can do it not in the Dave's tree :)Applies to
git://linux-nfs.org/~bfields/linux.gitnfsd-next after theip_map_cachevirtualization patch set I sent before.
They look fine to me.
--b.