diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2007-12-10 14:58:00 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-01-30 02:05:54 -0500 |
commit | 0d0f0c192df0282600c6d11c8cc252e7e7a80afc (patch) | |
tree | 06b3e96d326d243c266f9e1ae3ed3798080ab904 /fs/nfs | |
parent | 04dcd6e3aceedff9fcc96ce3014688d5b642d627 (diff) |
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/nfs')
-rw-r--r-- | fs/nfs/super.c | 32 |
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) | |||
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | /* | 1598 | /* |
1599 | * If the user didn't specify a port, set the port number to | ||
1600 | * the NFS version 4 default port. | ||
1601 | */ | ||
1602 | static void nfs4_default_port(struct sockaddr *sap) | ||
1603 | { | ||
1604 | switch (sap->sa_family) { | ||
1605 | case AF_INET: { | ||
1606 | struct sockaddr_in *ap = (struct sockaddr_in *)sap; | ||
1607 | if (ap->sin_port == 0) | ||
1608 | ap->sin_port = htons(NFS_PORT); | ||
1609 | break; | ||
1610 | } | ||
1611 | case AF_INET6: { | ||
1612 | struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap; | ||
1613 | if (ap->sin6_port == 0) | ||
1614 | ap->sin6_port = htons(NFS_PORT); | ||
1615 | break; | ||
1616 | } | ||
1617 | } | ||
1618 | } | ||
1619 | |||
1620 | /* | ||
1599 | * Validate NFSv4 mount options | 1621 | * Validate NFSv4 mount options |
1600 | */ | 1622 | */ |
1601 | static int nfs4_validate_mount_data(void *options, | 1623 | static int nfs4_validate_mount_data(void *options, |
@@ -1628,12 +1650,13 @@ static int nfs4_validate_mount_data(void *options, | |||
1628 | data->host_addr, | 1650 | data->host_addr, |
1629 | sizeof(args->nfs_server.address))) | 1651 | sizeof(args->nfs_server.address))) |
1630 | return -EFAULT; | 1652 | return -EFAULT; |
1631 | if (args->nfs_server.address.sin_port == 0) | ||
1632 | args->nfs_server.address.sin_port = htons(NFS_PORT); | ||
1633 | if (!nfs_verify_server_address((struct sockaddr *) | 1653 | if (!nfs_verify_server_address((struct sockaddr *) |
1634 | &args->nfs_server.address)) | 1654 | &args->nfs_server.address)) |
1635 | goto out_no_address; | 1655 | goto out_no_address; |
1636 | 1656 | ||
1657 | nfs4_default_port((struct sockaddr *) | ||
1658 | &args->nfs_server.address); | ||
1659 | |||
1637 | switch (data->auth_flavourlen) { | 1660 | switch (data->auth_flavourlen) { |
1638 | case 0: | 1661 | case 0: |
1639 | args->auth_flavors[0] = RPC_AUTH_UNIX; | 1662 | args->auth_flavors[0] = RPC_AUTH_UNIX; |
@@ -1687,12 +1710,13 @@ static int nfs4_validate_mount_data(void *options, | |||
1687 | if (nfs_parse_mount_options((char *)options, args) == 0) | 1710 | if (nfs_parse_mount_options((char *)options, args) == 0) |
1688 | return -EINVAL; | 1711 | return -EINVAL; |
1689 | 1712 | ||
1690 | if (args->nfs_server.address.sin_port == 0) | ||
1691 | args->nfs_server.address.sin_port = htons(NFS_PORT); | ||
1692 | if (!nfs_verify_server_address((struct sockaddr *) | 1713 | if (!nfs_verify_server_address((struct sockaddr *) |
1693 | &args->nfs_server.address)) | 1714 | &args->nfs_server.address)) |
1694 | return -EINVAL; | 1715 | return -EINVAL; |
1695 | 1716 | ||
1717 | nfs4_default_port((struct sockaddr *) | ||
1718 | &args->nfs_server.address); | ||
1719 | |||
1696 | switch (args->auth_flavor_len) { | 1720 | switch (args->auth_flavor_len) { |
1697 | case 0: | 1721 | case 0: |
1698 | args->auth_flavors[0] = RPC_AUTH_UNIX; | 1722 | args->auth_flavors[0] = RPC_AUTH_UNIX; |