Support rpcbind v4 in kernel's RPC server
Subsystems (4)
cover Support rpcbind v4 in kernel's RPC server
Hi Bruce, Trond-
First set of patches for 2.6.28. I hope I've addressed all review comments on these.
And btw, I posted the V6ONLY patch on netdev; received no objections.
---
Chuck Lever (8):
SUNRPC: Add kernel build option to disable server-side use of rpcbind v3/v4
SUNRPC: Use new rpcb_v4_register() interface in svc_register()
SUNRPC: Refactor svc_register()
SUNRPC: Split portmap unregister API into separate function
SUNRPC: Use proper INADDR_ANY when setting up RPC services on IPv6
SUNRPC: Set V6ONLY socket option for RPC listener sockets
SUNRPC: Add address family field to svc_serv data structure
NFS: nfs_parsed_mount_options can use unsigned int
fs/Kconfig | 22 +++++ fs/lockd/svc.c | 2 fs/nfs/callback.c | 3 - fs/nfs/internal.h | 8 +- fs/nfsd/nfssvc.c | 3 - include/linux/sunrpc/svc.h | 15 ++- net/sunrpc/svc.c | 197 ++++++++++++++++++++++++++++++++++++++------ net/sunrpc/svc_xprt.c | 37 +++++++- net/sunrpc/svcsock.c | 13 +++ 9 files changed, 252 insertions(+), 48 deletions(-)
Signature · 1 line
Chuck Lever
A message that is not in the archive (sent off-list or not yet received): 20080813223653.13068.9467.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org
PATCH 1/8 NFS: nfs_parsed_mount_options can use unsigned int
Eliminate mixed sign comparisons in nfs_compare_remount_options().
---
fs/nfs/internal.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
fs/nfs/internal.h +4 -4
@@ -32,11 +32,11 @@ struct nfs_clone_mount {*/ struct nfs_parsed_mount_data {int flags; -int rsize, wsize; -int timeo, retrans; -int acregmin, acregmax, +unsigned int rsize, wsize; +unsigned int timeo, retrans; +unsigned int acregmin, acregmax, acdirmin, acdirmax; -int namlen; +unsigned int namlen;unsigned int bsize;unsigned int auth_flavor_len;rpc_authflavor_t auth_flavors[1 ];
A message that is not in the archive (sent off-list or not yet received): 20080813223937.13068.47032.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org
Re: [PATCH 1/8] NFS: nfs_parsed_mount_options can use unsigned int
Quoted 3 lines · Chuck Lever
Eliminate mixed sign comparisons in
nfs_compare_remount_options().Signed-off-by Chuck Lever <[email protected]>
We really don't care about the sign, since we're always going to be comparing for equality in nfs_compare_remount_options().
Cheers
Trond
Quoted 26 lines
---
fs/nfs/internal.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)fs/nfs/internal.h +4
-4@@ -32,11 +32,11 @@ struct nfs_clone_mount {*/ struct nfs_parsed_mount_data {int flags; -int rsize, wsize; -int timeo, retrans; -int acregmin, acregmax, +unsigned int rsize, wsize; +unsigned int timeo, retrans; +unsigned int acregmin, acregmax, acdirmin, acdirmax; -int namlen; +unsigned int namlen;unsigned int bsize;unsigned int auth_flavor_len;rpc_authflavor_t auth_flavors[1 ];
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
PATCH 2/8 SUNRPC: Add address family field to svc_serv data structure
In reply to a message not in the archiveIntroduce and initialize an address family field in the svc_serv structure.
This field will determine what address family to use for the service's listener sockets and which address family is advertised via the local rpcbind daemon.
---
fs/lockd/svc.c | 2 +- fs/nfs/callback.c | 3 ++- fs/nfsd/nfssvc.c | 3 ++- include/linux/sunrpc/svc.h | 11 +++++++---- net/sunrpc/svc.c | 12 +++++++----- 5 files changed, 19 insertions(+), 12 deletions(-)
fs/lockd/svc.c +1 -1
@@ -266,7 +266,7 @@ lockd_up(int proto) /* Maybe add a 'family' option when IPv6 is supported ?? */ "lockd_up: no pid, %d users??\n", nlmsvc_users); error = -ENOMEM ; - serv =svc_create (&nlmsvc_program,LOCKD_BUFSIZE ,NULL ); + serv =svc_create (&nlmsvc_program,LOCKD_BUFSIZE ,AF_INET ,NULL );if (!serv) {printk (KERN_WARNING "lockd_up: create service failed\n" ); goto out;
fs/nfs/callback.c +2 -1
@@ -105,7 +105,8 @@ int nfs_callback_up(void)mutex_lock (&nfs_callback_mutex);if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) goto out; - serv =svc_create (&nfs4_callback_program,NFS4_CALLBACK_BUFSIZE ,NULL ); + serv =svc_create (&nfs4_callback_program,NFS4_CALLBACK_BUFSIZE , +AF_INET ,NULL ); ret = -ENOMEM ;if (!serv) goto out_err;
fs/nfsd/nfssvc.c +2 -1
@@ -229,7 +229,8 @@ int nfsd_create_serv(void)atomic_set (&nfsd_busy,0 ); nfsd_serv =svc_create_pooled (&nfsd_program, nfsd_max_blksize, - nfsd_last_thread, nfsd,THIS_MODULE ); +AF_INET , nfsd_last_thread, + nfsd,THIS_MODULE );if (nfsd_serv ==NULL ) err = -ENOMEM ;
include/linux/sunrpc/svc.h +7 -4
@@ -66,6 +66,7 @@ struct svc_serv {struct list_head sv_tempsocks;/* all temporary sockets */ int sv_tmpcnt;/* count of temporary sockets */ struct timer_list sv_temptimer;/* timer for aging temporary sockets */ +sa_family_t sv_family;/* listener's address family */ char * sv_name;/* service name */
@@ -381,14 +382,16 @@ struct svc_procedure {/* * Function prototypes. */ -struct svc_serv *svc_create (struct svc_program *,unsigned int , -void (*shutdown)(struct svc_serv *)); +struct svc_serv *svc_create (struct svc_program *,unsigned int , +const sa_family_t , +void (*shutdown)(struct svc_serv *));struct svc_rqst *svc_prepare_thread (struct svc_serv *serv,struct svc_pool *pool);void svc_exit_thread (struct svc_rqst *);struct svc_serv *svc_create_pooled (struct svc_program *,unsigned int , -void (*shutdown)(struct svc_serv *),svc_thread_fn , -struct module *); +const sa_family_t , +void (*shutdown)(struct svc_serv *), +svc_thread_fn ,struct module *);int svc_set_num_threads (struct svc_serv *,struct svc_pool *,int );void svc_destroy (struct svc_serv *);int svc_process (struct svc_rqst *);
net/sunrpc/svc.c +7 -5
@@ -357,7 +357,7 @@ svc_pool_for_cpu(struct svc_serv *serv, int cpu)*/ static struct svc_serv *__svc_create (struct svc_program *prog,unsigned int bufsize,int npools, -void (*shutdown)(struct svc_serv *serv)) +const sa_family_t family,void (*shutdown)(struct svc_serv *serv)) {struct svc_serv *serv;unsigned int vers;
@@ -366,6 +366,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,if (!(serv =kzalloc (sizeof (*serv),GFP_KERNEL )))return NULL ; + serv->sv_family = family; serv->sv_name = prog->pg_name; serv->sv_program = prog; serv->sv_nrthreads =1 ;
@@ -425,21 +426,22 @@ __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)) +const sa_family_t family,void (*shutdown)(struct svc_serv *serv)) { -return __svc_create (prog, bufsize,/*npools*/ 1 , shutdown); +return __svc_create (prog, bufsize,/*npools*/ 1 , family, shutdown); }EXPORT_SYMBOL (svc_create);struct svc_serv *svc_create_pooled (struct svc_program *prog,unsigned int bufsize, -void (*shutdown)(struct svc_serv *serv), +const sa_family_t family, +void (*shutdown)(struct svc_serv *serv),svc_thread_fn func,struct module *mod) {struct svc_serv *serv;unsigned int npools =svc_pool_map_get (); - serv =__svc_create (prog, bufsize, npools, shutdown); + serv =__svc_create (prog, bufsize, npools, family, shutdown);if (serv !=NULL ) { serv->sv_function = func;
PATCH 3/8 SUNRPC: Set V6ONLY socket option for RPC listener sockets
In reply to a message not in the archiveMy plan is to use an AF_INET listener on systems that support only IPv4, and an AF_INET6 listener on systems that can support IPv6. Incoming IPv4 packets will be posted to an AF_INET6 listener with a mapped IPv4 address.
Max Matveev <[email protected]> says:
Creating a single listener can be dangerous - if net.ipv6.bindv6only is enabled then it's possible to create another listener in v4 namespace on the same port and steal the traffic from the "unifed" listener. You need to disable V6ONLY explicitly via a sockopt to stop that.
Set appropriate socket option on RPC server listener sockets to prevent this.
---
net/sunrpc/svcsock.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
net/sunrpc/svcsock.c +13 -0
@@ -1114,6 +1114,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,struct svc_sock *svsk;struct sock *inet;int pmap_register = !(flags &SVC_SOCK_ANONYMOUS ); +int val;dprintk ("svc: svc_setup_socket %p\n" , sock);if (!(svsk =kzalloc (sizeof (*svsk),GFP_KERNEL ))) {
@@ -1146,6 +1147,18 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,else svc_tcp_init (svsk, serv); +/* +* We start one listener per sv_serv. We want AF_INET +* requests to be automatically shunted to our AF_INET6 +* listener using a mapped IPv4 address. Make sure +* no-one starts an equivalent IPv4 listener, which +* would steal our incoming connections. +*/ + val =0 ; +if (serv->sv_family ==AF_INET6 ) +kernel_setsockopt (sock,SOL_IPV6 ,IPV6_V6ONLY , + (char *)&val,sizeof (val)); +dprintk ("svc: svc_setup_socket created %p (inet %p)\n" , svsk, svsk->sk_sk);
A message that is not in the archive (sent off-list or not yet received): 20080813223953.13068.97829.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
Quoted 4 lines · Chuck Lever
My plan is to use an
AF_INETlistener on systems that support only IPv4, and anAF_INET6listener on systems that can support IPv6. Incoming IPv4 packets will be posted to anAF_INET6listener with a mapped IPv4 address.
How will the nfs server choose whether to use AF_INET or AF_INET6? Will we need some new user interface?
--b.
Quoted 49 lines
Max Matveev <[email protected]> says:
Creating a single listener can be dangerous - if net.ipv6.bindv6only is enabled then it's possible to create another listener in v4 namespace on the same port and steal the traffic from the "unifed" listener. You need to disable V6ONLY explicitly via a sockopt to stop that.Set appropriate socket option on RPC server listener sockets to prevent this.
Signed-off-by Chuck Lever <[email protected]>---
net/sunrpc/svcsock.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)net/sunrpc/svcsock.c +13
-0@@ -1114,6 +1114,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,struct svc_sock *svsk;struct sock *inet;int pmap_register = !(flags &SVC_SOCK_ANONYMOUS ); +int val;dprintk ("svc: svc_setup_socket %p\n" , sock);if (!(svsk =kzalloc (sizeof (*svsk),GFP_KERNEL ))) {@@ -1146,6 +1147,18 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,else svc_tcp_init (svsk, serv); +/* +* We start one listener per sv_serv. We want AF_INET +* requests to be automatically shunted to our AF_INET6 +* listener using a mapped IPv4 address. Make sure +* no-one starts an equivalent IPv4 listener, which +* would steal our incoming connections. +*/ + val =0 ; +if (serv->sv_family ==AF_INET6 ) +kernel_setsockopt (sock,SOL_IPV6 ,IPV6_V6ONLY , + (char *)&val,sizeof (val)); +dprintk ("svc: svc_setup_socket created %p (inet %p)\n" , svsk, svsk->sk_sk);
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
Quoted 8 lines · J. Bruce Fields
Quoted 4 lines · Chuck Lever
My plan is to use an
AF_INETlistener on systems that support only IPv4, and anAF_INET6listener on systems that can support IPv6. Incoming IPv4 packets will be posted to anAF_INET6listener with a mapped IPv4 address.How will the nfs server choose whether to use
AF_INETorAF_INET6? Will we need some new user interface?
[PATCH 2/8] changes svc_create() to take an additional argument which specifies the listener's address family. This value is stored in svc_serv.
Quoted 35 lines
Quoted 35 lines
Max Matveev <[email protected]> says:
Creating a single listener can be dangerous - if net.ipv6.bindv6only is enabled then it's possible to create another listener in v4 namespace on the same port and steal the traffic from the "unifed" listener. You need to disable V6ONLY explicitly via a sockopt to
stop
that.Set appropriate socket option on RPC server listener sockets to prevent this.
Signed-off-by Chuck Lever <[email protected]>---
net/sunrpc/svcsock.c| 13 +++++++++++++1 files changed, 13 insertions(+), 0 deletions(-)net/sunrpc/svcsock.c +1
-0@@ -1114,6 +1114,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, struct svc_sock *svsk;struct sock *inet;int pmap_register = !(flags &SVC_SOCK_ANONYMOUS ); +int val;dprintk ("svc: svc_setup_socket %p\n" , sock);if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) {net/sunrpc/svcsock.c +0
-0@@ -1146,6 +1147,18 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, else svc_tcp_init(svsk, serv);
Quoted 16 lines
Quoted 6 lines
net/sunrpc/svcsock.c +4
-0+/* +* We start one listener per sv_serv. We want AF_INET +* requests to be automatically shunted to our AF_INET6 +* listener using a mapped IPv4 address. Make sure net/sunrpc/svcsock.c static struct svc_sock *svc_setup_socket(struct svc_serv *serv, · line 1163
Quoted 10 lines
net/sunrpc/svcsock.c +8
-0+* no-one starts an equivalent IPv4 listener, which +* would steal our incoming connections. +*/ + val =0 ; +if (serv->sv_family ==AF_INET6 ) +kernel_setsockopt (sock,SOL_IPV6 ,IPV6_V6ONLY , + (char *)&val,sizeof (val)); +dprintk ("svc: svc_setup_socket created %p (inet %p)\n" , svsk, svsk->sk_sk);
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
Quoted 9 lines · Chuck Lever
Quoted 8 lines · J. Bruce Fields
Quoted 6 lines · Chuck Lever
My plan is to use an
AF_INETlistener on systems that support only IPv4,
and anAF_INET6listener on systems that can support IPv6. Incoming IPv4 packets will be posted to anAF_INET6listener with a mapped IPv4
address.
Quoted 7 lines
Quoted 3 lines
How will the nfs server choose whether to use
AF_INETorAF_INET6? Will
we need some new user interface?[PATCH 2/8] changes
svc_create()to take an additional argument which specifies the listener's address family. This value is stored insvc_serv.
Right, but I'm asking about the nfsd server, not the rpc server, and the user interface, not the in-kernel interface: so suppose I'm a server administrator, and want my nfs server to listen for ipv6 connections. Will there be some switch I'll need to flip?
--b.
Quoted 60 lines
Quoted 37 lines
Quoted 37 lines
Max Matveev <[email protected]> says:
Creating a single listener can be dangerous - if net.ipv6.bindv6only is enabled then it's possible to create another listener in v4 namespace on the same port and steal the traffic from the "unifed" listener. You need to disable V6ONLY explicitly via a sockopt to
stop
that.Set appropriate socket option on RPC server listener sockets to prevent
this.Signed-off-by Chuck Lever <[email protected]>---
net/sunrpc/svcsock.c| 13 +++++++++++++1 files changed, 13 insertions(+), 0 deletions(-)net/sunrpc/svcsock.c +1
-0@@ -1114,6 +1114,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, struct svc_sock *svsk;struct sock *inet;int pmap_register = !(flags &SVC_SOCK_ANONYMOUS ); +int val;dprintk ("svc: svc_setup_socket %p\n" , sock);if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) {net/sunrpc/svcsock.c +0
-0@@ -1146,6 +1147,18 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, else svc_tcp_init(svsk, serv);Quoted 16 lines
Quoted 6 lines
net/sunrpc/svcsock.c +4
-0+/* +* We start one listener per sv_serv. We want AF_INET +* requests to be automatically shunted to our AF_INET6 +* listener using a mapped IPv4 address. Make sure net/sunrpc/svcsock.c static struct svc_sock *svc_setup_socket(struct svc_serv *serv, · line 1163
Quoted 10 lines
net/sunrpc/svcsock.c +8
-0+* no-one starts an equivalent IPv4 listener, which +* would steal our incoming connections. +*/ + val =0 ; +if (serv->sv_family ==AF_INET6 ) +kernel_setsockopt (sock,SOL_IPV6 ,IPV6_V6ONLY , + (char *)&val,sizeof (val)); +dprintk ("svc: svc_setup_socket created %p (inet %p)\n" , svsk, svsk->sk_sk);--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
Quoted 14 lines · J. Bruce Fields
Quoted 13 lines · Chuck Lever
Quoted 11 lines · J. Bruce Fields
Quoted 6 lines · Chuck Lever
My plan is to use an
AF_INETlistener on systems that support only IPv4,
and anAF_INET6listener on systems that can support IPv6. Incoming IPv4 packets will be posted to anAF_INET6listener with a mapped IPv4
address.How will the nfs server choose whether to use
AF_INETorAF_INET6? Will
we need some new user interface?
Quoted 6 lines
Quoted 3 lines
[PATCH 2/8] changes
svc_create()to take an additional argument which specifies the listener's address family. This value is stored insvc_serv.Right, but I'm asking about the nfsd server, not the rpc server, and the user interface, not the in-kernel interface:
Ah. That wasn't clear before.
Quoted 3 lines
so suppose I'm a server
administrator, and want my nfs server to listen for ipv6 connections. Will there be some switch I'll need to flip?
I don't know how that UI will be designed. So far, I've focused only on the pieces needed for client side IPv6 support. I figured the Bull team had something figured out for the server, and didn't think any more about it.
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Max Matveev <[email protected]> says:
Creating a single listener can be dangerous - if net.ipv6.bindv6only is enabled then it's possible to create another listener in v4 namespace on the same port and steal the traffic from the "unifed" listener. You need to disable V6ONLY explicitly via a sockopt to stop
that.Set appropriate socket option on RPC server listener sockets to prevent
this.Signed-off-by Chuck Lever <[email protected]>---
net/sunrpc/svcsock.c| 13 +++++++++++++1 files changed, 13 insertions(+), 0 deletions(-)net/sunrpc/svcsock.c +1
-0@@ -1114,6 +1114,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, struct svc_sock *svsk;struct sock *inet;int pmap_register = !(flags &SVC_SOCK_ANONYMOUS ); +int val;dprintk ("svc: svc_setup_socket %p\n" , sock);if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) {net/sunrpc/svcsock.c +12
-0@@ -1146,6 +1147,18 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, else svc_tcp_init(svsk, serv); +/* +* We start one listener per sv_serv. We want AF_INET +* requests to be automatically shunted to our AF_INET6 +* listener using a mapped IPv4 address. Make sure +* no-one starts an equivalent IPv4 listener, which +* would steal our incoming connections. +*/ + val =0 ; +if (serv->sv_family ==AF_INET6 ) +kernel_setsockopt (sock,SOL_IPV6 ,IPV6_V6ONLY , + (char *)&val,sizeof (val)); +dprintk ("svc: svc_setup_socket created %p (inet %p)\n" , svsk, svsk->sk_sk);
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
Quoted 25 lines · Chuck Lever
Quoted 14 lines · J. Bruce Fields
Quoted 13 lines · Chuck Lever
Quoted 11 lines · J. Bruce Fields
Quoted 6 lines · Chuck Lever
My plan is to use an
AF_INETlistener on systems that support only IPv4,
and anAF_INET6listener on systems that can support IPv6. Incoming IPv4 packets will be posted to anAF_INET6listener with a mapped IPv4
address.How will the nfs server choose whether to use
AF_INETorAF_INET6? Will
we need some new user interface?Quoted 7 lines
Quoted 3 lines
[PATCH 2/8] changes
svc_create()to take an additional argument which specifies the listener's address family. This value is stored insvc_serv.Right, but I'm asking about the nfsd server, not the rpc server, and the
user interface, not the in-kernel interface:Ah. That wasn't clear before.
Quoted 8 lines
Quoted 3 lines
so suppose I'm a server
administrator, and want my nfs server to listen for ipv6 connections. Will there be some switch I'll need to flip?I don't know how that UI will be designed. So far, I've focused only on the pieces needed for client side IPv6 support. I figured the Bull team had something figured out for the server, and didn't think any more about it.
I've forgotten who was working on that; Aurelien Charbon?
--b.
Quoted 72 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Max Matveev <[email protected]> says:
Creating a single listener can be dangerous - if net.ipv6.bindv6only
is enabled then it's possible to create another listener in v4 namespace on the same port and steal the traffic from the "unifed" listener. You need to disable V6ONLY explicitly via a sockopt to stop
that.Set appropriate socket option on RPC server listener sockets to prevent
this.Signed-off-by Chuck Lever <[email protected]>---
net/sunrpc/svcsock.c| 13 +++++++++++++1 files changed, 13 insertions(+), 0 deletions(-)net/sunrpc/svcsock.c +1
-0@@ -1114,6 +1114,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, struct svc_sock *svsk;struct sock *inet;int pmap_register = !(flags &SVC_SOCK_ANONYMOUS ); +int val;dprintk ("svc: svc_setup_socket %p\n" , sock);if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) {net/sunrpc/svcsock.c +12
-0@@ -1146,6 +1147,18 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, else svc_tcp_init(svsk, serv); +/* +* We start one listener per sv_serv. We want AF_INET +* requests to be automatically shunted to our AF_INET6 +* listener using a mapped IPv4 address. Make sure +* no-one starts an equivalent IPv4 listener, which +* would steal our incoming connections. +*/ + val =0 ; +if (serv->sv_family ==AF_INET6 ) +kernel_setsockopt (sock,SOL_IPV6 ,IPV6_V6ONLY , + (char *)&val,sizeof (val)); +dprintk ("svc: svc_setup_socket created %p (inet %p)\n" , svsk, svsk->sk_sk);Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com--
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
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
J. Bruce Fields a =E9crit :
Quoted 16 lines · Chuck Lever
=20
Quoted 13 lines · J. Bruce Fields
=20
Quoted 10 lines · Chuck Lever
=20Quoted 7 lines · J. Bruce Fields
=20Quoted 4 lines · Chuck Lever
=20Quoted 1 line
My plan is to use an
AF_INETlistener on systems that support onl=
y
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
IPv4,
and anAF_INET6listener on systems that can support IPv6. Incomi=
ng
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
IPv4 packets will be posted to an
AF_INET6listener with a mapped IPv4
address.=20How will the nfs server choose whether to use
AF_INETorAF_INET6? Will
we need some new user interface?=20[PATCH 2/8] changes
svc_create()to take an additional argument whi=
ch
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
specifies the listener's address family. This value is stored in
svc_serv.=20Right, but I'm asking about the nfsd server, not the rpc server, and=
=20
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
the
user interface, not the in-kernel interface:=20Ah. That wasn't clear before.
=20
Quoted 2 lines
so suppose I'm a server
administrator, and want my nfs server to listen for ipv6 connections=
=2E
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Will there be some switch I'll need to flip?
=20I don't know how that UI will be designed. So far, I've focused only=
on=20
Quoted 1 line
Quoted 1 line
the pieces needed for client side IPv6 support. I figured the Bull t=
eam=20
Quoted 1 line
Quoted 1 line
had something figured out for the server, and didn't think any more a=
bout=20
Quoted 7 lines
Quoted 3 lines
it.
=20I've forgotten who was working on that; Aurelien Charbon? =20
Hi,
Sorry for not answering before, I am back from vacation. Aurelien is no longer directly working on that even he can answer any=20 questions.
It is me now who tess NFSV4 IPV6 with the patches Aurelien delivered=20
to Bruce a few months ago.
But since Chuck has delivered several new patches which affect the NFS server side about the way nfsd can listen for ipv6 connections.
To have NFSV4 IPV6 working with those changes, what it would be nice=20
to have a complete list
on what are the changes.
Is there now a complete release for which we can test those latest=20 changes? If not which one will be?
Are there any other changes still planned?
Best Regards
Quoted 9 lines
--b.
=20
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Max Matveev <[email protected]> says:
Creating a single listener can be dangerous - if =20 net.ipv6.bindv6only
is enabled then it's possible to create another listener in v4 namespace on the same port and steal the traffic from the "unifed=
"
Quoted 58 lines
Quoted 58 lines
Quoted 58 lines
Quoted 58 lines
Quoted 48 lines
Quoted 48 lines
listener. You need to disable V6ONLY explicitly via a sockopt to stop
that.Set appropriate socket option on RPC server listener sockets to prevent
this.Signed-off-by Chuck Lever <[email protected]>---
net/sunrpc/svcsock.c| 13 +++++++++++++1 files changed, 13 insertions(+), 0 deletions(-)net/sunrpc/svcsock.c +1
-0@@ -1114,6 +1114,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, struct svc_sock *svsk;struct sock *inet; int pmap_register =3D !(flags & SVC_SOCK_ANONYMOUS); +int val;dprintk ("svc: svc_setup_socket %p\n" , sock);if (!(svsk =3D kzalloc(sizeof(*svsk), GFP_KERNEL))) {net/sunrpc/svcsock.c +12
-0@@ -1146,6 +1147,18 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, else svc_tcp_init(svsk, serv); +/* +* We start one listener per sv_serv. We want AF_INET +* requests to be automatically shunted to our AF_INET6 +* listener using a mapped IPv4 address. Make sure +* no-one starts an equivalent IPv4 listener, which +* would steal our incoming connections. +*/ + val =3D 0; + if (serv->sv_family =3D=3D AF_INET6) +kernel_setsockopt (sock,SOL_IPV6 ,IPV6_V6ONLY , + (char *)&val,sizeof (val)); +dprintk ("svc: svc_setup_socket created %p (inet %p)\n" , svsk, svsk->sk_sk);Quoted 2 lines
Quoted 2 lines
=20--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com=20
Quoted 8 lines
Quoted 8 lines
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" =
in
Quoted 6 lines
Quoted 4 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
=20--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" i=
n
Quoted 6 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html=20
--=20
-----------------------------------------------------------------
Company : Bull, Architect of an Open World TM (www.bull.com)
Name : Aime Le Rouzic=20
Mail : Bull - BP 208 - 38432 Echirolles Cedex - France
E-Mail : [email protected]
Phone : 33 (4) 76.29.75.51
=46ax : 33 (4) 76.29.75.18
-----------------------------------------------------------------=20
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
Quoted 3 lines
J. Bruce Fields a =C3=A9crit :
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
so suppose I'm a server
administrator, and want my nfs server to listen for ipv6 connectio=
ns.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Will there be some switch I'll need to flip?
Quoted 1 line · Chuck Lever
I don't know how that UI will be designed. So far, I've focused on=
ly=20
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
on the pieces needed for client side IPv6 support. I figured the=20 Bull team had something figured out for the server, and didn't thin=
k=20
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
any more about it.
I've forgotten who was working on that; Aurelien Charbon?
Quoted 5 lines · On Thu, Aug 21, 2008 at 02:11:49PM +0200, Le Rouzic wrote:
Sorry for not answering before, I am back from vacation. Aurelien is no longer directly working on that even he can answer any questions. It is me now who tess NFSV4 IPV6 with the patches Aurelien delivered to Bruce a few months ago. But since Chuck has delivered several new patches which affect the NFS server side about the way nfsd can liste=
n
Quoted 1 line
for ipv6 connections.
I merged the last patch I can remember from Aurelien (f15364bd "IPv6 support for NFS server export caches"). Are there some others floating around that I should look at?
Quoted 4 lines
To have NFSV4 IPV6 working with those changes, what it would be nice to have a complete list on what are the changes. Is there now a complete release for which we can test those latest changes? If not which one will be? Are there any other changes still planned?
I was hoping you or Chuck would know; I don't know of anyone else working on nfs over ipv6.
--b.
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
J. Bruce Fields a =C3=A9crit :
Quoted 5 lines
Quoted 5 lines
J. Bruce Fields a =C3=A9crit :
=20Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
so suppose I'm a server
administrator, and want my nfs server to listen for ipv6 connectio=
ns.
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Will there be some switch I'll need to flip?
=20=20
Quoted 4 lines
Quoted 4 lines · Chuck Lever
=20Quoted 1 line
I don't know how that UI will be designed. So far, I've focused on=
ly=20
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
on the pieces needed for client side IPv6 support. I figured the=20 Bull team had something figured out for the server, and didn't thin=
k=20
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
any more about it.
=20I've forgotten who was working on that; Aurelien Charbon?
=20On Thu, Aug 21, 2008 at 02:11:49PM +0200, Le Rouzic wrote:
=20Quoted 5 lines
Sorry for not answering before, I am back from vacation. Aurelien is no longer directly working on that even he can answer any questions. It is me now who tess NFSV4 IPV6 with the patches Aurelien delivered to Bruce a few months ago. But since Chuck has delivered several new patches which affect the NFS server side about the way nfsd can liste=
n
Quoted 6 lines
Quoted 3 lines
for ipv6 connections.
=20I merged the last patch I can remember from Aurelien (
f15364bd"IPv6 support for NFS server export caches"). Are there some others floatin=
g
Quoted 11 lines
around that I should look at?
=20
Quoted 6 lines
To have NFSV4 IPV6 working with those changes, what it would be nice to have a complete list on what are the changes. Is there now a complete release for which we can test those latest changes? If not which one will be? Are there any other changes still planned?
=20
Quoted 4 lines
I was hoping you or Chuck would know; I don't know of anyone else working on nfs over ipv6.
=20
Hi,
About changes I was talking about changes introduced for IPv6 RPC=20 services via rpcbind
at least thoses published on the 19th on this mailing list can be=20 considered like the last
ones.
Cheers
Quoted 3 lines
--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" i=
n
Quoted 6 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html=20
--=20
-----------------------------------------------------------------
Company : Bull, Architect of an Open World TM (www.bull.com)
Name : Aime Le Rouzic=20
Mail : Bull - BP 208 - 38432 Echirolles Cedex - France
E-Mail : [email protected]
Phone : 33 (4) 76.29.75.51
=46ax : 33 (4) 76.29.75.18
-----------------------------------------------------------------=20
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
On Thu, Aug 21, 2008 at 11:32 AM, Le Rouzic <[email protected]> w= rote:
Quoted 7 lines
J. Bruce Fields a =E9crit :
Quoted 5 lines
Quoted 5 lines
J. Bruce Fields a =E9crit :
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
so suppose I'm a server
administrator, and want my nfs server to listen for ipv6 connect=
ions.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Will there be some switch I'll need to flip?
Quoted 2 lines · Chuck Lever
I don't know how that UI will be designed. So far, I've focused =
only
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
on the pieces needed for client side IPv6 support. I figured the=
Bull team
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
had something figured out for the server, and didn't think any mo=
re about
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
it.
I've forgotten who was working on that; Aurelien Charbon?
Quoted 2 lines · On Thu, Aug 21, 2008 at 02:11:49PM +0200, Le Rouzic wrote:
Sorry for not answering before, I am back from vacation. Aurelien =
is
Quoted 1 line
Quoted 1 line
Quoted 1 line
no longer directly working on that even he can answer any question=
s.
Quoted 1 line
Quoted 1 line
Quoted 1 line
It is me now who tess NFSV4 IPV6 with the patches Aurelien delivere=
d
Quoted 1 line
Quoted 1 line
Quoted 1 line
to Bruce a few months ago. But since Chuck has delivered several n=
ew
Quoted 1 line
Quoted 1 line
Quoted 1 line
patches which affect the NFS server side about the way nfsd can lis=
ten
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
for ipv6 connections.
I merged the last patch I can remember from Aurelien (
f15364bd"IPv6 support for NFS server export caches"). Are there some others float=
ing
Quoted 5 lines
Quoted 5 lines
around that I should look at?
Quoted 2 lines
To have NFSV4 IPV6 working with those changes, what it would be nic=
e
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
to have a complete list on what are the changes. Is there now a complete release for which we can test those latest changes? If no=
t
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
which one will be? Are there any other changes still planned?
I was hoping you or Chuck would know; I don't know of anyone else working on nfs over ipv6.
Hi,
About changes I was talking about changes introduced for IPv6 RPC ser=
vices
Quoted 2 lines
via rpcbind
at least thoses published on the 19th on this mailing list can be con=
sidered
Quoted 1 line
like the last ones.
My complete IPv6 patch set is available here:
http://git.linux-nfs.org/?p=3Dcel/cel-2.6.git;a=3Dsummary
The tags that start "cel-ipv6-..." contain the IPv6-related patches. I see the latest one is still two weeks old, so I should update it with what I sent to Bruce recently.
--=20
Chuck Lever
A message that is not in the archive (sent off-list or not yet received): 76bd70e30808210920y3db1b07cyccbe40e1b4582c12-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/8] SUNRPC: Set V6ONLY socket option for RPC listener sockets
Quoted 7 lines · Chuck Lever
My complete IPv6 patch set is available here:
http://git.linux-nfs.org/?p=cel/cel-2.6.git;a=summary
The tags that start "cel-ipv6-..." contain the IPv6-related patches. I see the latest one is still two weeks old, so I should update it with what I sent to Bruce recently.
OK. Well, I can't currently volunteer to write and test the last bits of server-side ipv6 functionality, so somebody else needs to or it won't happen.
--b.
PATCH 4/8 SUNRPC: Use proper INADDR_ANY when setting up RPC services on IPv6
In reply to a message not in the archiveChoose the correct family for the ANY address when initializing RPC services.
---
net/sunrpc/svc_xprt.c | 37 ++++++++++++++++++++++++++++++------- 1 files changed, 30 insertions(+), 7 deletions(-)
net/sunrpc/svc_xprt.c +30 -7
@@ -159,16 +159,41 @@ void svc_xprt_init(struct svc_xprt_class *xcl, struct svc_xprt *xprt, }EXPORT_SYMBOL_GPL (svc_xprt_init); -int svc_create_xprt (struct svc_serv *serv,char *xprt_name,unsigned short port, -int flags) +static struct svc_xprt *__svc_xpo_create (struct svc_xprt_class *xcl, +struct svc_serv *serv, +unsigned short port,int flags) { -struct svc_xprt_class *xcl;struct sockaddr_in sin = { .sin_family =AF_INET , .sin_addr.s_addr =htonl (INADDR_ANY ), .sin_port =htons (port), }; -dprintk ("svc: creating transport %s[%d]\n" , xprt_name, port); +struct sockaddr_in6 sin6 = { + .sin6_family =AF_INET6 , + .sin6_addr =IN6ADDR_ANY_INIT , + .sin6_port =htons (port), + }; + +switch (serv->sv_family) { +case AF_INET : +return xcl->xcl_ops->xpo_create (serv, + (struct sockaddr *)&sin, +sizeof (sin), flags); +case AF_INET6 : +return xcl->xcl_ops->xpo_create (serv, + (struct sockaddr *)&sin6, +sizeof (sin6), flags); + } + +return ERR_PTR (-EAFNOSUPPORT ); +} + +int svc_create_xprt (struct svc_serv *serv,char *xprt_name,unsigned short port, +int flags) +{ +struct svc_xprt_class *xcl; + +dprintk ("svc: creating transport %s[%u]\n" , xprt_name, port);spin_lock (&svc_xprt_class_lock);list_for_each_entry (xcl, &svc_xprt_class_list, xcl_list) {struct svc_xprt *newxprt;
@@ -180,9 +205,7 @@ int svc_create_xprt(struct svc_serv *serv, char *xprt_name, unsigned short port, goto err;spin_unlock (&svc_xprt_class_lock); - newxprt = xcl->xcl_ops-> -xpo_create (serv, (struct sockaddr *)&sin,sizeof (sin), - flags); + newxprt =__svc_xpo_create (xcl, serv, port, flags);if (IS_ERR (newxprt)) {module_put (xcl->xcl_owner);return PTR_ERR (newxprt);
PATCH 5/8 SUNRPC: Split portmap unregister API into separate function
In reply to a message not in the archiveCreate a separate server-level interface for unregistering RPC services.
The mechanics of, and the API for, registering and unregistering RPC services will diverge further as support for IPv6 is added.
---
net/sunrpc/svc.c | 76 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 63 insertions(+), 13 deletions(-)
net/sunrpc/svc.c +63 -13
@@ -28,6 +28,8 @@#define RPCDBG_FACILITY RPCDBG_SVCDSP +static void svc_unregister (const struct svc_serv *serv); +#define svc_serv_is_pooled (serv) ((serv)->sv_function)/*
@@ -417,9 +419,8 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,spin_lock_init (&pool->sp_lock); } -/* Remove any stale portmap registrations */ -svc_register (serv,0 ,0 ); +svc_unregister (serv);return serv; }
@@ -488,8 +489,7 @@ svc_destroy(struct svc_serv *serv)if (svc_serv_is_pooled (serv))svc_pool_map_put (); -/* Unregister service with the portmapper */ -svc_register (serv,0 ,0 ); +svc_unregister (serv);kfree (serv->sv_pools);kfree (serv); }
@@ -729,12 +729,10 @@ int svc_register(struct svc_serv *serv, int proto, unsigned short port) { struct svc_program *progp; -unsigned long flags;unsigned int i;int error =0 , dummy; -if (!port) -clear_thread_flag (TIF_SIGPENDING ); +BUG_ON (proto ==0 && port ==0 );for (progp = serv->sv_program; progp; progp = progp->pg_next) {for (i =0 ; i < progp->pg_nvers; i++) {
@@ -755,20 +753,72 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port) error =rpcb_register (progp->pg_prog, i, proto, port, &dummy);if (error <0 )break ; -if (port && !dummy) { +if (!dummy) { error = -EACCES ;break ; } } } -if (!port) { -spin_lock_irqsave (¤t->sighand->siglock, flags); -recalc_sigpending (); -spin_unlock_irqrestore (¤t->sighand->siglock, flags); +return error; +} + +/* +* The local rpcbind daemon listens on either only IPv6 or only +* IPv4. The kernel can't tell how it's configured. +* +* However, AF_INET addresses are mapped to AF_INET6 in IPv6-only +* configurations, so even an unregistration request on AF_INET +* will get to a local rpcbind daemon listening only on AF_INET6. +* +* So we always unregister via AF_INET (the loopback address is +* fairly unambiguous anyway). +* +* At this point we don't need rpcbind version 4 for unregistration: +* A v2 UNSET request will clear all transports (netids), addresses, +* and address families for [program, version]. +* +* This should allow automatic support for both an all-IPv4 and +* an all-IPv6 configuration. +*/ +static void __svc_unregister (struct svc_program *progp,u32 version) +{ +int error, boolean; + + error =rpcb_register (progp->pg_prog, version,0 ,0 , &boolean); +dprintk ("svc: svc_unregister(%sv%u), error %d, %s\n" , + progp->pg_name, version, error, + (boolean ?"succeeded" :"failed" )); +} + +/* +* All transport protocols and ports for this service are removed from +* the local rpcbind database if the service is not hidden. The result +* of unregistration is reported via dprintk for those who want +* verification of the result, but is otherwise not important. +*/ +static void svc_unregister (const struct svc_serv *serv) +{ +struct svc_program *progp; +unsigned long flags; + +clear_thread_flag (TIF_SIGPENDING ); + +for (progp = serv->sv_program; progp; progp = progp->pg_next) { +unsigned int i; +for (i =0 ; i < progp->pg_nvers; i++) { +if (progp->pg_vers[i] ==NULL ) +continue ; +if (progp->pg_vers[i]->vs_hidden) +continue ; + +__svc_unregister (progp, i); + } } -return error; +spin_lock_irqsave (¤t->sighand->siglock, flags); +recalc_sigpending (); +spin_unlock_irqrestore (¤t->sighand->siglock, flags); }/*
PATCH 6/8 SUNRPC: Refactor svc_register()
In reply to a message not in the archiveClean up: refactor the rpcb_register() call out of svc_register().
The next patch will choose the correct registration subroutine to use based on whether IPv6 support is desired for RPC services.
---
include/linux/sunrpc/svc.h | 4 +++- net/sunrpc/svc.c | 40 +++++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-)
include/linux/sunrpc/svc.h +3 -1
@@ -395,7 +395,9 @@ struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,int svc_set_num_threads (struct svc_serv *,struct svc_pool *,int );void svc_destroy (struct svc_serv *);int svc_process (struct svc_rqst *); -int svc_register (struct svc_serv *,int ,unsigned short ); +int svc_register (const struct svc_serv *,const unsigned short , +const unsigned short ); +void svc_wake_up (struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv,int cpu);
net/sunrpc/svc.c +27 -13
@@ -720,17 +720,32 @@ svc_exit_thread(struct svc_rqst *rqstp) }EXPORT_SYMBOL (svc_exit_thread); -/* -* Register an RPC service with the local portmapper. -* To unregister a service, call this routine with -* proto and port == 0. +static int __svc_register (const u32 program,const u32 version, +sa_family_t family, +const unsigned short protocol, +const unsigned short port) +{ +int error, result; + + error =rpcb_register (program, version, protocol, port, &result); +if (!result) + error = -EACCES ; +return error; +} + +/** +* svc_register - register an RPC service with the local portmapper +* @serv: svc_serv struct for the service to register +* @proto: transport protocol number to advertise +* @port: port to advertise +* */ -int -svc_register (struct svc_serv *serv,int proto,unsigned short port) +int svc_register (const struct svc_serv *serv,const unsigned short proto, +const unsigned short port) {struct svc_program *progp;unsigned int i; -int error =0 , dummy; +int error =0 ;BUG_ON (proto ==0 && port ==0 );
@@ -739,8 +754,9 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)if (progp->pg_vers[i] ==NULL )continue ; - dprintk("svc: svc_register(%s, %s, %d, %d)%s\n", + dprintk("svc: svc_register(%s, %u, %s, %u, %d)%s\n", progp->pg_name, + serv->sv_family, proto == IPPROTO_UDP? "udp" : "tcp", port, i,
@@ -750,13 +766,11 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)if (progp->pg_vers[i]->vs_hidden)continue ; - error =rpcb_register (progp->pg_prog, i, proto, port, &dummy); + error =__svc_register (progp->pg_prog, i, + serv->sv_family, proto, + port);if (error <0 )break ; -if (!dummy) { - error = -EACCES ; -break ; - } } }
A message that is not in the archive (sent off-list or not yet received): 20080813224016.13068.29786.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org
Re: [PATCH 6/8] SUNRPC: Refactor svc_register()
Quoted 40 lines · Chuck Lever
Clean up: refactor the
rpcb_register()call out ofsvc_register().The next patch will choose the correct registration subroutine to use based on whether IPv6 support is desired for RPC services.
Signed-off-by Chuck Lever <[email protected]>---
include/linux/sunrpc/svc.h | 4 +++- net/sunrpc/svc.c | 40 +++++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-)include/linux/sunrpc/svc.h +3
-1@@ -395,7 +395,9 @@ struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,int svc_set_num_threads (struct svc_serv *,struct svc_pool *,int );void svc_destroy (struct svc_serv *);int svc_process (struct svc_rqst *); -int svc_register (struct svc_serv *,int ,unsigned short ); +int svc_register (const struct svc_serv *,const unsigned short , +const unsigned short ); +void svc_wake_up (struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv,int cpu);net/sunrpc/svc.c +1
-4@@ -720,17 +720,32 @@ svc_exit_thread(struct svc_rqst *rqstp) }EXPORT_SYMBOL (svc_exit_thread); -/* -* Register an RPC service with the local portmapper. -* To unregister a service, call this routine with -* proto and port == 0. +static int __svc_register(const u32 program, const u32 version,
net/sunrpc/svc.c svc_exit_thread(struct svc_rqst *rqstp) · line 733
Quoted 10 lines
net/sunrpc/svc.c +10
-0+sa_family_t family, + const unsigned short protocol, + const unsigned short port) +{ + int error, result; + + error =rpcb_register (program, version, protocol, port, &result); +if (!result) + error = -EACCES ; +return error;
Isn't "result" 0 whenever error is nonzero? In that case the above is really equivalent to
rpcb_register(program, version, protocol, port, &result); return result ? 0 : -EACCES;
Is that what's intended? I don't believe it's the behavior of the original code.
I understand why they're there, but the separate "result" and "error" returns are kinda confusing. If the distinction's not needed then I wonder whether it should just be buried as deep in rpcb_register() as possible so we don't have to think about it.
--b.
Quoted 50 lines
net/sunrpc/svc.c +16
-9+} + +/** +* svc_register - register an RPC service with the local portmapper +* @serv: svc_serv struct for the service to register +* @proto: transport protocol number to advertise +* @port: port to advertise +* */ -int -svc_register (struct svc_serv *serv,int proto,unsigned short port) +int svc_register (const struct svc_serv *serv,const unsigned short proto, +const unsigned short port) {struct svc_program *progp;unsigned int i; -int error =0 , dummy; +int error =0 ;BUG_ON (proto ==0 && port ==0 );@@ -739,8 +754,9 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)if (progp->pg_vers[i] ==NULL )continue ; - dprintk("svc: svc_register(%s, %s, %d, %d)%s\n", + dprintk("svc: svc_register(%s, %u, %s, %u, %d)%s\n", progp->pg_name, + serv->sv_family, proto == IPPROTO_UDP? "udp" : "tcp", port, i,@@ -750,13 +766,11 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)if (progp->pg_vers[i]->vs_hidden)continue ; - error =rpcb_register (progp->pg_prog, i, proto, port, &dummy); + error =__svc_register (progp->pg_prog, i, + serv->sv_family, proto, + port);if (error <0 )break ; -if (!dummy) { - error = -EACCES ; -break ; - } } }
Re: [PATCH 6/8] SUNRPC: Refactor svc_register()
Quoted 56 lines · J. Bruce Fields
Quoted 42 lines · Chuck Lever
Clean up: refactor the
rpcb_register()call out ofsvc_register().The next patch will choose the correct registration subroutine to use based on whether IPv6 support is desired for RPC services.
Signed-off-by Chuck Lever <[email protected]>---
include/linux/sunrpc/svc.h| 4 +++-net/sunrpc/svc.c| 40 ++++++++++++++++++++++++++
+-------------2 files changed, 30 insertions(+), 14 deletions(-)include/linux/sunrpc/svc.h +3
-1@@ -395,7 +395,9 @@ struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,int svc_set_num_threads (struct svc_serv *,struct svc_pool *,int );void svc_destroy (struct svc_serv *);int svc_process (struct svc_rqst *); -int svc_register (struct svc_serv *,int ,unsigned short ); +int svc_register (const struct svc_serv *,const unsigned short , +const unsigned short ); +void svc_wake_up (struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);struct
svc_pool*svc_pool_for_cpu(struct svc_serv *serv, int cpu);net/sunrpc/svc.c +1
-4@@ -720,17 +720,32 @@ svc_exit_thread(struct svc_rqst *rqstp) }EXPORT_SYMBOL (svc_exit_thread); -/* -* Register an RPC service with the local portmapper. -* To unregister a service, call this routine with -* proto and port == 0. +static int __svc_register(const u32 program, const u32 version,net/sunrpc/svc.c svc_exit_thread(struct svc_rqst *rqstp) · line 733
Quoted 10 lines
net/sunrpc/svc.c +10
-0+sa_family_t family, + const unsigned short protocol, + const unsigned short port) +{ + int error, result; + + error =rpcb_register (program, version, protocol, port, &result); +if (!result) + error = -EACCES ; +return error;Isn't "result" 0 whenever error is nonzero? In that case the above is really equivalent to
Quoted 5 lines
rpcb_register(program, version, protocol, port, &result); return result ? 0 : -EACCES;Is that what's intended? I don't believe it's the behavior of the original code.
I'll fix it. It's a vestige of a previous implementation of rpcb_v4_register.
Quoted 4 lines
I understand why they're there, but the separate "result" and "error" returns are kinda confusing. If the distinction's not needed then I wonder whether it should just be buried as deep in
rpcb_register()as possible so we don't have to think about it.
pmap_set() is the user space API for this function, and it returns a bool_t -- TRUE if the service was registered, FALSE if it failed in any way. It is probably unnecessary to expose the RPC call and RPC reply status codes separately.
To fix this, I will rework the rpcb_register() and rpcb_v4_register() APIs, and the patches in this series that depend on them.
Quoted 39 lines
Quoted 39 lines
net/sunrpc/svc.c +13
-4+} + +/** +* svc_register - register an RPC service with the local portmapper +* @serv: svc_serv struct for the service to register +* @proto: transport protocol number to advertise +* @port: port to advertise +* */ -int -svc_register (struct svc_serv *serv,int proto,unsigned short port) +int svc_register (const struct svc_serv *serv,const unsigned short proto, +const unsigned short port) {struct svc_program *progp;unsigned int i; -int error =0 , dummy; +int error =0 ;BUG_ON (proto ==0 && port ==0 );@@ -739,8 +754,9 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)if (progp->pg_vers[i] ==NULL )continue ; - dprintk("svc: svc_register(%s, %s, %d, %d)%s\n", + dprintk("svc: svc_register(%s, %u, %s, %u, %d)%s\n", progp->pg_name, + serv->sv_family, proto == IPPROTO_UDP? "udp" : "tcp", port,i,net/sunrpc/svc.c +0
-0@@ -750,13 +766,11 @@ svc_register(struct svc_serv *serv, int proto, unsigned short port)if (progp->pg_vers[i]->vs_hidden)continue ;
Quoted 14 lines
Quoted 4 lines
net/sunrpc/svc.c +1
-1- error =rpcb_register (progp->pg_prog, i, proto, port, &dummy); + error = __svc_register(progp->pg_prog, i,net/sunrpc/svc.c svc_register(struct svc_serv *serv, int proto, unsigned short port) · line 775
Quoted 10 lines
net/sunrpc/svc.c +2
-4+ serv->sv_family, proto, + port);if (error <0 )break ; -if (!dummy) { - error = -EACCES ; -break ; - } } }
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
PATCH 7/8 SUNRPC: Use new rpcb_v4_register() interface in svc_register()
In reply to a message not in the archiveIn order to advertise NFS-related services on IPv6 interfaces via rpcbind, the kernel RPC server implementation must use rpcb_v4_register() instead of rpcb_register().
Legacy support (register using portmapper/rpcbindv2) is still available. The new rpcbind version is not used unless enabled via a CONFIG option.
---
net/sunrpc/svc.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-)
net/sunrpc/svc.c +73 -0
@@ -720,6 +720,74 @@ svc_exit_thread(struct svc_rqst *rqstp) }EXPORT_SYMBOL (svc_exit_thread); +#ifdef CONFIG_SUNRPC_REGISTER_V4 +/* +* Registering kernel RPC services with rpcbind version 2 will work +* over either IPv4 or IPv6, since the Linux kernel always registers +* services for the "any" address. +* +* However, the local rpcbind daemon listens on either only AF_INET +* or AF_INET6 (never both). When it listens on AF_INET6, an rpcbind +* version 2 registration will result in registering the service at +* IN6ADDR_ANY, even if the RPC service being registered is not +* IPv6-enabled. +* +* Rpcbind version 4 allows us to be a little more specific. Kernel +* RPC services that don't yet support AF_INET6 can register +* themselves as IPv4-only with the local rpcbind daemon, even if the +* daemon is listening only on AF_INET6. +* +* And, registering IPv6-enabled kernel RPC services via AF_INET6 +* verifies that the local user space rpcbind daemon is properly +* configured to support remote AF_INET6 rpcbind requests. +* +* An AF_INET6 registration request will fail if the local rpcbind +* daemon is not set up to listen on AF_INET6. Likewise, we fail +* AF_INET6 registration requests if svc_register() is configured to +* support only rpcbind version 2. +*/ +static int __svc_register (const u32 program,const u32 version, +const sa_family_t family, +const unsigned short protocol, +const unsigned short port) +{ +struct sockaddr_in sin = { + .sin_family =AF_INET , + .sin_addr.s_addr =htonl (INADDR_ANY ), + .sin_port =htons (port), + }; +struct sockaddr_in6 sin6 = { + .sin6_family =AF_INET6 , + .sin6_addr =IN6ADDR_ANY_INIT , + .sin6_port =htons (port), + }; +struct sockaddr *sap; +char *netid; +int error, result; + +switch (family) { +case AF_INET : + sap = (struct sockaddr *)&sin; + netid =RPCBIND_NETID_TCP ; +if (protocol ==IPPROTO_UDP ) + netid =RPCBIND_NETID_UDP ; +break ; +case AF_INET6 : + sap = (struct sockaddr *)&sin6; + netid =RPCBIND_NETID_TCP6 ; +if (protocol ==IPPROTO_UDP ) + netid =RPCBIND_NETID_UDP6 ; +break ; +default : +return -EAFNOSUPPORT ; + } + + error =rpcb_v4_register (program, version, sap, netid, &result); +if (!result) + error = -EACCES ; +return error; +} +#else static int __svc_register(const u32 program, const u32 version, sa_family_t family, const unsigned short protocol,
@@ -727,11 +795,15 @@ static int __svc_register(const u32 program, const u32 version, {int error, result; +if (family !=AF_INET ) +return -EAFNOSUPPORT ; + error =rpcb_register (program, version, protocol, port, &result);if (!result) error = -EACCES ;return error; } +#endif /** * svc_register - register an RPC service with the local portmapper
@@ -739,6 +811,7 @@ static int __svc_register(const u32 program, const u32 version,* @proto: transport protocol number to advertise * @port: port to advertise * +* Service is registered for any address in serv's address family */ int svc_register (const struct svc_serv *serv,const unsigned short proto,const unsigned short port)
PATCH 8/8 SUNRPC: Add kernel build option to disable server-side use of rpcbind v3/v4
In reply to a message not in the archiveAllow distributions to use the legacy behavior until they integrate an appropriate user-space rpcbind daemon that can support IPv6 RPC services.
I tried adding some logic to fall back if (un)registering with a v4 protocol request failed, but there are too many corner cases. So I just made it a compile-time switch that distributions can throw when they've replaced portmapper with rpcbind.
---
fs/Kconfig | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)
fs/Kconfig +22 -0
@@ -1765,6 +1765,28 @@ config SUNRPC_XPRT_RDMA If unsure, say N. +config SUNRPC_REGISTER_V4 + bool "Register local RPC services via rpcbind v4 (EXPERIMENTAL)" + depends on SUNRPC && EXPERIMENTAL + default n + help + Sun added support for registering RPC services at an IPv6 + address by creating two new versions of the rpcbind protocol + (RFC 1833). + + This option enables support in the kernel RPC server for + registering kernel RPC services via version 4 of the rpcbind + protocol. If you enable this option, you must run a portmapper + daemon that supports rpcbind protocol version 4. + + Serving NFS over IPv6 from knfsd (the kernel's NFS server) + requires that you enable this option and use a portmapper that + supports rpcbind version 4. + + If unsure, say N to get traditional behavior (register kernel + RPC services using only rpcbind version 2). Distributions + using the legacy Linux portmapper daemon must say N here. + config RPCSEC_GSS_KRB5 tristate "Secure RPC: Kerberos V mechanism (EXPERIMENTAL)" depends on SUNRPC && EXPERIMENTAL