Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9412b92772c1d80ea8284583b6aad0260e13515f
Commit:     9412b92772c1d80ea8284583b6aad0260e13515f
Parent:     338320345b40eb7c63592f40d25cbd58ccf99548
Author:     Chuck Lever <[EMAIL PROTECTED]>
AuthorDate: Mon Dec 10 14:59:21 2007 -0500
Committer:  Trond Myklebust <[EMAIL PROTECTED]>
CommitDate: Wed Jan 30 02:05:56 2008 -0500

    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 <[EMAIL PROTECTED]>
    Cc: Aurelien Charbon <[EMAIL PROTECTED]>
    Signed-off-by: Trond Myklebust <[EMAIL PROTECTED]>
---
 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 f120be4..041fe9e 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -641,6 +641,26 @@ static int nfs_verify_server_address(struct sockaddr *addr)
 }
 
 /*
+ * 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
  * a data structure
  */
@@ -963,9 +983,8 @@ static int nfs_parse_mount_options(char *raw,
                        string = match_strdup(args);
                        if (string == NULL)
                                goto out_nomem;
-                       mnt->nfs_server.address.sin_family = AF_INET;
-                       mnt->nfs_server.address.sin_addr.s_addr =
-                                                       in_aton(string);
+                       nfs_parse_server_address(string, (struct sockaddr *)
+                                                &mnt->nfs_server.address);
                        kfree(string);
                        break;
                case Opt_clientaddr:
@@ -984,9 +1003,8 @@ static int nfs_parse_mount_options(char *raw,
                        string = match_strdup(args);
                        if (string == NULL)
                                goto out_nomem;
-                       mnt->mount_server.address.sin_family = AF_INET;
-                       mnt->mount_server.address.sin_addr.s_addr =
-                                                       in_aton(string);
+                       nfs_parse_server_address(string, (struct sockaddr *)
+                                                &mnt->mount_server.address);
                        kfree(string);
                        break;
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to