From: Andy Adamson Date: Fri, 18 May 2007 16:52:41 -0400 NFSv4: Add a helper to return the next untried security flavor Helper function for NFS4ERR_WRONGSEC handler Returns RPC_AUTH_MAXFLAVOR when all flavors have been tried. Signed-off-by: Andy Adamson Signed-off-by: Trond Myklebust --- fs/nfs/client.c | 29 +++++++++++++++++++++++++++++ fs/nfs/nfs4_fs.h | 1 + 2 files changed, 30 insertions(+), 0 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 881fa49..eb03f5f 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -1102,6 +1102,35 @@ error: return ERR_PTR(error); } +/* + * Return the next untried security flavor or RPC_AUTH_MAXFLAVOR + * when all flavors have been tried. + */ +static rpc_authflavor_t nfs4_next_flavor(struct nfs4_exception *exc, + rpc_authflavor_t cur_flavor) +{ + struct nfs4_secinfo_res *sec; + rpc_authflavor_t ret = RPC_AUTH_MAXFLAVOR; + int i; + + dprintk("-->nfs4_next_flavor\n"); + sec = exc->ex_list; + for (i = 0; i < sec->fl_num; i++){ + + /* Skip flavors that have been tried. */ + if (sec->flavors[i] == RPC_AUTH_MAXFLAVOR) + continue; + + /* Try this flavor */ + ret = sec->flavors[i]; + sec->flavors[i] = RPC_AUTH_MAXFLAVOR; + goto out; + } +out: + dprintk("<-- nfs4_next_flavor() error %d\n", ret); + return ret; +} + #endif /* CONFIG_NFS_V4 */ /* diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index cf3a17e..9215b66 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -143,6 +143,7 @@ struct nfs4_state { struct nfs4_exception { long timeout; int retry; + struct nfs4_secinfo_res *ex_list; }; struct nfs4_state_recovery_ops {