]> err.no Git - linux-2.6/blobdiff - net/sunrpc/clnt.c
[NET] CORE: Fix whitespace errors.
[linux-2.6] / net / sunrpc / clnt.c
index 5a28ffac99eab1b73f153a34126142df9f5128d9..52429b1ffcc1d8d33bf7cf116bab5bfa0ceb052c 100644 (file)
@@ -234,12 +234,31 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
 {
        struct rpc_xprt *xprt;
        struct rpc_clnt *clnt;
+       struct rpc_xprtsock_create xprtargs = {
+               .proto = args->protocol,
+               .srcaddr = args->saddress,
+               .dstaddr = args->address,
+               .addrlen = args->addrsize,
+               .timeout = args->timeout
+       };
+       char servername[20];
 
-       xprt = xprt_create_transport(args->protocol, args->address,
-                                       args->addrsize, args->timeout);
+       xprt = xprt_create_transport(&xprtargs);
        if (IS_ERR(xprt))
                return (struct rpc_clnt *)xprt;
 
+       /*
+        * If the caller chooses not to specify a hostname, whip
+        * up a string representation of the passed-in address.
+        */
+       if (args->servername == NULL) {
+               struct sockaddr_in *addr =
+                                       (struct sockaddr_in *) &args->address;
+               snprintf(servername, sizeof(servername), NIPQUAD_FMT,
+                       NIPQUAD(addr->sin_addr.s_addr));
+               args->servername = servername;
+       }
+
        /*
         * By default, kernel RPC client connects from a reserved port.
         * CAP_NET_BIND_SERVICE will not be set for unprivileged requesters,
@@ -352,10 +371,6 @@ rpc_free_client(struct kref *kref)
 
        dprintk("RPC:       destroying %s client for %s\n",
                        clnt->cl_protname, clnt->cl_server);
-       if (clnt->cl_auth) {
-               rpcauth_destroy(clnt->cl_auth);
-               clnt->cl_auth = NULL;
-       }
        if (!IS_ERR(clnt->cl_dentry)) {
                rpc_rmdir(clnt->cl_dentry);
                rpc_put_mount();
@@ -375,6 +390,30 @@ out_free:
        kfree(clnt);
 }
 
+/*
+ * Free an RPC client
+ */
+static void
+rpc_free_auth(struct kref *kref)
+{
+       struct rpc_clnt *clnt = container_of(kref, struct rpc_clnt, cl_kref);
+
+       if (clnt->cl_auth == NULL) {
+               rpc_free_client(kref);
+               return;
+       }
+
+       /*
+        * Note: RPCSEC_GSS may need to send NULL RPC calls in order to
+        *       release remaining GSS contexts. This mechanism ensures
+        *       that it can do so safely.
+        */
+       kref_init(kref);
+       rpcauth_release(clnt->cl_auth);
+       clnt->cl_auth = NULL;
+       kref_put(kref, rpc_free_client);
+}
+
 /*
  * Release reference to the RPC client
  */
@@ -385,7 +424,7 @@ rpc_release_client(struct rpc_clnt *clnt)
 
        if (list_empty(&clnt->cl_tasks))
                wake_up(&destroy_wait);
-       kref_put(&clnt->cl_kref, rpc_free_client);
+       kref_put(&clnt->cl_kref, rpc_free_auth);
 }
 
 /**
@@ -767,7 +806,7 @@ call_reserveresult(struct rpc_task *task)
 static void
 call_allocate(struct rpc_task *task)
 {
-       unsigned int slack = task->tk_auth->au_cslack;
+       unsigned int slack = task->tk_msg.rpc_cred->cr_auth->au_cslack;
        struct rpc_rqst *req = task->tk_rqstp;
        struct rpc_xprt *xprt = task->tk_xprt;
        struct rpc_procinfo *proc = task->tk_msg.rpc_proc;
@@ -865,10 +904,8 @@ call_encode(struct rpc_task *task)
        if (encode == NULL)
                return;
 
-       lock_kernel();
        task->tk_status = rpcauth_wrap_req(task, encode, req, p,
                        task->tk_msg.rpc_argp);
-       unlock_kernel();
        if (task->tk_status == -ENOMEM) {
                /* XXX: Is this sane? */
                rpc_delay(task, 3*HZ);
@@ -1199,10 +1236,8 @@ call_decode(struct rpc_task *task)
        task->tk_action = rpc_exit_task;
 
        if (decode) {
-               lock_kernel();
                task->tk_status = rpcauth_unwrap_resp(task, decode, req, p,
                                                      task->tk_msg.rpc_resp);
-               unlock_kernel();
        }
        dprintk("RPC: %5u call_decode result %d\n", task->tk_pid,
                        task->tk_status);
@@ -1295,9 +1330,9 @@ call_verify(struct rpc_task *task)
                 * - if it isn't pointer subtraction in the NFS client may give
                 *   undefined results
                 */
-               printk(KERN_WARNING
-                      "call_verify: XDR representation not a multiple of"
-                      " 4 bytes: 0x%x\n", task->tk_rqstp->rq_rcv_buf.len);
+               dprintk("RPC: %5u %s: XDR representation not a multiple of"
+                      " 4 bytes: 0x%x\n", task->tk_pid, __FUNCTION__,
+                      task->tk_rqstp->rq_rcv_buf.len);
                goto out_eio;
        }
        if ((len -= 3) < 0)
@@ -1305,7 +1340,8 @@ call_verify(struct rpc_task *task)
        p += 1; /* skip XID */
 
        if ((n = ntohl(*p++)) != RPC_REPLY) {
-               printk(KERN_WARNING "call_verify: not an RPC reply: %x\n", n);
+               dprintk("RPC: %5u %s: not an RPC reply: %x\n",
+                               task->tk_pid, __FUNCTION__, n);
                goto out_garbage;
        }
        if ((n = ntohl(*p++)) != RPC_MSG_ACCEPTED) {
@@ -1356,7 +1392,8 @@ call_verify(struct rpc_task *task)
                               "authentication.\n", task->tk_client->cl_server);
                        break;
                default:
-                       printk(KERN_WARNING "call_verify: unknown auth error: %x\n", n);
+                       dprintk("RPC: %5u %s: unknown auth error: %x\n",
+                                       task->tk_pid, __FUNCTION__, n);
                        error = -EIO;
                }
                dprintk("RPC: %5u %s: call rejected %d\n",
@@ -1364,7 +1401,8 @@ call_verify(struct rpc_task *task)
                goto out_err;
        }
        if (!(p = rpcauth_checkverf(task, p))) {
-               printk(KERN_WARNING "call_verify: auth check failed\n");
+               dprintk("RPC: %5u %s: auth check failed\n",
+                               task->tk_pid, __FUNCTION__);
                goto out_garbage;               /* bad verifier, retry */
        }
        len = p - (__be32 *)iov->iov_base - 1;
@@ -1403,7 +1441,8 @@ call_verify(struct rpc_task *task)
                                task->tk_pid, __FUNCTION__);
                break;                  /* retry */
        default:
-               printk(KERN_WARNING "call_verify: server accept status: %x\n", n);
+               dprintk("RPC: %5u %s: server accept status: %x\n",
+                               task->tk_pid, __FUNCTION__, n);
                /* Also retry */
        }
 
@@ -1417,14 +1456,16 @@ out_garbage:
 out_retry:
                return ERR_PTR(-EAGAIN);
        }
-       printk(KERN_WARNING "RPC %s: retry failed, exit EIO\n", __FUNCTION__);
 out_eio:
        error = -EIO;
 out_err:
        rpc_exit(task, error);
+       dprintk("RPC: %5u %s: call failed with error %d\n", task->tk_pid,
+                       __FUNCTION__, error);
        return ERR_PTR(error);
 out_overflow:
-       printk(KERN_WARNING "RPC %s: server reply was truncated.\n", __FUNCTION__);
+       dprintk("RPC: %5u %s: server reply was truncated.\n", task->tk_pid,
+                       __FUNCTION__);
        goto out_garbage;
 }