Re: [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2012-04-24 at 16:35 -0400, Weston Andros Adamson wrote:
> All referrals (IPv4 addr, IPv6 addr, and DNS) are broken on mounts of
> IPv6 addresses, because validation code uses a path that is parsed
> from the dev_name ("<server>:<path>") by splitting on the first colon and
> colons are used in IPv6 addrs.
> This patch ignores colons within IPv6 addresses that are escaped by '[' and ']'.
> 
> Signed-off-by: Weston Andros Adamson <dros@xxxxxxxxxx>
> ---
> Reposted to address comments from Trond and Jim
> 
> This depends on commit 2f8e4bd91488f286e83e8abb14683102efaafb05
> "nfs: Enclose hostname in brackets when needed in nfs_do_root_mount".
> 
>  fs/nfs/nfs4namespace.c |   30 +++++++++++++++++++++++++++---
>  1 files changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
> index 9c8eca3..8c84e73 100644
> --- a/fs/nfs/nfs4namespace.c
> +++ b/fs/nfs/nfs4namespace.c
> @@ -52,6 +52,30 @@ Elong:
>  }
>  
>  /*
> + * return the path component of "<server>:<path>"
> + *  nfspath - the "<server>:<path>" string
> + *  end - one past the last char that could contain "<server>:"
> + * returns NULL on failure
> + */
> +static char *nfs_path_component(const char *nfspath, const char *end)
> +{
> +	char *p;
> +
> +	if (*nfspath == '[') {
> +		/* parse [] escaped IPv6 addrs */
> +		p = strchr(nfspath, ']');
> +		if (p != NULL && (p + 1) < end && *(++p) == ':')
				^^^^^^^^^ why not ++p?

> +			return p + 1;
> +	} else {
> +		/* otherwise split on first colon */
> +		p = strchr(nfspath, ':');
> +		if (p != NULL && p < end)
> +			return p + 1;
> +	}
> +	return NULL;
> +}
> +
> +/*
>   * Determine the mount path as a string
>   */
>  static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen)
> @@ -59,9 +83,9 @@ static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen)
>  	char *limit;
>  	char *path = nfs_path(&limit, dentry, buffer, buflen);
>  	if (!IS_ERR(path)) {
> -		char *colon = strchr(path, ':');
> -		if (colon && colon < limit)
> -			path = colon + 1;
> +		char *path_component = nfs_path_component(path, limit);
> +		if (path_component)
> +			return path_component;
>  	}
>  	return path;
>  }

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@xxxxxxxxxx
www.netapp.com

��.n��������+%������w��{.n�����{��w���jg��������ݢj����G�������j:+v���w�m������w�������h�����٥



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux