Commit 4ed45520 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] kNFSd: Don't over-write rpc request with response.

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.
parent 85d18365
...@@ -526,6 +526,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) ...@@ -526,6 +526,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
rqstp->rq_argbuf.base = data; rqstp->rq_argbuf.base = data;
rqstp->rq_argbuf.buf = data; rqstp->rq_argbuf.buf = data;
rqstp->rq_argbuf.len = (len >> 2); rqstp->rq_argbuf.len = (len >> 2);
rqstp->rq_argbuf.buflen = (len >> 2);
/* rqstp->rq_resbuf = rqstp->rq_defbuf; */ /* rqstp->rq_resbuf = rqstp->rq_defbuf; */
rqstp->rq_prot = IPPROTO_UDP; rqstp->rq_prot = IPPROTO_UDP;
...@@ -867,14 +868,17 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) ...@@ -867,14 +868,17 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
dprintk("svc: TCP complete record (%d bytes)\n", len); dprintk("svc: TCP complete record (%d bytes)\n", len);
/* Position reply write pointer immediately after /* Position reply write pointer immediately args,
* record length */ * allowing for record length */
rqstp->rq_resbuf.buf += 1; 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.len = 1;
rqstp->rq_resbuf.buflen= rqstp->rq_argbuf.buflen - (len>>2) - 1;
rqstp->rq_skbuff = 0; rqstp->rq_skbuff = 0;
rqstp->rq_argbuf.buf += 1; rqstp->rq_argbuf.buf += 1;
rqstp->rq_argbuf.len = (len >> 2); rqstp->rq_argbuf.len = (len >> 2);
rqstp->rq_argbuf.buflen = (len >> 2);
rqstp->rq_prot = IPPROTO_TCP; rqstp->rq_prot = IPPROTO_TCP;
/* Reset TCP read info */ /* Reset TCP read info */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment