summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-12-10 20:58:00 +0100
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-01-30 08:05:54 +0100
commit0d0f0c192df0282600c6d11c8cc252e7e7a80afc (patch)
tree06b3e96d326d243c266f9e1ae3ed3798080ab904 /fs
parentNFS: Make setting a port number agostic (diff)
downloadlinux-0d0f0c192df0282600c6d11c8cc252e7e7a80afc.tar.xz
linux-0d0f0c192df0282600c6d11c8cc252e7e7a80afc.zip
NFS: Set default port for NFSv4, with support for AF_INET6
Create a helper function to set the default NFS port for NFSv4 mount points. The helper supports both AF_INET and AF_INET6 family addresses. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/super.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index ef1aad774e6c..a88697ff19ef 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1596,6 +1596,28 @@ static void nfs4_fill_super(struct super_block *sb)
}
/*
+ * If the user didn't specify a port, set the port number to
+ * the NFS version 4 default port.
+ */
+static void nfs4_default_port(struct sockaddr *sap)
+{
+ switch (sap->sa_family) {
+ case AF_INET: {
+ struct sockaddr_in *ap = (struct sockaddr_in *)sap;
+ if (ap->sin_port == 0)
+ ap->sin_port = htons(NFS_PORT);
+ break;
+ }
+ case AF_INET6: {
+ struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
+ if (ap->sin6_port == 0)
+ ap->sin6_port = htons(NFS_PORT);
+ break;
+ }
+ }
+}
+
+/*
* Validate NFSv4 mount options
*/
static int nfs4_validate_mount_data(void *options,
@@ -1628,12 +1650,13 @@ static int nfs4_validate_mount_data(void *options,
data->host_addr,
sizeof(args->nfs_server.address)))
return -EFAULT;
- if (args->nfs_server.address.sin_port == 0)
- args->nfs_server.address.sin_port = htons(NFS_PORT);
if (!nfs_verify_server_address((struct sockaddr *)
&args->nfs_server.address))
goto out_no_address;
+ nfs4_default_port((struct sockaddr *)
+ &args->nfs_server.address);
+
switch (data->auth_flavourlen) {
case 0:
args->auth_flavors[0] = RPC_AUTH_UNIX;
@@ -1687,12 +1710,13 @@ static int nfs4_validate_mount_data(void *options,
if (nfs_parse_mount_options((char *)options, args) == 0)
return -EINVAL;
- if (args->nfs_server.address.sin_port == 0)
- args->nfs_server.address.sin_port = htons(NFS_PORT);
if (!nfs_verify_server_address((struct sockaddr *)
&args->nfs_server.address))
return -EINVAL;
+ nfs4_default_port((struct sockaddr *)
+ &args->nfs_server.address);
+
switch (args->auth_flavor_len) {
case 0:
args->auth_flavors[0] = RPC_AUTH_UNIX;