Skip to content

Commit

Permalink
SUNRPC: parametrize rpc_pton() by network context
Browse files Browse the repository at this point in the history
Parametrize rpc_pton() by network context and thus force it's callers to pass
in network context instead of using hard-coded "init_net".

Signed-off-by: Stanislav Kinsbursky <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
Stanislav Kinsbursky authored and Trond Myklebust committed Feb 1, 2012
1 parent 8b147f7 commit 90100b1
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions fs/nfs/dns_resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ssize_t nfs_dns_resolve_name(struct net *net, char *name, size_t namelen,

ip_len = dns_query(NULL, name, namelen, NULL, &ip_addr, NULL);
if (ip_len > 0)
ret = rpc_pton(ip_addr, ip_len, sa, salen);
ret = rpc_pton(&init_net, ip_addr, ip_len, sa, salen);
else
ret = -ESRCH;
kfree(ip_addr);
Expand Down Expand Up @@ -224,7 +224,7 @@ static int nfs_dns_parse(struct cache_detail *cd, char *buf, int buflen)
len = qword_get(&buf, buf1, sizeof(buf1));
if (len <= 0)
goto out;
key.addrlen = rpc_pton(buf1, len,
key.addrlen = rpc_pton(&init_net, buf1, len,
(struct sockaddr *)&key.addr,
sizeof(key.addr));

Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/nfs4filelayoutdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ decode_ds_addr(struct xdr_stream *streamp, gfp_t gfp_flags)

INIT_LIST_HEAD(&da->da_node);

if (!rpc_pton(buf, portstr-buf, (struct sockaddr *)&da->da_addr,
if (!rpc_pton(&init_net, buf, portstr-buf, (struct sockaddr *)&da->da_addr,
sizeof(da->da_addr))) {
dprintk("%s: error parsing address %s\n", __func__, buf);
goto out_free_da;
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/nfs4namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static size_t nfs_parse_server_name(char *string, size_t len,
{
ssize_t ret;

ret = rpc_pton(string, len, sa, salen);
ret = rpc_pton(&init_net, string, len, sa, salen);
if (ret == 0) {
ret = nfs_dns_resolve_name(server->client->cl_xprt->xprt_net,
string, len, sa, salen);
Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ static int nfs_parse_mount_options(char *raw,
if (string == NULL)
goto out_nomem;
mnt->nfs_server.addrlen =
rpc_pton(string, strlen(string),
rpc_pton(&init_net, string, strlen(string),
(struct sockaddr *)
&mnt->nfs_server.address,
sizeof(mnt->nfs_server.address));
Expand All @@ -1430,7 +1430,7 @@ static int nfs_parse_mount_options(char *raw,
if (string == NULL)
goto out_nomem;
mnt->mount_server.addrlen =
rpc_pton(string, strlen(string),
rpc_pton(&init_net, string, strlen(string),
(struct sockaddr *)
&mnt->mount_server.address,
sizeof(mnt->mount_server.address));
Expand Down
2 changes: 1 addition & 1 deletion fs/nfsd/nfsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size)
if (qword_get(&buf, fo_path, size) < 0)
return -EINVAL;

if (rpc_pton(fo_path, size, sap, salen) == 0)
if (rpc_pton(&init_net, fo_path, size, sap, salen) == 0)
return -EINVAL;

return nlmsvc_unlock_all_by_ip(sap);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/sunrpc/clnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);

size_t rpc_ntop(const struct sockaddr *, char *, const size_t);
size_t rpc_pton(const char *, const size_t,
size_t rpc_pton(struct net *, const char *, const size_t,
struct sockaddr *, const size_t);
char * rpc_sockaddr2uaddr(const struct sockaddr *, gfp_t);
size_t rpc_uaddr2sockaddr(const char *, const size_t,
Expand Down
7 changes: 4 additions & 3 deletions net/sunrpc/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ static size_t rpc_pton6(struct net *net, const char *buf, const size_t buflen,

/**
* rpc_pton - Construct a sockaddr in @sap
* @net: applicable network namespace
* @buf: C string containing presentation format IP address
* @buflen: length of presentation address in bytes
* @sap: buffer into which to plant socket address
Expand All @@ -242,14 +243,14 @@ static size_t rpc_pton6(struct net *net, const char *buf, const size_t buflen,
* socket address, if successful. Returns zero if an error
* occurred.
*/
size_t rpc_pton(const char *buf, const size_t buflen,
size_t rpc_pton(struct net *net, const char *buf, const size_t buflen,
struct sockaddr *sap, const size_t salen)
{
unsigned int i;

for (i = 0; i < buflen; i++)
if (buf[i] == ':')
return rpc_pton6(&init_net, buf, buflen, sap, salen);
return rpc_pton6(net, buf, buflen, sap, salen);
return rpc_pton4(buf, buflen, sap, salen);
}
EXPORT_SYMBOL_GPL(rpc_pton);
Expand Down Expand Up @@ -340,7 +341,7 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len,
port = (unsigned short)((porthi << 8) | portlo);

*c = '\0';
if (rpc_pton(buf, strlen(buf), sap, salen) == 0)
if (rpc_pton(&init_net, buf, strlen(buf), sap, salen) == 0)
return 0;

switch (sap->sa_family) {
Expand Down
2 changes: 1 addition & 1 deletion net/sunrpc/svcauth_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static int ip_map_parse(struct cache_detail *cd,
len = qword_get(&mesg, buf, mlen);
if (len <= 0) return -EINVAL;

if (rpc_pton(buf, len, &address.sa, sizeof(address)) == 0)
if (rpc_pton(&init_net, buf, len, &address.sa, sizeof(address)) == 0)
return -EINVAL;
switch (address.sa.sa_family) {
case AF_INET:
Expand Down

0 comments on commit 90100b1

Please sign in to comment.