All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs: Enclose hostname in brackets when needed in nfs_do_root_mount
@ 2011-09-02 23:09 Jan Kara
  2011-09-02 23:23 ` Myklebust, Trond
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2011-09-02 23:09 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: linux-nfs, Jan Kara, Josh Boyer, Trond Myklebust

When hostname contains colon (e.g. when it is an IPv6 address) it needs
to be enclosed in brackets to make parsing of NFS device string possible.
Fix nfs_do_root_mount() to enclose hostname properly when needed. NFS code
actually does not need this as it does not parse the string passed by
nfs_do_root_mount() but the device string is exposed to userspace in
/proc/mounts.

CC: Josh Boyer <jwboyer@redhat.com>
CC: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/nfs/super.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index b961cea..42b74f8 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2694,11 +2694,15 @@ static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type,
 	char *root_devname;
 	size_t len;
 
-	len = strlen(hostname) + 3;
+	len = strlen(hostname) + 5;
 	root_devname = kmalloc(len, GFP_KERNEL);
 	if (root_devname == NULL)
 		return ERR_PTR(-ENOMEM);
-	snprintf(root_devname, len, "%s:/", hostname);
+	/* Does hostname needs to be enclosed in brackets? */
+	if (strchr(hostname, ':'))
+		snprintf(root_devname, len, "[%s]:/", hostname);
+	else
+		snprintf(root_devname, len, "%s:/", hostname);
 	root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data);
 	kfree(root_devname);
 	return root_mnt;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH] nfs: Enclose hostname in brackets when needed in nfs_do_root_mount
  2011-09-02 23:09 [PATCH] nfs: Enclose hostname in brackets when needed in nfs_do_root_mount Jan Kara
@ 2011-09-02 23:23 ` Myklebust, Trond
  2011-09-03  0:22   ` Jan Kara
  0 siblings, 1 reply; 5+ messages in thread
From: Myklebust, Trond @ 2011-09-02 23:23 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-nfs, Josh Boyer

> -----Original Message-----
> From: Jan Kara [mailto:jack@suse.cz]
> Sent: Friday, September 02, 2011 7:10 PM
> To: Myklebust, Trond
> Cc: linux-nfs@vger.kernel.org; Jan Kara; Josh Boyer; Myklebust, Trond
> Subject: [PATCH] nfs: Enclose hostname in brackets when needed in
> nfs_do_root_mount
> 
> When hostname contains colon (e.g. when it is an IPv6 address) it
needs
> to be enclosed in brackets to make parsing of NFS device string
> possible.
> Fix nfs_do_root_mount() to enclose hostname properly when needed. NFS
> code
> actually does not need this as it does not parse the string passed by
> nfs_do_root_mount() but the device string is exposed to userspace in
> /proc/mounts.
> 
> CC: Josh Boyer <jwboyer@redhat.com>
> CC: Trond Myklebust <Trond.Myklebust@netapp.com>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  fs/nfs/super.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index b961cea..42b74f8 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -2694,11 +2694,15 @@ static struct vfsmount
> *nfs_do_root_mount(struct file_system_type *fs_type,
>  	char *root_devname;
>  	size_t len;
> 
> -	len = strlen(hostname) + 3;
> +	len = strlen(hostname) + 5;
>  	root_devname = kmalloc(len, GFP_KERNEL);
>  	if (root_devname == NULL)
>  		return ERR_PTR(-ENOMEM);
> -	snprintf(root_devname, len, "%s:/", hostname);
> +	/* Does hostname needs to be enclosed in brackets? */
> +	if (strchr(hostname, ':'))
> +		snprintf(root_devname, len, "[%s]:/", hostname);
> +	else
> +		snprintf(root_devname, len, "%s:/", hostname);

What if the hostname is already enclosed in brackets, as is usually the
case if I enter an IPv6 address instead of a DNS name? Won't this cause
it to be bracketed twice?

IOW: If I try to

	mount -t nfs [fe80::20c:29ff:fee9:83e6]:/export /mnt

won't the above end up returning a hostname of [[::20c:29ff:fee9:83e6]]?

Cheers
   Trond

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfs: Enclose hostname in brackets when needed in nfs_do_root_mount
  2011-09-02 23:23 ` Myklebust, Trond
@ 2011-09-03  0:22   ` Jan Kara
  2011-11-08 13:06     ` Jan Kara
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2011-09-03  0:22 UTC (permalink / raw)
  To: Myklebust, Trond; +Cc: Jan Kara, linux-nfs, Josh Boyer

On Fri 02-09-11 16:23:43, Myklebust, Trond wrote:
> > -----Original Message-----
> > From: Jan Kara [mailto:jack@suse.cz]
> > Sent: Friday, September 02, 2011 7:10 PM
> > To: Myklebust, Trond
> > Cc: linux-nfs@vger.kernel.org; Jan Kara; Josh Boyer; Myklebust, Trond
> > Subject: [PATCH] nfs: Enclose hostname in brackets when needed in
> > nfs_do_root_mount
> > 
> > When hostname contains colon (e.g. when it is an IPv6 address) it
> needs
> > to be enclosed in brackets to make parsing of NFS device string
> > possible.
> > Fix nfs_do_root_mount() to enclose hostname properly when needed. NFS
> > code
> > actually does not need this as it does not parse the string passed by
> > nfs_do_root_mount() but the device string is exposed to userspace in
> > /proc/mounts.
> > 
> > CC: Josh Boyer <jwboyer@redhat.com>
> > CC: Trond Myklebust <Trond.Myklebust@netapp.com>
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> >  fs/nfs/super.c |    8 ++++++--
> >  1 files changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> > index b961cea..42b74f8 100644
> > --- a/fs/nfs/super.c
> > +++ b/fs/nfs/super.c
> > @@ -2694,11 +2694,15 @@ static struct vfsmount
> > *nfs_do_root_mount(struct file_system_type *fs_type,
> >  	char *root_devname;
> >  	size_t len;
> > 
> > -	len = strlen(hostname) + 3;
> > +	len = strlen(hostname) + 5;
> >  	root_devname = kmalloc(len, GFP_KERNEL);
> >  	if (root_devname == NULL)
> >  		return ERR_PTR(-ENOMEM);
> > -	snprintf(root_devname, len, "%s:/", hostname);
> > +	/* Does hostname needs to be enclosed in brackets? */
> > +	if (strchr(hostname, ':'))
> > +		snprintf(root_devname, len, "[%s]:/", hostname);
> > +	else
> > +		snprintf(root_devname, len, "%s:/", hostname);
> 
> What if the hostname is already enclosed in brackets, as is usually the
> case if I enter an IPv6 address instead of a DNS name? Won't this cause
> it to be bracketed twice?
> 
> IOW: If I try to
> 
> 	mount -t nfs [fe80::20c:29ff:fee9:83e6]:/export /mnt
> 
> won't the above end up returning a hostname of [[::20c:29ff:fee9:83e6]]?
  No it won't - I've actually verified my patch with experiment ;). The
hostname nfs_do_root_mount() gets is already without possible brackets
(these have been removed when we first parsed the string passed from
userspace by nfs_parse_devname() - yes, it took me some time to drill
through the NFS call stack during mount to actually find out who removes
the brackets from the passed hostname and who composes the device name back
without them).

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfs: Enclose hostname in brackets when needed in nfs_do_root_mount
  2011-09-03  0:22   ` Jan Kara
@ 2011-11-08 13:06     ` Jan Kara
  2011-12-20 13:41       ` Josh Boyer
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2011-11-08 13:06 UTC (permalink / raw)
  To: Myklebust, Trond; +Cc: linux-nfs, Josh Boyer

On Sat 03-09-11 02:22:31, Jan Kara wrote:
> On Fri 02-09-11 16:23:43, Myklebust, Trond wrote:
> > > -----Original Message-----
> > > From: Jan Kara [mailto:jack@suse.cz]
> > > Sent: Friday, September 02, 2011 7:10 PM
> > > To: Myklebust, Trond
> > > Cc: linux-nfs@vger.kernel.org; Jan Kara; Josh Boyer; Myklebust, Trond
> > > Subject: [PATCH] nfs: Enclose hostname in brackets when needed in
> > > nfs_do_root_mount
> > > 
> > > When hostname contains colon (e.g. when it is an IPv6 address) it
> > needs
> > > to be enclosed in brackets to make parsing of NFS device string
> > > possible.
> > > Fix nfs_do_root_mount() to enclose hostname properly when needed. NFS
> > > code
> > > actually does not need this as it does not parse the string passed by
> > > nfs_do_root_mount() but the device string is exposed to userspace in
> > > /proc/mounts.
> > > 
> > > CC: Josh Boyer <jwboyer@redhat.com>
> > > CC: Trond Myklebust <Trond.Myklebust@netapp.com>
> > > Signed-off-by: Jan Kara <jack@suse.cz>
> > > ---
> > >  fs/nfs/super.c |    8 ++++++--
> > >  1 files changed, 6 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> > > index b961cea..42b74f8 100644
> > > --- a/fs/nfs/super.c
> > > +++ b/fs/nfs/super.c
> > > @@ -2694,11 +2694,15 @@ static struct vfsmount
> > > *nfs_do_root_mount(struct file_system_type *fs_type,
> > >  	char *root_devname;
> > >  	size_t len;
> > > 
> > > -	len = strlen(hostname) + 3;
> > > +	len = strlen(hostname) + 5;
> > >  	root_devname = kmalloc(len, GFP_KERNEL);
> > >  	if (root_devname == NULL)
> > >  		return ERR_PTR(-ENOMEM);
> > > -	snprintf(root_devname, len, "%s:/", hostname);
> > > +	/* Does hostname needs to be enclosed in brackets? */
> > > +	if (strchr(hostname, ':'))
> > > +		snprintf(root_devname, len, "[%s]:/", hostname);
> > > +	else
> > > +		snprintf(root_devname, len, "%s:/", hostname);
> > 
> > What if the hostname is already enclosed in brackets, as is usually the
> > case if I enter an IPv6 address instead of a DNS name? Won't this cause
> > it to be bracketed twice?
> > 
> > IOW: If I try to
> > 
> > 	mount -t nfs [fe80::20c:29ff:fee9:83e6]:/export /mnt
> > 
> > won't the above end up returning a hostname of [[::20c:29ff:fee9:83e6]]?
>   No it won't - I've actually verified my patch with experiment ;). The
> hostname nfs_do_root_mount() gets is already without possible brackets
> (these have been removed when we first parsed the string passed from
> userspace by nfs_parse_devname() - yes, it took me some time to drill
> through the NFS call stack during mount to actually find out who removes
> the brackets from the passed hostname and who composes the device name back
> without them).
  Ping? Trond, will you merge the patch please? I guess it got somehow
lost.

								Honza

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfs: Enclose hostname in brackets when needed in nfs_do_root_mount
  2011-11-08 13:06     ` Jan Kara
@ 2011-12-20 13:41       ` Josh Boyer
  0 siblings, 0 replies; 5+ messages in thread
From: Josh Boyer @ 2011-12-20 13:41 UTC (permalink / raw)
  To: Jan Kara; +Cc: Myklebust, Trond, linux-nfs

On Tue, Nov 08, 2011 at 02:06:08PM +0100, Jan Kara wrote:
> On Sat 03-09-11 02:22:31, Jan Kara wrote:
> > On Fri 02-09-11 16:23:43, Myklebust, Trond wrote:
> > > > -----Original Message-----
> > > > From: Jan Kara [mailto:jack@suse.cz]
> > > > Sent: Friday, September 02, 2011 7:10 PM
> > > > To: Myklebust, Trond
> > > > Cc: linux-nfs@vger.kernel.org; Jan Kara; Josh Boyer; Myklebust, Trond
> > > > Subject: [PATCH] nfs: Enclose hostname in brackets when needed in
> > > > nfs_do_root_mount
> > > > 
> > > > When hostname contains colon (e.g. when it is an IPv6 address) it
> > > needs
> > > > to be enclosed in brackets to make parsing of NFS device string
> > > > possible.
> > > > Fix nfs_do_root_mount() to enclose hostname properly when needed. NFS
> > > > code
> > > > actually does not need this as it does not parse the string passed by
> > > > nfs_do_root_mount() but the device string is exposed to userspace in
> > > > /proc/mounts.
> > > > 
> > > > CC: Josh Boyer <jwboyer@redhat.com>
> > > > CC: Trond Myklebust <Trond.Myklebust@netapp.com>
> > > > Signed-off-by: Jan Kara <jack@suse.cz>
> > > > ---
> > > >  fs/nfs/super.c |    8 ++++++--
> > > >  1 files changed, 6 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> > > > index b961cea..42b74f8 100644
> > > > --- a/fs/nfs/super.c
> > > > +++ b/fs/nfs/super.c
> > > > @@ -2694,11 +2694,15 @@ static struct vfsmount
> > > > *nfs_do_root_mount(struct file_system_type *fs_type,
> > > >  	char *root_devname;
> > > >  	size_t len;
> > > > 
> > > > -	len = strlen(hostname) + 3;
> > > > +	len = strlen(hostname) + 5;
> > > >  	root_devname = kmalloc(len, GFP_KERNEL);
> > > >  	if (root_devname == NULL)
> > > >  		return ERR_PTR(-ENOMEM);
> > > > -	snprintf(root_devname, len, "%s:/", hostname);
> > > > +	/* Does hostname needs to be enclosed in brackets? */
> > > > +	if (strchr(hostname, ':'))
> > > > +		snprintf(root_devname, len, "[%s]:/", hostname);
> > > > +	else
> > > > +		snprintf(root_devname, len, "%s:/", hostname);
> > > 
> > > What if the hostname is already enclosed in brackets, as is usually the
> > > case if I enter an IPv6 address instead of a DNS name? Won't this cause
> > > it to be bracketed twice?
> > > 
> > > IOW: If I try to
> > > 
> > > 	mount -t nfs [fe80::20c:29ff:fee9:83e6]:/export /mnt
> > > 
> > > won't the above end up returning a hostname of [[::20c:29ff:fee9:83e6]]?
> >   No it won't - I've actually verified my patch with experiment ;). The
> > hostname nfs_do_root_mount() gets is already without possible brackets
> > (these have been removed when we first parsed the string passed from
> > userspace by nfs_parse_devname() - yes, it took me some time to drill
> > through the NFS call stack during mount to actually find out who removes
> > the brackets from the passed hostname and who composes the device name back
> > without them).
>   Ping? Trond, will you merge the patch please? I guess it got somehow
> lost.

Did this patch ever get queued up?  I don't see it in Linus' tree or
linux-next so I'm guessing no.  Is there a reason why?

josh

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-12-20 13:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-02 23:09 [PATCH] nfs: Enclose hostname in brackets when needed in nfs_do_root_mount Jan Kara
2011-09-02 23:23 ` Myklebust, Trond
2011-09-03  0:22   ` Jan Kara
2011-11-08 13:06     ` Jan Kara
2011-12-20 13:41       ` Josh Boyer

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.