aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/super.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-09-07 13:26:57 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-09-07 16:11:24 -0400
commit74c988116231129320925a665e7420e513faaabe (patch)
treefda2be377b73375820dbc598bc5fc21e141d9669 /fs/nfs/super.c
parent0e20162ed1e9a639fc61d62c71327169fb1a1970 (diff)
NFS: Clean up the auth flavour array mess
What is the point of having a 'auth_flavor_len' field, if it is always set to 1, and can't be used to determine if the user has selected an auth flavour? This cleanup goes back to using auth_flavor_len for its original intended purpose, and gets rid of the ad-hoc replacements. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r--fs/nfs/super.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 6ad9053d8906..5d16ee3f1542 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -923,7 +923,7 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void)
923 data->nfs_server.port = NFS_UNSPEC_PORT; 923 data->nfs_server.port = NFS_UNSPEC_PORT;
924 data->nfs_server.protocol = XPRT_TRANSPORT_TCP; 924 data->nfs_server.protocol = XPRT_TRANSPORT_TCP;
925 data->auth_flavors[0] = RPC_AUTH_MAXFLAVOR; 925 data->auth_flavors[0] = RPC_AUTH_MAXFLAVOR;
926 data->auth_flavor_len = 1; 926 data->auth_flavor_len = 0;
927 data->minorversion = 0; 927 data->minorversion = 0;
928 data->need_mount = true; 928 data->need_mount = true;
929 data->net = current->nsproxy->net_ns; 929 data->net = current->nsproxy->net_ns;
@@ -1018,6 +1018,13 @@ static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt)
1018 } 1018 }
1019} 1019}
1020 1020
1021static void nfs_set_auth_parsed_mount_data(struct nfs_parsed_mount_data *data,
1022 rpc_authflavor_t pseudoflavor)
1023{
1024 data->auth_flavors[0] = pseudoflavor;
1025 data->auth_flavor_len = 1;
1026}
1027
1021/* 1028/*
1022 * Parse the value of the 'sec=' option. 1029 * Parse the value of the 'sec=' option.
1023 */ 1030 */
@@ -1729,7 +1736,7 @@ static struct nfs_server *nfs_try_mount_request(struct nfs_mount_info *mount_inf
1729 * Was a sec= authflavor specified in the options? First, verify 1736 * Was a sec= authflavor specified in the options? First, verify
1730 * whether the server supports it, and then just try to use it if so. 1737 * whether the server supports it, and then just try to use it if so.
1731 */ 1738 */
1732 if (args->auth_flavors[0] != RPC_AUTH_MAXFLAVOR) { 1739 if (args->auth_flavor_len > 0) {
1733 status = nfs_verify_authflavor(args, authlist, authlist_len); 1740 status = nfs_verify_authflavor(args, authlist, authlist_len);
1734 dfprintk(MOUNT, "NFS: using auth flavor %u\n", args->auth_flavors[0]); 1741 dfprintk(MOUNT, "NFS: using auth flavor %u\n", args->auth_flavors[0]);
1735 if (status) 1742 if (status)
@@ -1760,7 +1767,7 @@ static struct nfs_server *nfs_try_mount_request(struct nfs_mount_info *mount_inf
1760 /* Fallthrough */ 1767 /* Fallthrough */
1761 } 1768 }
1762 dfprintk(MOUNT, "NFS: attempting to use auth flavor %u\n", flavor); 1769 dfprintk(MOUNT, "NFS: attempting to use auth flavor %u\n", flavor);
1763 args->auth_flavors[0] = flavor; 1770 nfs_set_auth_parsed_mount_data(args, flavor);
1764 server = nfs_mod->rpc_ops->create_server(mount_info, nfs_mod); 1771 server = nfs_mod->rpc_ops->create_server(mount_info, nfs_mod);
1765 if (!IS_ERR(server)) 1772 if (!IS_ERR(server))
1766 return server; 1773 return server;
@@ -1776,7 +1783,7 @@ static struct nfs_server *nfs_try_mount_request(struct nfs_mount_info *mount_inf
1776 1783
1777 /* Last chance! Try AUTH_UNIX */ 1784 /* Last chance! Try AUTH_UNIX */
1778 dfprintk(MOUNT, "NFS: attempting to use auth flavor %u\n", RPC_AUTH_UNIX); 1785 dfprintk(MOUNT, "NFS: attempting to use auth flavor %u\n", RPC_AUTH_UNIX);
1779 args->auth_flavors[0] = RPC_AUTH_UNIX; 1786 nfs_set_auth_parsed_mount_data(args, RPC_AUTH_UNIX);
1780 return nfs_mod->rpc_ops->create_server(mount_info, nfs_mod); 1787 return nfs_mod->rpc_ops->create_server(mount_info, nfs_mod);
1781} 1788}
1782 1789
@@ -1893,6 +1900,7 @@ static int nfs23_validate_mount_data(void *options,
1893{ 1900{
1894 struct nfs_mount_data *data = (struct nfs_mount_data *)options; 1901 struct nfs_mount_data *data = (struct nfs_mount_data *)options;
1895 struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; 1902 struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address;
1903 int extra_flags = NFS_MOUNT_LEGACY_INTERFACE;
1896 1904
1897 if (data == NULL) 1905 if (data == NULL)
1898 goto out_no_data; 1906 goto out_no_data;
@@ -1908,6 +1916,8 @@ static int nfs23_validate_mount_data(void *options,
1908 goto out_no_v3; 1916 goto out_no_v3;
1909 data->root.size = NFS2_FHSIZE; 1917 data->root.size = NFS2_FHSIZE;
1910 memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE); 1918 memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE);
1919 /* Turn off security negotiation */
1920 extra_flags |= NFS_MOUNT_SECFLAVOUR;
1911 case 4: 1921 case 4:
1912 if (data->flags & NFS_MOUNT_SECFLAVOUR) 1922 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1913 goto out_no_sec; 1923 goto out_no_sec;
@@ -1935,7 +1945,7 @@ static int nfs23_validate_mount_data(void *options,
1935 * can deal with. 1945 * can deal with.
1936 */ 1946 */
1937 args->flags = data->flags & NFS_MOUNT_FLAGMASK; 1947 args->flags = data->flags & NFS_MOUNT_FLAGMASK;
1938 args->flags |= NFS_MOUNT_LEGACY_INTERFACE; 1948 args->flags |= extra_flags;
1939 args->rsize = data->rsize; 1949 args->rsize = data->rsize;
1940 args->wsize = data->wsize; 1950 args->wsize = data->wsize;
1941 args->timeo = data->timeo; 1951 args->timeo = data->timeo;
@@ -1959,9 +1969,10 @@ static int nfs23_validate_mount_data(void *options,
1959 args->namlen = data->namlen; 1969 args->namlen = data->namlen;
1960 args->bsize = data->bsize; 1970 args->bsize = data->bsize;
1961 1971
1962 args->auth_flavors[0] = RPC_AUTH_UNIX;
1963 if (data->flags & NFS_MOUNT_SECFLAVOUR) 1972 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1964 args->auth_flavors[0] = data->pseudoflavor; 1973 nfs_set_auth_parsed_mount_data(args, data->pseudoflavor);
1974 else
1975 nfs_set_auth_parsed_mount_data(args, RPC_AUTH_UNIX);
1965 if (!args->nfs_server.hostname) 1976 if (!args->nfs_server.hostname)
1966 goto out_nomem; 1977 goto out_nomem;
1967 1978
@@ -2176,7 +2187,7 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
2176 data->rsize = nfss->rsize; 2187 data->rsize = nfss->rsize;
2177 data->wsize = nfss->wsize; 2188 data->wsize = nfss->wsize;
2178 data->retrans = nfss->client->cl_timeout->to_retries; 2189 data->retrans = nfss->client->cl_timeout->to_retries;
2179 data->auth_flavors[0] = nfss->client->cl_auth->au_flavor; 2190 nfs_set_auth_parsed_mount_data(data, nfss->client->cl_auth->au_flavor);
2180 data->acregmin = nfss->acregmin / HZ; 2191 data->acregmin = nfss->acregmin / HZ;
2181 data->acregmax = nfss->acregmax / HZ; 2192 data->acregmax = nfss->acregmax / HZ;
2182 data->acdirmin = nfss->acdirmin / HZ; 2193 data->acdirmin = nfss->acdirmin / HZ;
@@ -2675,15 +2686,17 @@ static int nfs4_validate_mount_data(void *options,
2675 goto out_no_address; 2686 goto out_no_address;
2676 args->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port); 2687 args->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port);
2677 2688
2678 args->auth_flavors[0] = RPC_AUTH_UNIX;
2679 if (data->auth_flavourlen) { 2689 if (data->auth_flavourlen) {
2690 rpc_authflavor_t pseudoflavor;
2680 if (data->auth_flavourlen > 1) 2691 if (data->auth_flavourlen > 1)
2681 goto out_inval_auth; 2692 goto out_inval_auth;
2682 if (copy_from_user(&args->auth_flavors[0], 2693 if (copy_from_user(&pseudoflavor,
2683 data->auth_flavours, 2694 data->auth_flavours,
2684 sizeof(args->auth_flavors[0]))) 2695 sizeof(pseudoflavor)))
2685 return -EFAULT; 2696 return -EFAULT;
2686 } 2697 nfs_set_auth_parsed_mount_data(args, pseudoflavor);
2698 } else
2699 nfs_set_auth_parsed_mount_data(args, RPC_AUTH_UNIX);
2687 2700
2688 c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); 2701 c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
2689 if (IS_ERR(c)) 2702 if (IS_ERR(c))