提交 1aba1567 编写于 作者: W Weston Andros Adamson 提交者: Trond Myklebust

nfs4: fix referrals on mounts that use IPv6 addrs

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: NWeston Andros Adamson <dros@netapp.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 2300fd67
...@@ -51,6 +51,30 @@ static inline char *nfs4_pathname_string(const struct nfs4_pathname *pathname, ...@@ -51,6 +51,30 @@ static inline char *nfs4_pathname_string(const struct nfs4_pathname *pathname,
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
} }
/*
* 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 * Determine the mount path as a string
*/ */
...@@ -59,9 +83,9 @@ 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 *limit;
char *path = nfs_path(&limit, dentry, buffer, buflen); char *path = nfs_path(&limit, dentry, buffer, buflen);
if (!IS_ERR(path)) { if (!IS_ERR(path)) {
char *colon = strchr(path, ':'); char *path_component = nfs_path_component(path, limit);
if (colon && colon < limit) if (path_component)
path = colon + 1; return path_component;
} }
return path; return path;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册