diff options
-rw-r--r-- | include/linux/sunrpc/svc_rdma.h | 2 | ||||
-rw-r--r-- | net/sunrpc/xprtrdma/svc_rdma_marshal.c | 16 | ||||
-rw-r--r-- | net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 15 |
3 files changed, 12 insertions, 21 deletions
diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h index 975da754c778..2280325e4c88 100644 --- a/include/linux/sunrpc/svc_rdma.h +++ b/include/linux/sunrpc/svc_rdma.h | |||
@@ -178,8 +178,6 @@ struct svcxprt_rdma { | |||
178 | #define RPCRDMA_MAX_REQ_SIZE 4096 | 178 | #define RPCRDMA_MAX_REQ_SIZE 4096 |
179 | 179 | ||
180 | /* svc_rdma_marshal.c */ | 180 | /* svc_rdma_marshal.c */ |
181 | extern void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *, | ||
182 | int *, int *); | ||
183 | extern int svc_rdma_xdr_decode_req(struct rpcrdma_msg **, struct svc_rqst *); | 181 | extern int svc_rdma_xdr_decode_req(struct rpcrdma_msg **, struct svc_rqst *); |
184 | extern int svc_rdma_xdr_decode_deferred_req(struct svc_rqst *); | 182 | extern int svc_rdma_xdr_decode_deferred_req(struct svc_rqst *); |
185 | extern int svc_rdma_xdr_encode_error(struct svcxprt_rdma *, | 183 | extern int svc_rdma_xdr_encode_error(struct svcxprt_rdma *, |
diff --git a/net/sunrpc/xprtrdma/svc_rdma_marshal.c b/net/sunrpc/xprtrdma/svc_rdma_marshal.c index 65b146297f5a..b681855cf970 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_marshal.c +++ b/net/sunrpc/xprtrdma/svc_rdma_marshal.c | |||
@@ -71,22 +71,6 @@ static u32 *decode_read_list(u32 *va, u32 *vaend) | |||
71 | } | 71 | } |
72 | 72 | ||
73 | /* | 73 | /* |
74 | * Determine number of chunks and total bytes in chunk list. The chunk | ||
75 | * list has already been verified to fit within the RPCRDMA header. | ||
76 | */ | ||
77 | void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *ch, | ||
78 | int *ch_count, int *byte_count) | ||
79 | { | ||
80 | /* compute the number of bytes represented by read chunks */ | ||
81 | *byte_count = 0; | ||
82 | *ch_count = 0; | ||
83 | for (; ch->rc_discrim != 0; ch++) { | ||
84 | *byte_count = *byte_count + ntohl(ch->rc_target.rs_length); | ||
85 | *ch_count = *ch_count + 1; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * Decodes a write chunk list. The expected format is as follows: | 74 | * Decodes a write chunk list. The expected format is as follows: |
91 | * descrim : xdr_one | 75 | * descrim : xdr_one |
92 | * nchunks : <count> | 76 | * nchunks : <count> |
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c index 2c67de032009..b3b7bb85844d 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | |||
@@ -365,12 +365,22 @@ static int rdma_read_chunk_frmr(struct svcxprt_rdma *xprt, | |||
365 | return ret; | 365 | return ret; |
366 | } | 366 | } |
367 | 367 | ||
368 | static unsigned int | ||
369 | rdma_rcl_chunk_count(struct rpcrdma_read_chunk *ch) | ||
370 | { | ||
371 | unsigned int count; | ||
372 | |||
373 | for (count = 0; ch->rc_discrim != xdr_zero; ch++) | ||
374 | count++; | ||
375 | return count; | ||
376 | } | ||
377 | |||
368 | static int rdma_read_chunks(struct svcxprt_rdma *xprt, | 378 | static int rdma_read_chunks(struct svcxprt_rdma *xprt, |
369 | struct rpcrdma_msg *rmsgp, | 379 | struct rpcrdma_msg *rmsgp, |
370 | struct svc_rqst *rqstp, | 380 | struct svc_rqst *rqstp, |
371 | struct svc_rdma_op_ctxt *head) | 381 | struct svc_rdma_op_ctxt *head) |
372 | { | 382 | { |
373 | int page_no, ch_count, ret; | 383 | int page_no, ret; |
374 | struct rpcrdma_read_chunk *ch; | 384 | struct rpcrdma_read_chunk *ch; |
375 | u32 page_offset, byte_count; | 385 | u32 page_offset, byte_count; |
376 | u64 rs_offset; | 386 | u64 rs_offset; |
@@ -381,8 +391,7 @@ static int rdma_read_chunks(struct svcxprt_rdma *xprt, | |||
381 | if (!ch) | 391 | if (!ch) |
382 | return 0; | 392 | return 0; |
383 | 393 | ||
384 | svc_rdma_rcl_chunk_counts(ch, &ch_count, &byte_count); | 394 | if (rdma_rcl_chunk_count(ch) > RPCSVC_MAXPAGES) |
385 | if (ch_count > RPCSVC_MAXPAGES) | ||
386 | return -EINVAL; | 395 | return -EINVAL; |
387 | 396 | ||
388 | /* The request is completed when the RDMA_READs complete. The | 397 | /* The request is completed when the RDMA_READs complete. The |