Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SUNRPC endianness annotations

rpcrdma stuff lacks endianness annotations for on-the-wire data.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Al Viro and committed by
Linus Torvalds
2d8a9726 7a78a172

+28 -28
+16 -16
include/linux/sunrpc/rpc_rdma.h
··· 41 41 #define _LINUX_SUNRPC_RPC_RDMA_H 42 42 43 43 struct rpcrdma_segment { 44 - uint32_t rs_handle; /* Registered memory handle */ 45 - uint32_t rs_length; /* Length of the chunk in bytes */ 46 - uint64_t rs_offset; /* Chunk virtual address or offset */ 44 + __be32 rs_handle; /* Registered memory handle */ 45 + __be32 rs_length; /* Length of the chunk in bytes */ 46 + __be64 rs_offset; /* Chunk virtual address or offset */ 47 47 }; 48 48 49 49 /* 50 50 * read chunk(s), encoded as a linked list. 51 51 */ 52 52 struct rpcrdma_read_chunk { 53 - uint32_t rc_discrim; /* 1 indicates presence */ 54 - uint32_t rc_position; /* Position in XDR stream */ 53 + __be32 rc_discrim; /* 1 indicates presence */ 54 + __be32 rc_position; /* Position in XDR stream */ 55 55 struct rpcrdma_segment rc_target; 56 56 }; 57 57 ··· 66 66 * write chunk(s), encoded as a counted array. 67 67 */ 68 68 struct rpcrdma_write_array { 69 - uint32_t wc_discrim; /* 1 indicates presence */ 70 - uint32_t wc_nchunks; /* Array count */ 69 + __be32 wc_discrim; /* 1 indicates presence */ 70 + __be32 wc_nchunks; /* Array count */ 71 71 struct rpcrdma_write_chunk wc_array[0]; 72 72 }; 73 73 74 74 struct rpcrdma_msg { 75 - uint32_t rm_xid; /* Mirrors the RPC header xid */ 76 - uint32_t rm_vers; /* Version of this protocol */ 77 - uint32_t rm_credit; /* Buffers requested/granted */ 78 - uint32_t rm_type; /* Type of message (enum rpcrdma_proc) */ 75 + __be32 rm_xid; /* Mirrors the RPC header xid */ 76 + __be32 rm_vers; /* Version of this protocol */ 77 + __be32 rm_credit; /* Buffers requested/granted */ 78 + __be32 rm_type; /* Type of message (enum rpcrdma_proc) */ 79 79 union { 80 80 81 81 struct { /* no chunks */ 82 - uint32_t rm_empty[3]; /* 3 empty chunk lists */ 82 + __be32 rm_empty[3]; /* 3 empty chunk lists */ 83 83 } rm_nochunks; 84 84 85 85 struct { /* no chunks and padded */ 86 - uint32_t rm_align; /* Padding alignment */ 87 - uint32_t rm_thresh; /* Padding threshold */ 88 - uint32_t rm_pempty[3]; /* 3 empty chunk lists */ 86 + __be32 rm_align; /* Padding alignment */ 87 + __be32 rm_thresh; /* Padding threshold */ 88 + __be32 rm_pempty[3]; /* 3 empty chunk lists */ 89 89 } rm_padded; 90 90 91 - uint32_t rm_chunks[0]; /* read, write and reply chunks */ 91 + __be32 rm_chunks[0]; /* read, write and reply chunks */ 92 92 93 93 } rm_body; 94 94 };
+12 -12
net/sunrpc/xprtrdma/rpc_rdma.c
··· 181 181 struct rpcrdma_read_chunk *cur_rchunk = NULL; 182 182 struct rpcrdma_write_array *warray = NULL; 183 183 struct rpcrdma_write_chunk *cur_wchunk = NULL; 184 - u32 *iptr = headerp->rm_body.rm_chunks; 184 + __be32 *iptr = headerp->rm_body.rm_chunks; 185 185 186 186 if (type == rpcrdma_readch || type == rpcrdma_areadch) { 187 187 /* a read chunk - server will RDMA Read our memory */ ··· 217 217 cur_rchunk->rc_target.rs_handle = htonl(seg->mr_rkey); 218 218 cur_rchunk->rc_target.rs_length = htonl(seg->mr_len); 219 219 xdr_encode_hyper( 220 - (u32 *)&cur_rchunk->rc_target.rs_offset, 220 + (__be32 *)&cur_rchunk->rc_target.rs_offset, 221 221 seg->mr_base); 222 222 dprintk("RPC: %s: read chunk " 223 223 "elem %d@0x%llx:0x%x pos %d (%s)\n", __func__, ··· 229 229 cur_wchunk->wc_target.rs_handle = htonl(seg->mr_rkey); 230 230 cur_wchunk->wc_target.rs_length = htonl(seg->mr_len); 231 231 xdr_encode_hyper( 232 - (u32 *)&cur_wchunk->wc_target.rs_offset, 232 + (__be32 *)&cur_wchunk->wc_target.rs_offset, 233 233 seg->mr_base); 234 234 dprintk("RPC: %s: %s chunk " 235 235 "elem %d@0x%llx:0x%x (%s)\n", __func__, ··· 257 257 * finish off header. If write, marshal discrim and nchunks. 258 258 */ 259 259 if (cur_rchunk) { 260 - iptr = (u32 *) cur_rchunk; 260 + iptr = (__be32 *) cur_rchunk; 261 261 *iptr++ = xdr_zero; /* finish the read chunk list */ 262 262 *iptr++ = xdr_zero; /* encode a NULL write chunk list */ 263 263 *iptr++ = xdr_zero; /* encode a NULL reply chunk */ 264 264 } else { 265 265 warray->wc_discrim = xdr_one; 266 266 warray->wc_nchunks = htonl(nchunks); 267 - iptr = (u32 *) cur_wchunk; 267 + iptr = (__be32 *) cur_wchunk; 268 268 if (type == rpcrdma_writech) { 269 269 *iptr++ = xdr_zero; /* finish the write chunk list */ 270 270 *iptr++ = xdr_zero; /* encode a NULL reply chunk */ ··· 559 559 * RDMA'd by server. See map at rpcrdma_create_chunks()! :-) 560 560 */ 561 561 static int 562 - rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, u32 **iptrp) 562 + rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, __be32 **iptrp) 563 563 { 564 564 unsigned int i, total_len; 565 565 struct rpcrdma_write_chunk *cur_wchunk; ··· 573 573 struct rpcrdma_segment *seg = &cur_wchunk->wc_target; 574 574 ifdebug(FACILITY) { 575 575 u64 off; 576 - xdr_decode_hyper((u32 *)&seg->rs_offset, &off); 576 + xdr_decode_hyper((__be32 *)&seg->rs_offset, &off); 577 577 dprintk("RPC: %s: chunk %d@0x%llx:0x%x\n", 578 578 __func__, 579 579 ntohl(seg->rs_length), ··· 585 585 } 586 586 /* check and adjust for properly terminated write chunk */ 587 587 if (wrchunk) { 588 - u32 *w = (u32 *) cur_wchunk; 588 + __be32 *w = (__be32 *) cur_wchunk; 589 589 if (*w++ != xdr_zero) 590 590 return -1; 591 591 cur_wchunk = (struct rpcrdma_write_chunk *) w; ··· 593 593 if ((char *) cur_wchunk > rep->rr_base + rep->rr_len) 594 594 return -1; 595 595 596 - *iptrp = (u32 *) cur_wchunk; 596 + *iptrp = (__be32 *) cur_wchunk; 597 597 return total_len; 598 598 } 599 599 ··· 721 721 struct rpc_rqst *rqst; 722 722 struct rpc_xprt *xprt = rep->rr_xprt; 723 723 struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); 724 - u32 *iptr; 724 + __be32 *iptr; 725 725 int i, rdmalen, status; 726 726 727 727 /* Check status. If bad, signal disconnect and return rep to pool */ ··· 801 801 r_xprt->rx_stats.total_rdma_reply += rdmalen; 802 802 } else { 803 803 /* else ordinary inline */ 804 - iptr = (u32 *)((unsigned char *)headerp + 28); 804 + iptr = (__be32 *)((unsigned char *)headerp + 28); 805 805 rep->rr_len -= 28; /*sizeof *headerp;*/ 806 806 status = rep->rr_len; 807 807 } ··· 816 816 headerp->rm_body.rm_chunks[2] != xdr_one || 817 817 req->rl_nchunks == 0) 818 818 goto badheader; 819 - iptr = (u32 *)((unsigned char *)headerp + 28); 819 + iptr = (__be32 *)((unsigned char *)headerp + 28); 820 820 rdmalen = rpcrdma_count_chunks(rep, req->rl_nchunks, 0, &iptr); 821 821 if (rdmalen < 0) 822 822 goto badheader;