aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4state.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-04-08 16:02:17 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-04-19 16:54:59 -0400
commita2b2bb8822c78806930bbb4d4c5bb3ae69648fd0 (patch)
treea172b309f9ead2f81426eebdb28f3f1ecb75ce48 /fs/nfs/nfs4state.c
parent7c67db3a8a98045744f06fcd6d8f476d9df0ba5c (diff)
NFSv4: Attempt to use machine credentials in SETCLIENTID calls
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4state.c')
-rw-r--r--fs/nfs/nfs4state.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 7775435ea7a5..46eb624e4f16 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -71,6 +71,29 @@ static int nfs4_init_client(struct nfs_client *clp, struct rpc_cred *cred)
71 return status; 71 return status;
72} 72}
73 73
74static struct rpc_cred *nfs4_get_machine_cred(struct nfs_client *clp)
75{
76 struct rpc_cred *cred = NULL;
77
78 spin_lock(&clp->cl_lock);
79 if (clp->cl_machine_cred != NULL)
80 cred = get_rpccred(clp->cl_machine_cred);
81 spin_unlock(&clp->cl_lock);
82 return cred;
83}
84
85static void nfs4_clear_machine_cred(struct nfs_client *clp)
86{
87 struct rpc_cred *cred;
88
89 spin_lock(&clp->cl_lock);
90 cred = clp->cl_machine_cred;
91 clp->cl_machine_cred = NULL;
92 spin_unlock(&clp->cl_lock);
93 if (cred != NULL)
94 put_rpccred(cred);
95}
96
74struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp) 97struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp)
75{ 98{
76 struct nfs4_state_owner *sp; 99 struct nfs4_state_owner *sp;
@@ -91,13 +114,18 @@ static struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp)
91{ 114{
92 struct nfs4_state_owner *sp; 115 struct nfs4_state_owner *sp;
93 struct rb_node *pos; 116 struct rb_node *pos;
117 struct rpc_cred *cred;
94 118
119 cred = nfs4_get_machine_cred(clp);
120 if (cred != NULL)
121 goto out;
95 pos = rb_first(&clp->cl_state_owners); 122 pos = rb_first(&clp->cl_state_owners);
96 if (pos != NULL) { 123 if (pos != NULL) {
97 sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); 124 sp = rb_entry(pos, struct nfs4_state_owner, so_client_node);
98 return get_rpccred(sp->so_cred); 125 cred = get_rpccred(sp->so_cred);
99 } 126 }
100 return NULL; 127out:
128 return cred;
101} 129}
102 130
103static void nfs_alloc_unique_id(struct rb_root *root, struct nfs_unique_id *new, 131static void nfs_alloc_unique_id(struct rb_root *root, struct nfs_unique_id *new,
@@ -924,10 +952,10 @@ restart_loop:
924 if (cred != NULL) { 952 if (cred != NULL) {
925 /* Yes there are: try to renew the old lease */ 953 /* Yes there are: try to renew the old lease */
926 status = nfs4_proc_renew(clp, cred); 954 status = nfs4_proc_renew(clp, cred);
955 put_rpccred(cred);
927 switch (status) { 956 switch (status) {
928 case 0: 957 case 0:
929 case -NFS4ERR_CB_PATH_DOWN: 958 case -NFS4ERR_CB_PATH_DOWN:
930 put_rpccred(cred);
931 goto out; 959 goto out;
932 case -NFS4ERR_STALE_CLIENTID: 960 case -NFS4ERR_STALE_CLIENTID:
933 case -NFS4ERR_LEASE_MOVED: 961 case -NFS4ERR_LEASE_MOVED:
@@ -936,14 +964,19 @@ restart_loop:
936 } else { 964 } else {
937 /* "reboot" to ensure we clear all state on the server */ 965 /* "reboot" to ensure we clear all state on the server */
938 clp->cl_boot_time = CURRENT_TIME; 966 clp->cl_boot_time = CURRENT_TIME;
939 cred = nfs4_get_setclientid_cred(clp);
940 } 967 }
941 /* We're going to have to re-establish a clientid */ 968 /* We're going to have to re-establish a clientid */
942 nfs4_state_mark_reclaim(clp); 969 nfs4_state_mark_reclaim(clp);
943 status = -ENOENT; 970 status = -ENOENT;
971 cred = nfs4_get_setclientid_cred(clp);
944 if (cred != NULL) { 972 if (cred != NULL) {
945 status = nfs4_init_client(clp, cred); 973 status = nfs4_init_client(clp, cred);
946 put_rpccred(cred); 974 put_rpccred(cred);
975 /* Handle case where the user hasn't set up machine creds */
976 if (status == -EACCES && cred == clp->cl_machine_cred) {
977 nfs4_clear_machine_cred(clp);
978 goto restart_loop;
979 }
947 } 980 }
948 if (status) 981 if (status)
949 goto out_error; 982 goto out_error;