Commit cdcd7f9a authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

NFS: Verify IPv6 addresses properly

Add support to nfs_verify_server_address for recognizing AF_INET6
addresses.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent fd00a8ff
...@@ -600,16 +600,21 @@ static void nfs_umount_begin(struct vfsmount *vfsmnt, int flags) ...@@ -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) static int nfs_verify_server_address(struct sockaddr *addr)
{ {
switch (addr->sa_family) { switch (addr->sa_family) {
case AF_INET: { case AF_INET: {
struct sockaddr_in *sa = (struct sockaddr_in *) addr; struct sockaddr_in *sa = (struct sockaddr_in *)addr;
if (sa->sin_addr.s_addr != INADDR_ANY) return sa->sin_addr.s_addr != INADDR_ANY;
return 1; }
break; case AF_INET6: {
struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr;
return !ipv6_addr_any(sa);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment