mount.nfs: return error if proto= option specified IPv6 when IPv6 isn't supported
Subsystems (2)
PATCH 1/1 mount.nfs: return error if proto= option specified IPv6 when IPv6 isn't supported
Right now, there's nothing that expressly forbids someone from specifying proto=tcp6 for instance, even when nfs-utils it built without IPv6 support. This may not work well if (for instance) they are using NFSv3, since statd won't support IPv6. Explicitly return an error if someone specifies an IPv6 proto= or mountproto= option and IPv6 isn't supported.
--- utils/mount/network.c | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-)
utils/mount/network.c +27 -7
@@ -1334,9 +1334,26 @@ nfs_nfs_port(struct mount_options *options, unsigned long *port)#ifdef IPV6_SUPPORTED sa_family_t config_default_family =AF_UNSPEC ; -#else + +static int +nfs_verify_family (sa_family_t family) +{ +return 1 ; +} +#else /* IPV6_SUPPORTED */ sa_family_t config_default_family =AF_INET ; -#endif + +static int +nfs_verify_family (sa_family_t family) +{ +if (family !=AF_INET ) { + errno =EAFNOSUPPORT ; +return 0 ; + } + +return 1 ; +} +#endif /* IPV6_SUPPORTED */ /* * Returns TRUE and fills in @family if a valid NFS protocol option
@@ -1357,15 +1374,15 @@ int nfs_nfs_proto_family(struct mount_options *options,return 1 ;case 2 :/* proto */ option =po_get (options,"proto" ); -if (option !=NULL ) -return nfs_get_proto (option, family, &protocol); +if (option !=NULL && !nfs_get_proto (option, family, &protocol)) +return 0 ; }/* * NFS transport protocol wasn't specified. Return the * default address family. */ -return 1 ; +return nfs_verify_family (*family); }/*
@@ -1494,8 +1511,11 @@ int nfs_mount_proto_family(struct mount_options *options, *family = config_default_family; option =po_get (options,"mountproto" ); -if (option !=NULL ) -return nfs_get_proto (option, family, &protocol); +if (option !=NULL ) { +if (!nfs_get_proto (option, family, &protocol)) +return 0 ; +return nfs_verify_family (*family); + }/* * MNT transport protocol wasn't specified. If the NFS
Signature · 1 line
1.6.6
Quoted 27 lines · Jeff Layton
Right now, there's nothing that expressly forbids someone from specifying proto=tcp6 for instance, even when nfs-utils it built without IPv6 support. This may not work well if (for instance) they are using NFSv3, since statd won't support IPv6. Explicitly return an error if someone specifies an IPv6 proto= or mountproto= option and IPv6 isn't supported.
Signed-off-by Jeff Layton<[email protected]>--- utils/mount/network.c | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-)utils/mount/network.c +6
-1@@ -1334,9 +1334,26 @@ nfs_nfs_port(struct mount_options *options, unsigned long *port)#ifdef IPV6_SUPPORTED sa_family_t config_default_family =AF_UNSPEC ; -#else + +static int +nfs_verify_family (sa_family_t family) +{ +return 1 ; +}
utils/mount/network.c nfs_nfs_port(struct mount_options *options, unsigned long *port) · line 1351
Quoted 10 lines
utils/mount/network.c +8
-1+#else /* IPV6_SUPPORTED */ sa_family_t config_default_family =AF_INET ; -#endif + +static int +nfs_verify_family (sa_family_t family) +{ +if (family !=AF_INET ) { + errno =EAFNOSUPPORT ; +return 0 ;
I assume you do this so that mount.nfs emits a proper error message in this case. What about below where nfs_get_proto() returns false?
Quoted 12 lines
utils/mount/network.c +5
-0+ } + +return 1 ; +} +#endif /* IPV6_SUPPORTED */ /* * Returns TRUE and fills in @family if a valid NFS protocol option @@ -1357,15 +1374,15 @@ int nfs_nfs_proto_family(struct mount_options *options,return 1 ;case 2 :/* proto */ option =po_get (options,"proto" );
utils/mount/network.c int nfs_nfs_proto_family(struct mount_options *options, · line 1384
Quoted 10 lines
utils/mount/network.c +2
-2-if (option !=NULL ) -return nfs_get_proto (option, family,&protocol); +if (option !=NULL && !nfs_get_proto (option, family,&protocol)) +return 0 ; }/* * NFS transport protocol wasn't specified. Return the * default address family. */
It would help if this comment mentioned why you need to verify *family in the default case.
Quoted 19 lines
utils/mount/network.c +6
-3-return 1 ; +return nfs_verify_family (*family); }/* @@ -1494,8 +1511,11 @@ int nfs_mount_proto_family(struct mount_options *options, *family = config_default_family; option =po_get (options,"mountproto" ); -if (option !=NULL ) -return nfs_get_proto (option, family,&protocol); +if (option !=NULL ) { +if (!nfs_get_proto (option, family,&protocol)) +return 0 ; +return nfs_verify_family (*family); + }/* * MNT transport protocol wasn't specified. If the NFS
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Quoted 33 lines · On Mon, 08 Feb 2010 12:27:24 -0500 Chuck Lever <[email protected]> wrote:
Quoted 32 lines · Jeff Layton
Right now, there's nothing that expressly forbids someone from specifying proto=tcp6 for instance, even when nfs-utils it built without IPv6 support. This may not work well if (for instance) they are using NFSv3, since statd won't support IPv6. Explicitly return an error if someone specifies an IPv6 proto= or mountproto= option and IPv6 isn't supported.
Signed-off-by Jeff Layton<[email protected]>--- utils/mount/network.c | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-)utils/mount/network.c +9
-2@@ -1334,9 +1334,26 @@ nfs_nfs_port(struct mount_options *options, unsigned long *port)#ifdef IPV6_SUPPORTED sa_family_t config_default_family =AF_UNSPEC ; -#else + +static int +nfs_verify_family (sa_family_t family) +{ +return 1 ; +} +#else /* IPV6_SUPPORTED */ sa_family_t config_default_family =AF_INET ; -#endif + +static int
Quoted 9 lines
utils/mount/network.c nfs_nfs_port(struct mount_options *options, unsigned long *port) · line 1351
Quoted 5 lines
utils/mount/network.c +5
-0+nfs_verify_family(sa_family_t family) +{ +if (family !=AF_INET ) { + errno =EAFNOSUPPORT ; +return 0 ;I assume you do this so that mount.nfs emits a proper error message in this case. What about below where
nfs_get_proto()returns false?
Yep, otherwise if you specify a "Defaultproto=tcp6" in the config file, you'll get:
mount.nfs: Unable to set default family : Success
...which is a little confusing.
I'm not sure what to do about nfs_get_proto returning false. default_value() calls this before the address family stuff:
if (!nfs_nfs_protocol(options, &config_default_proto)) {
xlog_warn("Unable to set default protocol : %s",
strerror(errno));
}...and I assume that it'll also always display "Success" there too, since errno doesn't seem to be set by nfs_get_proto. Maybe nfs_get_proto() should set errno?
Again though, that sort of seems like a separate patch from this.
Quoted 26 lines
Quoted 12 lines
utils/mount/network.c +5
-0+ } + +return 1 ; +} +#endif /* IPV6_SUPPORTED */ /* * Returns TRUE and fills in @family if a valid NFS protocol option @@ -1357,15 +1374,15 @@ int nfs_nfs_proto_family(struct mount_options *options,return 1 ;case 2 :/* proto */ option =po_get (options,"proto" );utils/mount/network.c int nfs_nfs_proto_family(struct mount_options *options, · line 1384
Quoted 10 lines
utils/mount/network.c +2
-2-if (option !=NULL ) -return nfs_get_proto (option, family,&protocol); +if (option !=NULL && !nfs_get_proto (option, family,&protocol)) +return 0 ; }/* * NFS transport protocol wasn't specified. Return the * default address family. */ It would help if this comment mentioned why you need to verify *family in the default case.
Quoted 2 lines
utils/mount/network.c int nfs_nfs_proto_family(struct mount_options *options, · line 1385
Quoted 2 lines
utils/mount/network.c +1
-1-return 1 ; +return nfs_verify_family (*family);
I suppose we don't really need to check it for the default case. I just did that since it made fewer conditionals in the code. I can reorganize it so that it's not needed if that'll be clearer.
Quoted 18 lines
Quoted 17 lines
utils/mount/network.c +5
-2}/* @@ -1494,8 +1511,11 @@ int nfs_mount_proto_family(struct mount_options *options, *family = config_default_family; option =po_get (options,"mountproto" ); -if (option !=NULL ) -return nfs_get_proto (option, family,&protocol); +if (option !=NULL ) { +if (!nfs_get_proto (option, family,&protocol)) +return 0 ; +return nfs_verify_family (*family); + }/* * MNT transport protocol wasn't specified. If the NFS
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20100208124312.68087e78-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Quoted 53 lines · Jeff Layton
Quoted 33 lines · On Mon, 08 Feb 2010 12:27:24 -0500 Chuck Lever<[email protected]> wrote:
Quoted 32 lines · Jeff Layton
Right now, there's nothing that expressly forbids someone from specifying proto=tcp6 for instance, even when nfs-utils it built without IPv6 support. This may not work well if (for instance) they are using NFSv3, since statd won't support IPv6. Explicitly return an error if someone specifies an IPv6 proto= or mountproto= option and IPv6 isn't supported.
Signed-off-by Jeff Layton<[email protected]>--- utils/mount/network.c | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-)utils/mount/network.c +9
-2@@ -1334,9 +1334,26 @@ nfs_nfs_port(struct mount_options *options, unsigned long *port)#ifdef IPV6_SUPPORTED sa_family_t config_default_family =AF_UNSPEC ; -#else + +static int +nfs_verify_family (sa_family_t family) +{ +return 1 ; +} +#else /* IPV6_SUPPORTED */ sa_family_t config_default_family =AF_INET ; -#endif + +static intQuoted 9 lines
utils/mount/network.c nfs_nfs_port(struct mount_options *options, unsigned long *port) · line 1351
Quoted 5 lines
utils/mount/network.c +5
-0+nfs_verify_family(sa_family_t family) +{ +if (family !=AF_INET ) { + errno =EAFNOSUPPORT ; +return 0 ;I assume you do this so that mount.nfs emits a proper error message in this case. What about below where
nfs_get_proto()returns false?Yep, otherwise if you specify a "Defaultproto=tcp6" in the config file, you'll get:
mount.nfs: Unable to set default family : Success
...which is a little confusing.
Quoted 7 lines
I'm not sure what to do about
nfs_get_protoreturning false.default_value()calls this before the address family stuff:if (!nfs_nfs_protocol(options,&config_default_proto)) { xlog_warn("Unable to set default protocol : %s", strerror(errno)); }
By the way, "%m" is equivalent to "%s", strerror(errno)
Quoted 3 lines
...and I assume that it'll also always display "Success" there too, since errno doesn't seem to be set by
nfs_get_proto. Maybenfs_get_proto()should set errno?
Maybe.
I would think that nfs_nfs_protocol, being a part of the mount command proper, should worry about what error message mount.nfs should display.
The functions in getport.c are supposed to be more generic, and often
set the rpccreate_err fields instead of or in addition to errno. (Never mind that nobody but mount.nfs uses them).
So, I'd say you probably should have nfs_nfs_protocol set errno as needed, as you did with nfs_verify_family.
Quoted 55 lines
Again though, that sort of seems like a separate patch from this.
Quoted 26 lines
Quoted 12 lines
utils/mount/network.c +5
-0+ } + +return 1 ; +} +#endif /* IPV6_SUPPORTED */ /* * Returns TRUE and fills in @family if a valid NFS protocol option @@ -1357,15 +1374,15 @@ int nfs_nfs_proto_family(struct mount_options *options,return 1 ;case 2 :/* proto */ option =po_get (options,"proto" );utils/mount/network.c int nfs_nfs_proto_family(struct mount_options *options, · line 1384
Quoted 10 lines
utils/mount/network.c +2
-2-if (option !=NULL ) -return nfs_get_proto (option, family,&protocol); +if (option !=NULL && !nfs_get_proto (option, family,&protocol)) +return 0 ; }/* * NFS transport protocol wasn't specified. Return the * default address family. */ It would help if this comment mentioned why you need to verify *family in the default case.
Quoted 2 lines
utils/mount/network.c int nfs_nfs_proto_family(struct mount_options *options, · line 1385
Quoted 2 lines
utils/mount/network.c +1
-1-return 1 ; +return nfs_verify_family (*family);I suppose we don't really need to check it for the default case. I just did that since it made fewer conditionals in the code. I can reorganize it so that it's not needed if that'll be clearer.
Quoted 18 lines
Quoted 17 lines
utils/mount/network.c +5
-2}/* @@ -1494,8 +1511,11 @@ int nfs_mount_proto_family(struct mount_options *options, *family = config_default_family; option =po_get (options,"mountproto" ); -if (option !=NULL ) -return nfs_get_proto (option, family,&protocol); +if (option !=NULL ) { +if (!nfs_get_proto (option, family,&protocol)) +return 0 ; +return nfs_verify_family (*family); + }/* * MNT transport protocol wasn't specified. If the NFS
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com