nfs: convert proto= option to use netid's rather than a protoname
Subsystems (2)
PATCH 1/1 nfs: convert proto= option to use netid's rather than a protoname
Solaris uses netids as values for the proto= option, so that when someone specifies "tcp6" they get traffic over TCP + IPv6. Until recently, this has never really been an issue for Linux since it didn't support NFS over IPv6. The netid and the protocol name were generally always the same (modulo any strange configuration in /etc/netconfig).
The solaris manpage documents their proto= option as:
proto= _netid_ | rdma
This patch is intended to bring Linux closer to how the Solaris proto= option works, by declaring a static netid mapping in the kernel and converting the proto= and mountproto= options to follow it and display the proper values in /proc/mounts.
Much of this functionality will need to be provided by a userspace mount.nfs patch. Chuck Lever has a draft patch to change mount.nfs in the same way. In principle, we could do *all* of this in userspace but for the fact that the mount options in /proc/mounts would no longer reflect the options passed to mount.nfs.
The alternative to the static mapping here is to add a mechanism to upcall to userspace for netid's. I'm not opposed to that option, but it'll probably mean a bit more overhead (and quite a bit more code). Rather than shoot for that at first, I figured it was probably better to start simply.
Comments welcome...
--- fs/nfs/super.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 81 insertions(+), 13 deletions(-)
fs/nfs/super.c +81 -13
@@ -175,14 +175,16 @@ static const match_table_t nfs_mount_option_tokens = { };enum { - Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma, + Opt_xprt_udp, Opt_xprt_udp6, Opt_xprt_tcp, Opt_xprt_tcp6, Opt_xprt_rdma, Opt_xprt_err };static const match_table_t nfs_xprt_protocol_tokens = { { Opt_xprt_udp,"udp" }, + { Opt_xprt_udp6,"udp6" }, { Opt_xprt_tcp,"tcp" }, + { Opt_xprt_tcp6,"tcp6" }, { Opt_xprt_rdma,"rdma" }, { Opt_xprt_err,NULL }
@@ -492,6 +494,45 @@ static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour)return sec_flavours[i].str; } +static void nfs_show_mountd_netid (struct seq_file *m,struct nfs_server *nfss, +int showdefaults) +{ +struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address; + +seq_printf (m,",mountproto=" ); +switch (sap->sa_family) { +case AF_INET : +switch (nfss->mountd_protocol) { +case IPPROTO_UDP : +seq_printf (m,RPCBIND_NETID_UDP ); +break ; +case IPPROTO_TCP : +seq_printf (m,RPCBIND_NETID_TCP ); +break ; +default : +if (showdefaults) +seq_printf (m,"auto" ); + } +break ; +case AF_INET6 : +switch (nfss->mountd_protocol) { +case IPPROTO_UDP : +seq_printf (m,RPCBIND_NETID_UDP6 ); +break ; +case IPPROTO_TCP : +seq_printf (m,RPCBIND_NETID_TCP6 ); +break ; +default : +if (showdefaults) +seq_printf (m,"auto" ); + } +break ; +default : +if (showdefaults) +seq_printf (m,"auto" ); + } +} +static void nfs_show_mountd_options (struct seq_file *m,struct nfs_server *nfss,int showdefaults) {
@@ -518,17 +559,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,if (nfss->mountd_port || showdefaults)seq_printf (m,",mountport=%u" , nfss->mountd_port); -switch (nfss->mountd_protocol) { -case IPPROTO_UDP : -seq_printf (m,",mountproto=udp" ); -break ; -case IPPROTO_TCP : -seq_printf (m,",mountproto=tcp" ); -break ; -default : -if (showdefaults) -seq_printf (m,",mountproto=auto" ); - } +nfs_show_mountd_netid (m, nfss, showdefaults); }/*
@@ -578,7 +609,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,seq_puts (m, nfs_infop->nostr); }seq_printf (m,",proto=%s" , -rpc_peeraddr2str (nfss->client,RPC_DISPLAY_PROTO )); +rpc_peeraddr2str (nfss->client,RPC_DISPLAY_NETID ));if (version ==4 ) {if (nfss->port !=NFS_PORT )seq_printf (m,",port=%u" , nfss->port);
@@ -887,6 +918,8 @@ static int nfs_parse_mount_options(char *raw, {char *p, *string, *secdata;int rc, sloppy =0 , invalid_option =0 ; +unsigned short protofamily =AF_UNSPEC ; +unsigned short mountfamily =AF_UNSPEC ;if (!raw) {dfprintk (MOUNT ,"NFS: mount options string was NULL.\n" );
@@ -1232,12 +1265,17 @@ static int nfs_parse_mount_options(char *raw, token =match_token (string, nfs_xprt_protocol_tokens, args); + protofamily =AF_INET ;switch (token) { +case Opt_xprt_udp6: + protofamily =AF_INET6 ;case Opt_xprt_udp: mnt->flags &= ~NFS_MOUNT_TCP ; mnt->nfs_server.protocol =XPRT_TRANSPORT_UDP ;kfree (string);break ; +case Opt_xprt_tcp6: + protofamily =AF_INET6 ;case Opt_xprt_tcp: mnt->flags |=NFS_MOUNT_TCP ; mnt->nfs_server.protocol =XPRT_TRANSPORT_TCP ;
@@ -1265,10 +1303,15 @@ static int nfs_parse_mount_options(char *raw, nfs_xprt_protocol_tokens, args);kfree (string); + mountfamily =AF_INET ;switch (token) { +case Opt_xprt_udp6: + mountfamily =AF_INET6 ;case Opt_xprt_udp: mnt->mount_server.protocol =XPRT_TRANSPORT_UDP ;break ; +case Opt_xprt_tcp6: + mountfamily =AF_INET6 ;case Opt_xprt_tcp: mnt->mount_server.protocol =XPRT_TRANSPORT_TCP ;break ;
@@ -1367,8 +1410,33 @@ static int nfs_parse_mount_options(char *raw,if (!sloppy && invalid_option)return 0 ; +/* +* verify that any proto=/mountproto= options match the address +* familiies in the addr=/mountaddr= options. +*/ +if (protofamily !=AF_UNSPEC && + protofamily != mnt->nfs_server.address.ss_family) + goto out_proto_mismatch; + +if (mountfamily !=AF_UNSPEC ) { +if (mnt->mount_server.addrlen) { +if (mountfamily != mnt->mount_server.address.ss_family) + goto out_mountproto_mismatch; + }else { +if (mountfamily != mnt->nfs_server.address.ss_family) + goto out_mountproto_mismatch; + } + } +return 1 ; +out_mountproto_mismatch: +printk (KERN_INFO "NFS: mount server address does not match mountproto= " +"option\n" ); +return 0 ; +out_proto_mismatch: +printk (KERN_INFO "NFS: server address does not match proto= option\n" ); +return 0 ; out_invalid_address:printk (KERN_INFO "NFS: bad IP address specified: %s\n" , p);return 0 ;
Signature · 1 line
1.6.0.6
Quoted 128 lines · Jeff Layton
Solaris uses netids as values for the proto= option, so that when someone specifies "tcp6" they get traffic over TCP + IPv6. Until recently, this has never really been an issue for Linux since it didn't support NFS over IPv6. The netid and the protocol name were generally always the same (modulo any strange configuration in
/etc/netconfig).The solaris manpage documents their proto= option as:
proto= _netid_ | rdma
This patch is intended to bring Linux closer to how the Solaris proto= option works, by declaring a static netid mapping in the kernel and converting the proto= and mountproto= options to follow it and display the proper values in
/proc/mounts.Much of this functionality will need to be provided by a userspace mount.nfs patch. Chuck Lever has a draft patch to change mount.nfs in the same way. In principle, we could do *all* of this in userspace but for the fact that the mount options in
/proc/mountswould no longer reflect the options passed to mount.nfs.The alternative to the static mapping here is to add a mechanism to upcall to userspace for netid's. I'm not opposed to that option, but it'll probably mean a bit more overhead (and quite a bit more code). Rather than shoot for that at first, I figured it was probably better to start simply.
Comments welcome...
Signed-off-by Jeff Layton <[email protected]>---
fs/nfs/super.c| 94 +++++++++++++++++++++++++++++++++++++++++++++++
+--------1 files changed, 81 insertions(+), 13 deletions(-)fs/nfs/super.c +3
-1@@ -175,14 +175,16 @@ static const match_table_t nfs_mount_option_tokens = { };enum { - Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma, + Opt_xprt_udp, Opt_xprt_udp6, Opt_xprt_tcp, Opt_xprt_tcp6, Opt_xprt_rdma, Opt_xprt_err };static const match_table_t nfs_xprt_protocol_tokens = { { Opt_xprt_udp,"udp" }, + { Opt_xprt_udp6,"udp6" }, { Opt_xprt_tcp,"tcp" }, + { Opt_xprt_tcp6,"tcp6" }, { Opt_xprt_rdma,"rdma" },{ Opt_xprt_err, NULL }fs/nfs/super.c +39
-0@@ -492,6 +494,45 @@ static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour)return sec_flavours[i].str; } +static void nfs_show_mountd_netid (struct seq_file *m,struct nfs_server *nfss, +int showdefaults) +{ +struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address; + +seq_printf (m,",mountproto=" ); +switch (sap->sa_family) { +case AF_INET : +switch (nfss->mountd_protocol) { +case IPPROTO_UDP : +seq_printf (m,RPCBIND_NETID_UDP ); +break ; +case IPPROTO_TCP : +seq_printf (m,RPCBIND_NETID_TCP ); +break ; +default : +if (showdefaults) +seq_printf (m,"auto" ); + } +break ; +case AF_INET6 : +switch (nfss->mountd_protocol) { +case IPPROTO_UDP : +seq_printf (m,RPCBIND_NETID_UDP6 ); +break ; +case IPPROTO_TCP : +seq_printf (m,RPCBIND_NETID_TCP6 ); +break ; +default : +if (showdefaults) +seq_printf (m,"auto" ); + } +break ; +default : +if (showdefaults) +seq_printf (m,"auto" ); + } +} + static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,int showdefaults)
{fs/nfs/super.c +1
-11@@ -518,17 +559,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, if (nfss->mountd_port || showdefaults) seq_printf(m, ",mountport=%u", nfss->mountd_port); -switch (nfss->mountd_protocol) { -case IPPROTO_UDP : -seq_printf (m,",mountproto=udp" ); -break ; -case IPPROTO_TCP : -seq_printf (m,",mountproto=tcp" ); -break ; -default : -if (showdefaults) -seq_printf (m,",mountproto=auto" ); - } +nfs_show_mountd_netid (m ,nfss ,showdefaults ); }/*
fs/nfs/super.c static void nfs_show_mount_options(struct · line 613
Quoted 6 lines
fs/nfs/super.c +1
-1@@ -578,7 +609,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, seq_puts(m, nfs_infop->nostr); }seq_printf (m,",proto=%s" , -rpc_peeraddr2str (nfss->client,RPC_DISPLAY_PROTO )); +rpc_peeraddr2str (nfss->client,RPC_DISPLAY_NETID ));
Does that do the right thing for rdma mounts, currently?
Quoted 80 lines
fs/nfs/super.c +0
-0if (version ==4 ) {if (nfss->port !=NFS_PORT )seq_printf(m, ",port=%u", nfss->port);fs/nfs/super.c +32
-0@@ -887,6 +918,8 @@ static int nfs_parse_mount_options(char *raw, {char *p, *string, *secdata;int rc, sloppy =0 , invalid_option =0 ; +unsigned short protofamily =AF_UNSPEC ; +unsigned short mountfamily =AF_UNSPEC ;if (!raw) {dfprintk (MOUNT ,"NFS: mount options string was NULL.\n" );@@ -1232,12 +1265,17 @@ static int nfs_parse_mount_options(char *raw, token =match_token (string, nfs_xprt_protocol_tokens, args); + protofamily =AF_INET ;switch (token) { +case Opt_xprt_udp6: + protofamily =AF_INET6 ;case Opt_xprt_udp: mnt->flags &= ~NFS_MOUNT_TCP ; mnt->nfs_server.protocol =XPRT_TRANSPORT_UDP ;kfree (string);break ; +case Opt_xprt_tcp6: + protofamily =AF_INET6 ;case Opt_xprt_tcp: mnt->flags |=NFS_MOUNT_TCP ; mnt->nfs_server.protocol =XPRT_TRANSPORT_TCP ;@@ -1265,10 +1303,15 @@ static int nfs_parse_mount_options(char *raw, nfs_xprt_protocol_tokens, args);kfree (string); + mountfamily =AF_INET ;switch (token) { +case Opt_xprt_udp6: + mountfamily =AF_INET6 ;case Opt_xprt_udp: mnt->mount_server.protocol =XPRT_TRANSPORT_UDP ;break ; +case Opt_xprt_tcp6: + mountfamily =AF_INET6 ;case Opt_xprt_tcp: mnt->mount_server.protocol =XPRT_TRANSPORT_TCP ;break ;@@ -1367,8 +1410,33 @@ static int nfs_parse_mount_options(char *raw,if (!sloppy && invalid_option)return 0 ; +/* +* verify that any proto=/mountproto= options match the address +* familiies in the addr=/mountaddr= options. +*/ +if (protofamily !=AF_UNSPEC && + protofamily != mnt->nfs_server.address.ss_family) + goto out_proto_mismatch; + +if (mountfamily !=AF_UNSPEC ) { +if (mnt->mount_server.addrlen) { +if (mountfamily != mnt->mount_server.address.ss_family) + goto out_mountproto_mismatch; + }else { +if (mountfamily != mnt->nfs_server.address.ss_family) + goto out_mountproto_mismatch; + } + } +return 1 ; +out_mountproto_mismatch: + printk(KERN_INFO "NFS: mount server address does not matchmountproto= "
fs/nfs/super.c +4
-0+ "option\n"); +return 0 ; +out_proto_mismatch: + printk(KERN_INFO "NFS: server address does not match proto= option\n");
fs/nfs/super.c +1
-0+return 0 ;
out_invalid_address:
Quoted 9 lines
printk(KERN_INFO "NFS: bad IP address specified: %s\n", p); return 0;Signature · 6 lines
1.6.0.6 -- 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
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Quoted 12 lines · On Wed, 28 Oct 2009 16:15:33 -0400 Chuck Lever <[email protected]> wrote:
fs/nfs/super.c static void nfs_show_mount_options(struct · line 613
Quoted 9 lines
/*
fs/nfs/super.c +1
-1@@ -578,7 +609,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, seq_puts(m, nfs_infop->nostr); }seq_printf (m,",proto=%s" , -rpc_peeraddr2str (nfss->client,RPC_DISPLAY_PROTO )); +rpc_peeraddr2str (nfss->client,RPC_DISPLAY_NETID ));Does that do the right thing for rdma mounts, currently?
Unfortunately, I don't have an easy way to test this with RDMA yet, but it looks like it'll do the right thing. The RPC_DISPLAY_PROTO and RPC_DISPLAY_NETID strings both get set to "rdma".
As best I can tell IPv6 support for RDMA doesn't exist yet, so that seems to be the right thing to do for now.
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20091028184106.019ccbc6-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Quoted 16 lines · Jeff Layton
Quoted 12 lines · On Wed, 28 Oct 2009 16:15:33 -0400 Chuck Lever <[email protected]> wrote:
fs/nfs/super.c static void nfs_show_mount_options(struct · line 613
Quoted 9 lines
/*
fs/nfs/super.c +1
-1@@ -578,7 +609,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, seq_puts(m, nfs_infop->nostr); }seq_printf (m,",proto=%s" , -rpc_peeraddr2str (nfss->client,RPC_DISPLAY_PROTO )); +rpc_peeraddr2str (nfss->client,RPC_DISPLAY_NETID ));Does that do the right thing for rdma mounts, currently?
Quoted 6 lines
Unfortunately, I don't have an easy way to test this with RDMA yet, but it looks like it'll do the right thing. The
RPC_DISPLAY_PROTOandRPC_DISPLAY_NETIDstrings both get set to "rdma".As best I can tell IPv6 support for RDMA doesn't exist yet, so that seems to be the right thing to do for now.
OK... the NFS client plays some games with the internal protocol settings to get NLM and MNT to go over TCP instead of RDMA. I guess the PROTO and NETID strings are still "rdma" in this case, but it's worth keeping an eye on.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Quoted 9 lines · Jeff Layton
Solaris uses netids as values for the proto= option, so that when someone specifies "tcp6" they get traffic over TCP + IPv6. Until recently, this has never really been an issue for Linux since it didn't support NFS over IPv6. The netid and the protocol name were generally always the same (modulo any strange configuration in
/etc/netconfig).The solaris manpage documents their proto= option as:
proto= _netid_ | rdma
I'm strictly against adding netid braindamage to Linux. Just because Solaris made a mistake we don't have to repeat it.
Adding a hack to mount.nfs to parse it is fine, but there's not need to display it again.
Quoted 9 lines · On Thu, 29 Oct 2009 00:24:15 -0400 Christoph Hellwig <[email protected]> wrote:
Quoted 8 lines · Jeff Layton
Solaris uses netids as values for the proto= option, so that when someone specifies "tcp6" they get traffic over TCP + IPv6. Until recently, this has never really been an issue for Linux since it didn't support NFS over IPv6. The netid and the protocol name were generally always the same (modulo any strange configuration in
/etc/netconfig).The solaris manpage documents their proto= option as:
Quoted 7 lines
Quoted 1 line
proto= _netid_ | rdma
I'm strictly against adding netid braindamage to Linux. Just because Solaris made a mistake we don't have to repeat it.
Adding a hack to mount.nfs to parse it is fine, but there's not need to display it again.
Can you outline your objection to using netid's? What specifically are you against here?
There's good reason to keep the userspace utility and kernel in sync with respect to options. Otherwise if someone tries to remount a filesystem with the options listed in /proc/mounts the result will be different, no?
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20091029065816.314f5858-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org
Quoted 4 lines · Jeff Layton
There's good reason to keep the userspace utility and kernel in sync with respect to options. Otherwise if someone tries to remount a filesystem with the options listed in
/proc/mountsthe result will be different, no?
Everything that appear in /proc/self/mounts should also be feedable to mount. But we have lots of options that are just for compatiblity and are parsed by mount but turned into something else for /proc/self/mounts display.
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Jeff Layton
Solaris uses netids as values for the proto= option, so that when someone specifies "tcp6" they get traffic over TCP + IPv6. Until recently, this has never really been an issue for Linux since it didn't support NFS over IPv6. The netid and the protocol name were generally always the same (modulo any strange configuration in
/etc/netconfig).
Quoted 6 lines
Quoted 3 lines
The solaris manpage documents their proto= option as:
proto= _netid_ | rdma
I'm strictly against adding netid braindamage to Linux. Just because Solaris made a mistake we don't have to repeat it.
As it stands, the kernel already has some support for netids, which is required for supporting NFS and RPC on IPv6 such that it can interoperate with the reference NFS implementation. We might be able to address your concern if we understood specifically what was at issue.
A feature request has been made to provide a mechanism to force the use of IPv4 or IPv6 for mounting NFS servers that have both types of address. The use of "proto=netid" is especially preferred for mount.nfs since Linux often shares automounter maps with other NFS implementations. And, netids are an internet standard at this point. We could choose a different mechanism for the kernel's mount option parser, but I haven't seen an alternative proposal that is cleaner overall than what we have here.
Quoted 2 lines
Adding a hack to mount.nfs to parse it is fine, but there's not need to display it again.
That was our first pass, but as Jeff says, it's just bad user interface design for the mount options in /proc/mounts to have different semantics than what admins use in user space. I would rather keep mount.nfs and the kernel's mount parser as close together as possible.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com