]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
SUNRPC: Clean up of rpc_bindcred()
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Sat, 31 Jul 2010 18:29:08 +0000 (14:29 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 4 Aug 2010 12:54:08 +0000 (08:54 -0400)
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
include/linux/sunrpc/auth.h
net/sunrpc/auth.c
net/sunrpc/auth_generic.c
net/sunrpc/clnt.c

index d2737625a24711db6c17db0fb88d295e6e25f156..90e4c3827ac0787b2b011e20271d61c206501bba 100644 (file)
@@ -106,7 +106,7 @@ struct rpc_credops {
        void                    (*crdestroy)(struct rpc_cred *);
 
        int                     (*crmatch)(struct auth_cred *, struct rpc_cred *, int);
-       void                    (*crbind)(struct rpc_task *, struct rpc_cred *, int);
+       struct rpc_cred *       (*crbind)(struct rpc_task *, struct rpc_cred *, int);
        __be32 *                (*crmarshal)(struct rpc_task *, __be32 *);
        int                     (*crrefresh)(struct rpc_task *);
        __be32 *                (*crvalidate)(struct rpc_task *, __be32 *);
@@ -135,8 +135,8 @@ void                        rpcauth_release(struct rpc_auth *);
 struct rpc_cred *      rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int);
 void                   rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *);
 struct rpc_cred *      rpcauth_lookupcred(struct rpc_auth *, int);
-void                   rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int);
-void                   rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *, int);
+int                    rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int);
+struct rpc_cred *      rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *, int);
 void                   put_rpccred(struct rpc_cred *);
 void                   rpcauth_unbindcred(struct rpc_task *);
 __be32 *               rpcauth_marshcred(struct rpc_task *, __be32 *);
index d80f01725fc25dce8def5949fc5329bc6e7b99fb..d8968faf5ccf685a05c8c6628e4850f5f87a70fc 100644 (file)
@@ -444,16 +444,16 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
 }
 EXPORT_SYMBOL_GPL(rpcauth_init_cred);
 
-void
+struct rpc_cred *
 rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred, int lookupflags)
 {
-       task->tk_msg.rpc_cred = get_rpccred(cred);
        dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid,
                        cred->cr_auth->au_ops->au_name, cred);
+       return get_rpccred(cred);
 }
 EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred);
 
-static void
+static struct rpc_cred *
 rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags)
 {
        struct rpc_auth *auth = task->tk_client->cl_auth;
@@ -461,45 +461,42 @@ rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags)
                .uid = 0,
                .gid = 0,
        };
-       struct rpc_cred *ret;
 
        dprintk("RPC: %5u looking up %s cred\n",
                task->tk_pid, task->tk_client->cl_auth->au_ops->au_name);
-       ret = auth->au_ops->lookup_cred(auth, &acred, lookupflags);
-       if (!IS_ERR(ret))
-               task->tk_msg.rpc_cred = ret;
-       else
-               task->tk_status = PTR_ERR(ret);
+       return auth->au_ops->lookup_cred(auth, &acred, lookupflags);
 }
 
-static void
+static struct rpc_cred *
 rpcauth_bind_new_cred(struct rpc_task *task, int lookupflags)
 {
        struct rpc_auth *auth = task->tk_client->cl_auth;
-       struct rpc_cred *ret;
 
        dprintk("RPC: %5u looking up %s cred\n",
                task->tk_pid, auth->au_ops->au_name);
-       ret = rpcauth_lookupcred(auth, lookupflags);
-       if (!IS_ERR(ret))
-               task->tk_msg.rpc_cred = ret;
-       else
-               task->tk_status = PTR_ERR(ret);
+       return rpcauth_lookupcred(auth, lookupflags);
 }
 
-void
+int
 rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags)
 {
+       struct rpc_cred *new;
        int lookupflags = 0;
 
        if (flags & RPC_TASK_ASYNC)
                lookupflags |= RPCAUTH_LOOKUP_NEW;
        if (cred != NULL)
-               cred->cr_ops->crbind(task, cred, lookupflags);
+               new = cred->cr_ops->crbind(task, cred, lookupflags);
        else if (flags & RPC_TASK_ROOTCREDS)
-               rpcauth_bind_root_cred(task, lookupflags);
+               new = rpcauth_bind_root_cred(task, lookupflags);
        else
-               rpcauth_bind_new_cred(task, lookupflags);
+               new = rpcauth_bind_new_cred(task, lookupflags);
+       if (IS_ERR(new))
+               return PTR_ERR(new);
+       if (task->tk_msg.rpc_cred != NULL)
+               put_rpccred(task->tk_msg.rpc_cred);
+       task->tk_msg.rpc_cred = new;
+       return 0;
 }
 
 void
index 8bae33b36cc6f5757296327de3f11dfa11e628c6..43162bb3b78f47cb30c6054907839f92281f4c92 100644 (file)
@@ -54,18 +54,13 @@ struct rpc_cred *rpc_lookup_machine_cred(void)
 }
 EXPORT_SYMBOL_GPL(rpc_lookup_machine_cred);
 
-static void
-generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred, int lookupflags)
+static struct rpc_cred *generic_bind_cred(struct rpc_task *task,
+               struct rpc_cred *cred, int lookupflags)
 {
        struct rpc_auth *auth = task->tk_client->cl_auth;
        struct auth_cred *acred = &container_of(cred, struct generic_cred, gc_base)->acred;
-       struct rpc_cred *ret;
 
-       ret = auth->au_ops->lookup_cred(auth, acred, lookupflags);
-       if (!IS_ERR(ret))
-               task->tk_msg.rpc_cred = ret;
-       else
-               task->tk_status = PTR_ERR(ret);
+       return auth->au_ops->lookup_cred(auth, acred, lookupflags);
 }
 
 /*
index 3647c81fd68984c42e7ee25d26035d4b0e5e0e9c..f34b5e3823c0813d227454411392f4433a59ea4a 100644 (file)
@@ -606,7 +606,7 @@ rpc_task_set_rpc_message(struct rpc_task *task, const struct rpc_message *msg)
                task->tk_msg.rpc_argp = msg->rpc_argp;
                task->tk_msg.rpc_resp = msg->rpc_resp;
                /* Bind the user cred */
-               rpcauth_bindcred(task, msg->rpc_cred, task->tk_flags);
+               task->tk_status = rpcauth_bindcred(task, msg->rpc_cred, task->tk_flags);
        }
 }