]> git.hungrycats.org Git - linux/commitdiff
[PATCH] kNFSd: Don't over-write rpc request with response.
authorNeil Brown <neilb@cse.unsw.edu.au>
Fri, 11 Oct 2002 12:39:50 +0000 (05:39 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Fri, 11 Oct 2002 12:39:50 +0000 (05:39 -0700)
We are going to want rpc request to be immutable so that
we can take a copy and put it aside to be processed later.
Currently the tcp code writes the response into the same
buffer as the request, thus corrupting the request.
With this patch, the response goes after the request.  There should
always be enough room as large reqeusts (Write) has small
responses, and large responses (read) are for small requests.

buflen is changed for requests to record the length of the
request.  It already gets reset for each new request.

net/sunrpc/svcsock.c

index 6319f64da31fecaca57357cbe1586ea557bae189..740eb3962f23ec75cbbdf1581e9b1e2d2b78f6eb 100644 (file)
@@ -526,6 +526,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
        rqstp->rq_argbuf.base = data;
        rqstp->rq_argbuf.buf  = data;
        rqstp->rq_argbuf.len  = (len >> 2);
+       rqstp->rq_argbuf.buflen = (len >> 2);
        /* rqstp->rq_resbuf      = rqstp->rq_defbuf; */
        rqstp->rq_prot        = IPPROTO_UDP;
 
@@ -867,14 +868,17 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
 
        dprintk("svc: TCP complete record (%d bytes)\n", len);
 
-       /* Position reply write pointer immediately after
-        * record length */
-       rqstp->rq_resbuf.buf += 1;
+       /* Position reply write pointer immediately args,
+        * allowing for record length */
+       rqstp->rq_resbuf.base = rqstp->rq_argbuf.base + (len>>2);
+       rqstp->rq_resbuf.buf  = rqstp->rq_resbuf.base + 1;
        rqstp->rq_resbuf.len  = 1;
+       rqstp->rq_resbuf.buflen= rqstp->rq_argbuf.buflen - (len>>2) - 1;
 
        rqstp->rq_skbuff      = 0;
        rqstp->rq_argbuf.buf += 1;
        rqstp->rq_argbuf.len  = (len >> 2);
+       rqstp->rq_argbuf.buflen = (len >> 2);
        rqstp->rq_prot        = IPPROTO_TCP;
 
        /* Reset TCP read info */