NFSv4 handle port presence in fs_location server string
[ Upstream commit a8d54baba7c65db2d3278873def61f8d3753d766 ] An fs_location attribute returns a string that can be ipv4, ipv6, or DNS name. An ip location can have a port appended to it and if no port is present a default port needs to be set. If rpc_pton() fails to parse, try calling rpc_uaddr2socaddr() that can convert an universal address. Signed-off-by: Olga Kornievskaia <kolga@netapp.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
6f2974b52b
commit
b37dd03f2f
@@ -282,7 +282,7 @@ int nfs4_submount(struct fs_context *, struct nfs_server *);
|
|||||||
int nfs4_replace_transport(struct nfs_server *server,
|
int nfs4_replace_transport(struct nfs_server *server,
|
||||||
const struct nfs4_fs_locations *locations);
|
const struct nfs4_fs_locations *locations);
|
||||||
size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa,
|
size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa,
|
||||||
size_t salen, struct net *net);
|
size_t salen, struct net *net, int port);
|
||||||
/* nfs4proc.c */
|
/* nfs4proc.c */
|
||||||
extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *);
|
extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *);
|
||||||
extern int nfs4_async_handle_error(struct rpc_task *task,
|
extern int nfs4_async_handle_error(struct rpc_task *task,
|
||||||
|
@@ -165,16 +165,21 @@ static int nfs4_validate_fspath(struct dentry *dentry,
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa,
|
size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa,
|
||||||
size_t salen, struct net *net)
|
size_t salen, struct net *net, int port)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
ret = rpc_pton(net, string, len, sa, salen);
|
ret = rpc_pton(net, string, len, sa, salen);
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = rpc_uaddr2sockaddr(net, string, len, sa, salen);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = nfs_dns_resolve_name(net, string, len, sa, salen);
|
ret = nfs_dns_resolve_name(net, string, len, sa, salen);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
} else if (port) {
|
||||||
|
rpc_set_port(sa, port);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +333,7 @@ static int try_location(struct fs_context *fc,
|
|||||||
nfs_parse_server_name(buf->data, buf->len,
|
nfs_parse_server_name(buf->data, buf->len,
|
||||||
&ctx->nfs_server.address,
|
&ctx->nfs_server.address,
|
||||||
sizeof(ctx->nfs_server._address),
|
sizeof(ctx->nfs_server._address),
|
||||||
fc->net_ns);
|
fc->net_ns, 0);
|
||||||
if (ctx->nfs_server.addrlen == 0)
|
if (ctx->nfs_server.addrlen == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -496,7 +501,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
salen = nfs_parse_server_name(buf->data, buf->len,
|
salen = nfs_parse_server_name(buf->data, buf->len,
|
||||||
sap, addr_bufsize, net);
|
sap, addr_bufsize, net, 0);
|
||||||
if (salen == 0)
|
if (salen == 0)
|
||||||
continue;
|
continue;
|
||||||
rpc_set_port(sap, NFS_PORT);
|
rpc_set_port(sap, NFS_PORT);
|
||||||
|
Reference in New Issue
Block a user