diff options
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r-- | fs/nfs/super.c | 30 |
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 | */ | ||
651 | static 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 | ||