mirror of
https://github.com/adulau/aha.git
synced 2025-01-04 07:03:38 +00:00
NFS: Refactor mount option address parsing into separate function
Refactor the logic to parse incoming text-based IP addresses. Use the in4_pton() function instead of the older in_aton(), following the lead of the in-kernel CIFS client. Later we'll add IPv6 address parsing using the matching in6_pton() function. For now we can't allow IPv6 address parsing: we must expand the size of the address storage fields in the nfs_parsed_mount_options struct before we can parse and store IPv6 addresses. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Cc: Aurelien Charbon <aurelien.charbon@ext.bull.net> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
338320345b
commit
9412b92772
1 changed files with 24 additions and 6 deletions
|
@ -640,6 +640,26 @@ static int nfs_verify_server_address(struct sockaddr *addr)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse string addresses passed in via a mount option,
|
||||||
|
* and construct a sockaddr based on the result.
|
||||||
|
*
|
||||||
|
* If address parsing fails, set the sockaddr's address
|
||||||
|
* family to AF_UNSPEC to force nfs_verify_server_address()
|
||||||
|
* to punt the mount.
|
||||||
|
*/
|
||||||
|
static void nfs_parse_server_address(char *value,
|
||||||
|
struct sockaddr *sap)
|
||||||
|
{
|
||||||
|
struct sockaddr_in *ap = (void *)sap;
|
||||||
|
|
||||||
|
ap->sin_family = AF_INET;
|
||||||
|
if (in4_pton(value, -1, (u8 *)&ap->sin_addr.s_addr, '\0', NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
sap->sa_family = AF_UNSPEC;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Error-check and convert a string of mount options from user space into
|
* Error-check and convert a string of mount options from user space into
|
||||||
* a data structure
|
* a data structure
|
||||||
|
@ -963,9 +983,8 @@ static int nfs_parse_mount_options(char *raw,
|
||||||
string = match_strdup(args);
|
string = match_strdup(args);
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
goto out_nomem;
|
goto out_nomem;
|
||||||
mnt->nfs_server.address.sin_family = AF_INET;
|
nfs_parse_server_address(string, (struct sockaddr *)
|
||||||
mnt->nfs_server.address.sin_addr.s_addr =
|
&mnt->nfs_server.address);
|
||||||
in_aton(string);
|
|
||||||
kfree(string);
|
kfree(string);
|
||||||
break;
|
break;
|
||||||
case Opt_clientaddr:
|
case Opt_clientaddr:
|
||||||
|
@ -984,9 +1003,8 @@ static int nfs_parse_mount_options(char *raw,
|
||||||
string = match_strdup(args);
|
string = match_strdup(args);
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
goto out_nomem;
|
goto out_nomem;
|
||||||
mnt->mount_server.address.sin_family = AF_INET;
|
nfs_parse_server_address(string, (struct sockaddr *)
|
||||||
mnt->mount_server.address.sin_addr.s_addr =
|
&mnt->mount_server.address);
|
||||||
in_aton(string);
|
|
||||||
kfree(string);
|
kfree(string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue