From: Peter Staubach <staubach@redhat.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: trond.myklebust@netapp.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 2/4] NFS: Support raw IPv6 address hostnames during NFS mount operation
Date: Wed, 18 Jun 2008 18:35:35 -0400 [thread overview]
Message-ID: <48598DB7.4060404@redhat.com> (raw)
In-Reply-To: <20080618223203.16006.61765.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
Chuck Lever wrote:
> Traditionally the mount command has looked for a ":" to separate the
> server's hostname from the export path in the mounted on device name,
> like this:
>
> mount server:/export /mounted/on/dir
>
> The server's hostname is "server" and the export path is "/export".
>
> You can also substitute a specific IPv4 network address for the server
> hostname, like this:
>
> mount 192.168.0.55:/export /mounted/on/dir
>
> Raw IPv6 addresses present a problem, however, because they look
> something like this:
>
> fe80::200:5aff:fe00:30b
>
> Note the use of colons.
>
> To get around the presence of colons, copy the Solaris convention used for
> mounting IPv6 servers by address: wrap a raw IPv6 address with square
> brackets.
>
>
It seems unfortunate that the convention couldn't have been to
look for the first instance of ":/" and break the strings there.
ps
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>
> fs/nfs/super.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
> 1 files changed, 82 insertions(+), 8 deletions(-)
>
>
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index 5e0eefa..98c8110 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -1215,14 +1215,9 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args,
> return status;
> }
>
> -/*
> - * Split "dev_name" into "hostname:export_path".
> - *
> - * Note: caller frees hostname and export path, even on error.
> - */
> -static int nfs_parse_devname(const char *dev_name,
> - char **hostname, size_t maxnamlen,
> - char **export_path, size_t maxpathlen)
> +static int nfs_parse_simple_hostname(const char *dev_name,
> + char **hostname, size_t maxnamlen,
> + char **export_path, size_t maxpathlen)
> {
> size_t len;
> char *colon, *comma;
> @@ -1277,6 +1272,85 @@ out_path:
> }
>
> /*
> + * Hostname has square brackets around it because it contains one or
> + * more colons. We look for the first closing square bracket, and a
> + * colon must follow it.
> + */
> +static int nfs_parse_protected_hostname(const char *dev_name,
> + char **hostname, size_t maxnamlen,
> + char **export_path, size_t maxpathlen)
> +{
> + size_t len;
> + char *start, *end;
> +
> + start = (char *)(dev_name + 1);
> +
> + end = strchr(start, ']');
> + if (end == NULL)
> + goto out_bad_devname;
> + if (*(end + 1) != ':')
> + goto out_bad_devname;
> +
> + len = end - start;
> + if (len > maxnamlen)
> + goto out_hostname;
> +
> + /* N.B. caller will free nfs_server.hostname in all cases */
> + *hostname = kstrndup(start, len, GFP_KERNEL);
> + if (*hostname == NULL)
> + goto out_nomem;
> +
> + end += 2;
> + len = strlen(end);
> + if (len > maxpathlen)
> + goto out_path;
> + *export_path = kstrndup(end, len, GFP_KERNEL);
> + if (!*export_path)
> + goto out_nomem;
> +
> + return 0;
> +
> +out_bad_devname:
> + dfprintk(MOUNT, "NFS: device name not in host:path format\n");
> + return -EINVAL;
> +
> +out_nomem:
> + dfprintk(MOUNT, "NFS: not enough memory to parse device name\n");
> + return -ENOMEM;
> +
> +out_hostname:
> + dfprintk(MOUNT, "NFS: server hostname too long\n");
> + return -ENAMETOOLONG;
> +
> +out_path:
> + dfprintk(MOUNT, "NFS: export pathname too long\n");
> + return -ENAMETOOLONG;
> +}
> +
> +/*
> + * Split "dev_name" into "hostname:export_path".
> + *
> + * The leftmost colon demarks the split between the server's hostname
> + * and the export path. If the hostname starts with a left square
> + * bracket, then it may contain colons.
> + *
> + * Note: caller frees hostname and export path, even on error.
> + */
> +static int nfs_parse_devname(const char *dev_name,
> + char **hostname, size_t maxnamlen,
> + char **export_path, size_t maxpathlen)
> +{
> + if (*dev_name == '[')
> + return nfs_parse_protected_hostname(dev_name,
> + hostname, maxnamlen,
> + export_path, maxpathlen);
> +
> + return nfs_parse_simple_hostname(dev_name,
> + hostname, maxnamlen,
> + export_path, maxpathlen);
> +}
> +
> +/*
> * Validate the NFS2/NFS3 mount data
> * - fills in the mount root filehandle
> *
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2008-06-18 22:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-18 22:31 [PATCH 0/4] NFS mounting with raw IPv6 server hostnames (take 2) Chuck Lever
[not found] ` <20080618222951.16006.3679.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-06-18 22:31 ` [PATCH 1/4] NFS: Use common device name parsing logic for NFSv4 and NFSv2/v3 Chuck Lever
2008-06-18 22:32 ` [PATCH 2/4] NFS: Support raw IPv6 address hostnames during NFS mount operation Chuck Lever
[not found] ` <20080618223203.16006.61765.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-06-18 22:35 ` Peter Staubach [this message]
2008-06-18 22:42 ` Chuck Lever
2008-06-18 22:51 ` Trond Myklebust
2008-06-18 22:59 ` Peter Staubach
2008-06-18 22:32 ` [PATCH 3/4] NFS: Add string length argument to nfs_parse_server_address Chuck Lever
[not found] ` <20080618223211.16006.8247.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-06-19 17:43 ` Trond Myklebust
2008-06-18 22:32 ` [PATCH 4/4] NFS: handle interface identifiers in incoming IPv6 addresses Chuck Lever
-- strict thread matches above, loose matches on Subject: below --
2008-06-23 16:36 [PATCH 0/4] NFS mounting with raw IPv6 server hostnames (take 3) Chuck Lever
[not found] ` <20080623163129.10539.15565.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-06-23 16:36 ` [PATCH 2/4] NFS: Support raw IPv6 address hostnames during NFS mount operation Chuck Lever
2008-06-17 18:17 [PATCH 0/4] NFS mounting with raw IPv6 server hostnames Chuck Lever
[not found] ` <20080617181622.3215.61295.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org>
2008-06-17 18:17 ` [PATCH 2/4] NFS: Support raw IPv6 address hostnames during NFS mount operation Chuck Lever
2008-05-18 21:19 [PATCH 0/4] RFC: raw IPv6 address parsing in NFS client Chuck Lever
2008-05-18 21:20 ` [PATCH 2/4] NFS: Support raw IPv6 address hostnames during NFS mount operation Chuck Lever
2008-05-18 22:23 ` Trond Myklebust
2008-05-19 14:48 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48598DB7.4060404@redhat.com \
--to=staubach@redhat.com \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@netapp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.