aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorWeston Andros Adamson <dros@netapp.com>2013-08-13 16:37:33 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-09-05 10:43:33 -0400
commitab4c2361358ebdf4933f6bfd1dc98d7a14b55769 (patch)
treeecc07d0ff2f19dbe91936e2e5729b4dbe4b2017e /fs
parent2031cd1af143f47dacacbb35efbef22f2fd079e6 (diff)
nfs4.1: Add state protection handler
Add nfs4_state_protect - the function responsible for switching to the machine credential and the correct rpc client when SP4_MACH_CRED is in use. Signed-off-by: Weston Andros Adamson <dros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/nfs4_fs.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 277407df6d47..3559e899666e 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -268,6 +268,35 @@ is_ds_client(struct nfs_client *clp)
268{ 268{
269 return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS; 269 return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS;
270} 270}
271
272/*
273 * Function responsible for determining if an rpc_message should use the
274 * machine cred under SP4_MACH_CRED and if so switching the credential and
275 * authflavor (using the nfs_client's rpc_clnt which will be krb5i/p).
276 * Should be called before rpc_call_sync/rpc_call_async.
277 */
278static inline void
279nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
280 struct rpc_clnt **clntp, struct rpc_message *msg)
281{
282 struct rpc_cred *newcred = NULL;
283 rpc_authflavor_t flavor;
284
285 if (test_bit(sp4_mode, &clp->cl_sp4_flags)) {
286 spin_lock(&clp->cl_lock);
287 if (clp->cl_machine_cred != NULL)
288 newcred = get_rpccred(clp->cl_machine_cred);
289 spin_unlock(&clp->cl_lock);
290 if (msg->rpc_cred)
291 put_rpccred(msg->rpc_cred);
292 msg->rpc_cred = newcred;
293
294 flavor = clp->cl_rpcclient->cl_auth->au_flavor;
295 WARN_ON(flavor != RPC_AUTH_GSS_KRB5I &&
296 flavor != RPC_AUTH_GSS_KRB5P);
297 *clntp = clp->cl_rpcclient;
298 }
299}
271#else /* CONFIG_NFS_v4_1 */ 300#else /* CONFIG_NFS_v4_1 */
272static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server) 301static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server)
273{ 302{
@@ -285,6 +314,12 @@ is_ds_client(struct nfs_client *clp)
285{ 314{
286 return false; 315 return false;
287} 316}
317
318static inline void
319nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags,
320 struct rpc_clnt **clntp, struct rpc_message *msg)
321{
322}
288#endif /* CONFIG_NFS_V4_1 */ 323#endif /* CONFIG_NFS_V4_1 */
289 324
290extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[]; 325extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[];