From 84a8d367a7ee02a22fac8c778846c9dad33b1cd9 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Fri, 17 Oct 2008 07:47:49 +0000 Subject: [PATCH] Branch b1_8_gate b=17151 i=nathan, adilger patch provide by LLNL Validate ptlrpc body checksum before swabbing. --- lustre/ptlrpc/pack_generic.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 0364d8d..7d8aec5 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -68,7 +68,7 @@ static inline int lustre_msg_hdr_size_v2(int count) return size_round(offsetof(struct lustre_msg_v2, lm_buflens[count])); } -static int lustre_msg_need_swab(struct lustre_msg *msg) +int lustre_msg_need_swab(struct lustre_msg *msg) { return (msg->lm_magic == LUSTRE_MSG_MAGIC_V1_SWABBED) || (msg->lm_magic == LUSTRE_MSG_MAGIC_V2_SWABBED); @@ -914,6 +914,20 @@ static inline int lustre_unpack_ptlrpc_body_v2(struct lustre_msg_v2 *m, return 0; } +int lustre_unpack_msg_ptlrpc_body(struct lustre_msg *msg, + int offset, int swab_needed) +{ + switch (msg->lm_magic) { + case LUSTRE_MSG_MAGIC_V1: + return 0; + case LUSTRE_MSG_MAGIC_V2: + return lustre_unpack_ptlrpc_body_v2(msg, offset, swab_needed); + default: + CERROR("incorrect message magic: %08x\n", msg->lm_magic); + return -EINVAL; + } +} + int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset) { switch (req->rq_reqmsg->lm_magic) { -- 1.8.3.1