NFS: Verify IPv6 addresses properly
authorChuck Lever <chuck.lever@oracle.com>
Mon, 10 Dec 2007 19:57:45 +0000 (14:57 -0500)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 30 Jan 2008 07:05:53 +0000 (02:05 -0500)
Add support to nfs_verify_server_address for recognizing AF_INET6
addresses.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/super.c

index c3d8fcf385238650ec63c157610fb08eea3d4862..038b20b38b220dddd54accdfb9725772a1b937f9 100644 (file)
@@ -600,16 +600,21 @@ static void nfs_umount_begin(struct vfsmount *vfsmnt, int flags)
 }
 
 /*
- * Sanity-check a server address provided by the mount command
+ * Sanity-check a server address provided by the mount command.
+ *
+ * Address family must be initialized, and address must not be
+ * the ANY address for that family.
  */
 static int nfs_verify_server_address(struct sockaddr *addr)
 {
        switch (addr->sa_family) {
        case AF_INET: {
-               struct sockaddr_in *sa = (struct sockaddr_in *) addr;
-               if (sa->sin_addr.s_addr != INADDR_ANY)
-                       return 1;
-               break;
+               struct sockaddr_in *sa = (struct sockaddr_in *)addr;
+               return sa->sin_addr.s_addr != INADDR_ANY;
+       }
+       case AF_INET6: {
+               struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr;
+               return !ipv6_addr_any(sa);
        }
        }