All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs
@ 2012-04-24 14:57 Weston Andros Adamson
  2012-04-24 15:19 ` Jim Rees
  2012-04-24 15:33 ` Myklebust, Trond
  0 siblings, 2 replies; 9+ messages in thread
From: Weston Andros Adamson @ 2012-04-24 14:57 UTC (permalink / raw)
  To: Trond.Myklebust; +Cc: chuck.lever, linux-nfs, Weston Andros Adamson

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@netapp.com>
---

This depends on commit 2f8e4bd91488f286e83e8abb14683102efaafb05
"nfs: Enclose hostname in brackets when needed in nfs_do_root_mount".

 fs/nfs/nfs4namespace.c |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 9c8eca3..307743d 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -52,6 +52,35 @@ Elong:
 }
 
 /*
+ * parse the path component of an nfs path ("<server>:<path>").
+ *  nfspath - the "<server>:<path>" string
+ *  end - pointer to end of devname component of 'nfspath'
+ * returns NULL on failure
+ */
+static inline char *nfs_parse_path_component(char *nfspath, char *end)
+{
+	bool ipv6_esc = false;
+	char *p;
+
+	/* find first colon not in IPv6 addr */
+	for (p = nfspath; p < end && *p; p++) {
+		switch (*p) {
+		case '[':
+			ipv6_esc = true;
+			break;
+		case ']':
+			ipv6_esc = false;
+			break;
+		case ':':
+			if (!ipv6_esc)
+				return (p + 1);
+			break;
+		}
+	}
+	return NULL;
+}
+
+/*
  * Determine the mount path as a string
  */
 static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen)
@@ -59,9 +88,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_parse_path_component(path, limit);
+		if (path_component)
+			return path_component;
 	}
 	return path;
 }
-- 
1.7.4.4


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

* Re: [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs
  2012-04-24 14:57 [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs Weston Andros Adamson
@ 2012-04-24 15:19 ` Jim Rees
  2012-04-24 16:20   ` Adamson, Dros
  2012-04-24 15:33 ` Myklebust, Trond
  1 sibling, 1 reply; 9+ messages in thread
From: Jim Rees @ 2012-04-24 15:19 UTC (permalink / raw)
  To: Weston Andros Adamson; +Cc: Trond.Myklebust, chuck.lever, linux-nfs

Weston Andros Adamson wrote:

  diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
  index 9c8eca3..307743d 100644
  --- a/fs/nfs/nfs4namespace.c
  +++ b/fs/nfs/nfs4namespace.c
  @@ -52,6 +52,35 @@ Elong:
   }
   
   /*
  + * parse the path component of an nfs path ("<server>:<path>").
  + *  nfspath - the "<server>:<path>" string
  + *  end - pointer to end of devname component of 'nfspath'
  + * returns NULL on failure
  + */

The comment seems odd to me.  You're not parsing the path component, you're
parsing the nfspath to return the path.  And the term "devname component"
hasn't been defined anywhere.  How about this:

Return the path component of an nfs path ("<server>:<path>").
 nfspath - the "<server>:<path>" string
 end - pointer to end of nfspath
returns NULL on failure

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

* Re: [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs
  2012-04-24 14:57 [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs Weston Andros Adamson
  2012-04-24 15:19 ` Jim Rees
@ 2012-04-24 15:33 ` Myklebust, Trond
  2012-04-24 16:17   ` Adamson, Dros
  1 sibling, 1 reply; 9+ messages in thread
From: Myklebust, Trond @ 2012-04-24 15:33 UTC (permalink / raw)
  To: Adamson, Dros; +Cc: chuck.lever, linux-nfs

T24gVHVlLCAyMDEyLTA0LTI0IGF0IDEwOjU3IC0wNDAwLCBXZXN0b24gQW5kcm9zIEFkYW1zb24g
d3JvdGU6DQo+IEFsbCByZWZlcnJhbHMgKElQdjQgYWRkciwgSVB2NiBhZGRyLCBhbmQgRE5TKSBh
cmUgYnJva2VuIG9uIG1vdW50cyBvZg0KPiBJUHY2IGFkZHJlc3NlcywgYmVjYXVzZSB2YWxpZGF0
aW9uIGNvZGUgdXNlcyBhIHBhdGggdGhhdCBpcyBwYXJzZWQNCj4gZnJvbSB0aGUgZGV2X25hbWUg
KCI8c2VydmVyPjo8cGF0aD4iKSBieSBzcGxpdHRpbmcgb24gdGhlIGZpcnN0IGNvbG9uIGFuZA0K
PiBjb2xvbnMgYXJlIHVzZWQgaW4gSVB2NiBhZGRycy4NCj4gVGhpcyBwYXRjaCBpZ25vcmVzIGNv
bG9ucyB3aXRoaW4gSVB2NiBhZGRyZXNzZXMgdGhhdCBhcmUgZXNjYXBlZCBieSAnWycgYW5kICdd
Jy4NCj4gDQo+IFNpZ25lZC1vZmYtYnk6IFdlc3RvbiBBbmRyb3MgQWRhbXNvbiA8ZHJvc0BuZXRh
cHAuY29tPg0KPiAtLS0NCj4gDQo+IFRoaXMgZGVwZW5kcyBvbiBjb21taXQgMmY4ZTRiZDkxNDg4
ZjI4NmU4M2U4YWJiMTQ2ODMxMDJlZmFhZmIwNQ0KPiAibmZzOiBFbmNsb3NlIGhvc3RuYW1lIGlu
IGJyYWNrZXRzIHdoZW4gbmVlZGVkIGluIG5mc19kb19yb290X21vdW50Ii4NCj4gDQo+ICBmcy9u
ZnMvbmZzNG5hbWVzcGFjZS5jIHwgICAzNSArKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr
Ky0tLQ0KPiAgMSBmaWxlcyBj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ounts that use IPv6 addrs
  2012-04-24 15:33 ` Myklebust, Trond
@ 2012-04-24 16:17   ` Adamson, Dros
  0 siblings, 0 replies; 9+ messages in thread
From: Adamson, Dros @ 2012-04-24 16:17 UTC (permalink / raw)
  To: Myklebust, Trond; +Cc: Adamson, Dros, chuck.lever, linux-nfs

[-- Attachment #1: Type: text/plain, Size: 3425 bytes --]


On Apr 24, 2012, at 11:33 AM, Myklebust, Trond wrote:

> On Tue, 2012-04-24 at 10:57 -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@netapp.com>
>> ---
>> 
>> This depends on commit 2f8e4bd91488f286e83e8abb14683102efaafb05
>> "nfs: Enclose hostname in brackets when needed in nfs_do_root_mount".
>> 
>> fs/nfs/nfs4namespace.c |   35 ++++++++++++++++++++++++++++++++---
>> 1 files changed, 32 insertions(+), 3 deletions(-)
>> 
>> diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
>> index 9c8eca3..307743d 100644
>> --- a/fs/nfs/nfs4namespace.c
>> +++ b/fs/nfs/nfs4namespace.c
>> @@ -52,6 +52,35 @@ Elong:
>> }
>> 
>> /*
>> + * parse the path component of an nfs path ("<server>:<path>").
>> + *  nfspath - the "<server>:<path>" string
>> + *  end - pointer to end of devname component of 'nfspath'
>> + * returns NULL on failure
>> + */
>> +static inline char *nfs_parse_path_component(char *nfspath, char *end)
> 
> Nit: this is really parsing the server name component of the devname.
> 
> Also, please make the 'end' argument 'const char *', and  drop the
> 'inline' declaration.

OK.

> 
>> +{
>> +	bool ipv6_esc = false;
>> +	char *p;
>> +
>> +	/* find first colon not in IPv6 addr */
>> +	for (p = nfspath; p < end && *p; p++) {
>> +		switch (*p) {
>> +		case '[':
>> +			ipv6_esc = true;
> 
> Note that if p != nfspath, then we have a problem. The '[' _must_ be the
> first character in the server name, and there _must_ be a matching ']'
> at the end.
> So how about optimising this using something along the lines of:
> 
> 	p = nfspath;
> 	/* Handle escaped hostnames */
> 	if (*p == '[') {
> 		p = strchr(p, ']');
> 		if (p == NULL)
> 			return NULL;
> 	}
> 	p = strchr(p, ':');
> 	if (p != NULL)
> 		p++;
> 	return p;

OK, I'll change it to be more strict.  Note that your suggestion doesn't enforce that the matching ']' is at the end of the hostname (next char ':').

>> +			break;
>> +		case ':':
>> +			if (!ipv6_esc)
>> +				return (p + 1);
>> +			break;
>> +		}
>> +	}
>> +	return NULL;
>> +}
>> +
>> +/*
>>  * Determine the mount path as a string
>>  */
>> static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen)
>> @@ -59,9 +88,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_parse_path_component(path, limit);
>> +		if (path_component)
>> +			return path_component;
>> 	}
>> 	return path;
>> }
> 
> So this fixes the problem of parsing the devname, but how about the
> issue of setting the correct devname if the server supplies an IPv6
> address as the hostname?

That is covered by the patch you sent me (commit 2f8e4bd91488f286e83e8abb14683102efaafb05).  I thought you'd just use that patch - it's what I tested with.

-dros

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 1374 bytes --]

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

* Re: [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs
  2012-04-24 15:19 ` Jim Rees
@ 2012-04-24 16:20   ` Adamson, Dros
  0 siblings, 0 replies; 9+ messages in thread
From: Adamson, Dros @ 2012-04-24 16:20 UTC (permalink / raw)
  To: Jim Rees
  Cc: Myklebust, Trond, <chuck.lever@oracle.com>,
	<linux-nfs@vger.kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1167 bytes --]


On Apr 24, 2012, at 11:19 AM, Jim Rees wrote:

> Weston Andros Adamson wrote:
> 
>  diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
>  index 9c8eca3..307743d 100644
>  --- a/fs/nfs/nfs4namespace.c
>  +++ b/fs/nfs/nfs4namespace.c
>  @@ -52,6 +52,35 @@ Elong:
>   }
> 
>   /*
>  + * parse the path component of an nfs path ("<server>:<path>").
>  + *  nfspath - the "<server>:<path>" string
>  + *  end - pointer to end of devname component of 'nfspath'
>  + * returns NULL on failure
>  + */
> 
> The comment seems odd to me.  You're not parsing the path component, you're
> parsing the nfspath to return the path.  And the term "devname component"
> hasn't been defined anywhere.  How about this:
> 
> Return the path component of an nfs path ("<server>:<path>").

Yeah, OK.

> nfspath - the "<server>:<path>" string
> end - pointer to end of nfspath

Well, that's not really true.  "end" comes from the call to nfs_path() and points to the end of the devname component of the nfs_path, i.e.:

if "[fc00::10]:/export" is mounted:

[fc00::10]:/export/foo/bar
                  ^end

> returns NULL on failure

-dros

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 1374 bytes --]

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

* [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs
@ 2012-04-24 20:50 Weston Andros Adamson
  0 siblings, 0 replies; 9+ messages in thread
From: Weston Andros Adamson @ 2012-04-24 20:50 UTC (permalink / raw)
  To: Trond.Myklebust; +Cc: chuck.lever, linux-nfs, Weston Andros Adamson

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@netapp.com>
---
Reposted again to address a comment from Trond

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..7483a17 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 < end && *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;
 }
-- 
1.7.4.4


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

* Re: [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs
  2012-04-24 20:35 Weston Andros Adamson
@ 2012-04-24 20:42 ` Myklebust, Trond
  0 siblings, 0 replies; 9+ messages in thread
From: Myklebust, Trond @ 2012-04-24 20:42 UTC (permalink / raw)
  To: Adamson, Dros; +Cc: chuck.lever, linux-nfs

T24gVHVlLCAyMDEyLTA0LTI0IGF0IDE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AuY29tDQoNCg==

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

* [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs
@ 2012-04-24 20:35 Weston Andros Adamson
  2012-04-24 20:42 ` Myklebust, Trond
  0 siblings, 1 reply; 9+ messages in thread
From: Weston Andros Adamson @ 2012-04-24 20:35 UTC (permalink / raw)
  To: Trond.Myklebust; +Cc: chuck.lever, linux-nfs, Weston Andros Adamson

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@netapp.com>
---
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) == ':')
+			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;
 }
-- 
1.7.4.4


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

* [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs
@ 2012-04-24 15:07 Weston Andros Adamson
  0 siblings, 0 replies; 9+ messages in thread
From: Weston Andros Adamson @ 2012-04-24 15:07 UTC (permalink / raw)
  To: Trond.Myklebust; +Cc: chuck.lever, linux-nfs, Weston Andros Adamson

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@netapp.com>
---

Updated to pass checkpatch.pl - sorry for posting twice!

This depends on commit 2f8e4bd91488f286e83e8abb14683102efaafb05
"nfs: Enclose hostname in brackets when needed in nfs_do_root_mount".

 fs/nfs/nfs4namespace.c |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 9c8eca3..f90c7b3 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -52,6 +52,35 @@ Elong:
 }
 
 /*
+ * parse the path component of an nfs path ("<server>:<path>").
+ *  nfspath - the "<server>:<path>" string
+ *  end - pointer to end of devname component of 'nfspath'
+ * returns NULL on failure
+ */
+static inline char *nfs_parse_path_component(char *nfspath, char *end)
+{
+	bool ipv6_esc = false;
+	char *p;
+
+	/* find first colon not in IPv6 addr */
+	for (p = nfspath; p < end && *p; p++) {
+		switch (*p) {
+		case '[':
+			ipv6_esc = true;
+			break;
+		case ']':
+			ipv6_esc = false;
+			break;
+		case ':':
+			if (!ipv6_esc)
+				return p + 1;
+			break;
+		}
+	}
+	return NULL;
+}
+
+/*
  * Determine the mount path as a string
  */
 static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen)
@@ -59,9 +88,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_parse_path_component(path, limit);
+		if (path_component)
+			return path_component;
 	}
 	return path;
 }
-- 
1.7.4.4


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

end of thread, other threads:[~2012-04-24 20:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-24 14:57 [PATCH] nfs4: fix referrals on mounts that use IPv6 addrs Weston Andros Adamson
2012-04-24 15:19 ` Jim Rees
2012-04-24 16:20   ` Adamson, Dros
2012-04-24 15:33 ` Myklebust, Trond
2012-04-24 16:17   ` Adamson, Dros
2012-04-24 15:07 Weston Andros Adamson
2012-04-24 20:35 Weston Andros Adamson
2012-04-24 20:42 ` Myklebust, Trond
2012-04-24 20:50 Weston Andros Adamson

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.