aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/super.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-12-10 14:59:21 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-01-30 02:05:56 -0500
commit9412b92772c1d80ea8284583b6aad0260e13515f (patch)
tree9c2032bd41d9c1e9ade36dab4ec8e4e208d96a4e /fs/nfs/super.c
parent338320345b40eb7c63592f40d25cbd58ccf99548 (diff)
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>
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r--fs/nfs/super.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index f120be43d543..041fe9e9b74d 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -641,6 +641,26 @@ static int nfs_verify_server_address(struct sockaddr *addr)
641} 641}
642 642
643/* 643/*
644 * Parse string addresses passed in via a mount option,
645 * and construct a sockaddr based on the result.
646 *
647 * If address parsing fails, set the sockaddr's address
648 * family to AF_UNSPEC to force nfs_verify_server_address()
649 * to punt the mount.
650 */
651static void nfs_parse_server_address(char *value,
652 struct sockaddr *sap)
653{
654 struct sockaddr_in *ap = (void *)sap;
655
656 ap->sin_family = AF_INET;
657 if (in4_pton(value, -1, (u8 *)&ap->sin_addr.s_addr, '\0', NULL))
658 return;
659
660 sap->sa_family = AF_UNSPEC;
661}
662
663/*
644 * Error-check and convert a string of mount options from user space into 664 * Error-check and convert a string of mount options from user space into
645 * a data structure 665 * a data structure
646 */ 666 */
@@ -963,9 +983,8 @@ static int nfs_parse_mount_options(char *raw,
963 string = match_strdup(args); 983 string = match_strdup(args);
964 if (string == NULL) 984 if (string == NULL)
965 goto out_nomem; 985 goto out_nomem;
966 mnt->nfs_server.address.sin_family = AF_INET; 986 nfs_parse_server_address(string, (struct sockaddr *)
967 mnt->nfs_server.address.sin_addr.s_addr = 987 &mnt->nfs_server.address);
968 in_aton(string);
969 kfree(string); 988 kfree(string);
970 break; 989 break;
971 case Opt_clientaddr: 990 case Opt_clientaddr:
@@ -984,9 +1003,8 @@ static int nfs_parse_mount_options(char *raw,
984 string = match_strdup(args); 1003 string = match_strdup(args);
985 if (string == NULL) 1004 if (string == NULL)
986 goto out_nomem; 1005 goto out_nomem;
987 mnt->mount_server.address.sin_family = AF_INET; 1006 nfs_parse_server_address(string, (struct sockaddr *)
988 mnt->mount_server.address.sin_addr.s_addr = 1007 &mnt->mount_server.address);
989 in_aton(string);
990 kfree(string); 1008 kfree(string);
991 break; 1009 break;
992 1010