2007-11-30 01:22:59

by Trond Myklebust

[permalink] [raw]
Subject: Re: [NFS] [PATCH 14/29] NFS: Set default port for NFSv4, with support for AF_INET6


On Thu, 2007-11-29 at 14:41 -0500, Chuck Lever wrote:
> Move more address family dependencies to a helper function.
>
> Signed-off-by: Chuck Lever <[email protected]>
> ---
>
> fs/nfs/super.c | 30 ++++++++++++++++++++++++++----
> 1 files changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index 6377098..6a9192f 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -1570,6 +1570,28 @@ static void nfs4_fill_super(struct super_block *sb)
> }
>
> /*
> + * If the user didn't specify a port, set the port number to
> + * the NFS version 4 default port.
> + */
> +static void nfs4_default_port(struct sockaddr_storage *ssp)
> +{
> + switch (ssp->ss_family) {
> + case AF_INET: {
> + struct sockaddr_in *ap = (struct sockaddr_in *)ssp;
> + if (ap->sin_port == 0)
> + ap->sin_port = htons(NFS_PORT);
> + break;
> + }
> + case AF_INET6: {
> + struct sockaddr_in6 *ap = (struct sockaddr_in6 *)ssp;
> + if (ap->sin6_port == 0)
> + ap->sin6_port = htons(NFS_PORT);
> + break;
> + }
> + }
> +}
> +
> +/*
> * Validate NFSv4 mount options
> */
> static int nfs4_validate_mount_data(void *options,
> @@ -1602,12 +1624,12 @@ static int nfs4_validate_mount_data(void *options,
> data->host_addr,
> sizeof(args->nfs_server.address)))
> return -EFAULT;
> - if (args->nfs_server.address.sin_port == 0)
> - args->nfs_server.address.sin_port = htons(NFS_PORT);
> if (!nfs_verify_server_address((void *)
> &args->nfs_server.address))
> goto out_no_address;
>
> + nfs4_default_port((void *)&args->nfs_server.address);
^^^^^^^^ Eeeewwwww
> +
> switch (data->auth_flavourlen) {
> case 0:
> args->auth_flavors[0] = RPC_AUTH_UNIX;
> @@ -1661,12 +1683,12 @@ static int nfs4_validate_mount_data(void *options,
> if (nfs_parse_mount_options((char *)options, args) == 0)
> return -EINVAL;
>
> - if (args->nfs_server.address.sin_port == 0)
> - args->nfs_server.address.sin_port = htons(NFS_PORT);
> if (!nfs_verify_server_address((void *)
> &args->nfs_server.address))
> return -EINVAL;
>
> + nfs4_default_port((void *)&args->nfs_server.address);
> +
> switch (args->auth_flavor_len) {
> case 0:
> args->auth_flavors[0] = RPC_AUTH_UNIX;
>


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
_______________________________________________
Please note that [email protected] is being discontinued.
Please subscribe to [email protected] instead.
http://vger.kernel.org/vger-lists.html#linux-nfs