Whamcloud - gitweb
LU-15098 tests: sanity-sec 27a exec commands on right node
[fs/lustre-release.git] / lustre / ptlrpc / sec_plain.c
index 881add9..f1141a0 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/ptlrpc/sec_plain.c
  *
@@ -156,13 +155,13 @@ static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc)
        unsigned int off, i;
 
        for (i = 0; i < desc->bd_iov_count; i++) {
-               if (desc->bd_vec[i].kiov_len == 0)
+               if (desc->bd_vec[i].bv_len == 0)
                        continue;
 
-               ptr = kmap(desc->bd_vec[i].kiov_page);
-               off = desc->bd_vec[i].kiov_offset & ~PAGE_MASK;
+               ptr = kmap(desc->bd_vec[i].bv_page);
+               off = desc->bd_vec[i].bv_offset & ~PAGE_MASK;
                ptr[off] ^= 0x1;
-               kunmap(desc->bd_vec[i].kiov_page);
+               kunmap(desc->bd_vec[i].bv_page);
                return;
        }
 }
@@ -216,7 +215,6 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
 {
        struct lustre_msg *msg = req->rq_repdata;
        struct plain_header *phdr;
-       __u32 cksum;
        bool swabbed;
 
        ENTRY;
@@ -225,7 +223,7 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
                RETURN(-EPROTO);
        }
 
-       swabbed = ptlrpc_rep_need_swab(req);
+       swabbed = req_capsule_rep_need_swab(&req->rq_pill);
 
        phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr));
        if (phdr == NULL) {
@@ -251,12 +249,8 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req)
        }
 
        if (unlikely(req->rq_early)) {
-               unsigned int hsize = 4;
+               __u32 cksum = lustre_msg_calc_cksum(msg, PLAIN_PACK_MSG_OFF);
 
-               cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32,
-                               lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0),
-                               lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF),
-                               NULL, 0, (unsigned char *)&cksum, &hsize);
                if (cksum != msg->lm_cksum) {
                        CDEBUG(D_SEC,
                               "early reply checksum mismatch: %08x != %08x\n",
@@ -355,12 +349,12 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx,
 
        /* fix the actual data size */
        for (i = 0, nob = 0; i < desc->bd_iov_count; i++) {
-               if (desc->bd_vec[i].kiov_len +
+               if (desc->bd_vec[i].bv_len +
                    nob > desc->bd_nob_transferred) {
-                       desc->bd_vec[i].kiov_len =
+                       desc->bd_vec[i].bv_len =
                                desc->bd_nob_transferred - nob;
                }
-               nob += desc->bd_vec[i].kiov_len;
+               nob += desc->bd_vec[i].bv_len;
        }
 
        rc = plain_verify_bulk_csum(desc, req->rq_flvr.u_bulk.hash.hash_alg,
@@ -755,7 +749,7 @@ static int plain_accept(struct ptlrpc_request *req)
                RETURN(SECSVC_DROP);
        }
 
-       swabbed = ptlrpc_req_need_swab(req);
+       swabbed = req_capsule_req_need_swab(&req->rq_pill);
 
        phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr));
        if (phdr == NULL) {
@@ -890,20 +884,13 @@ int plain_authorize(struct ptlrpc_request *req)
                phdr->ph_flags |= PLAIN_FL_BULK;
 
        rs->rs_repdata_len = len;
+       req->rq_reply_off = 0;
 
        if (likely(req->rq_packed_final)) {
                if (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)
                        req->rq_reply_off = plain_at_offset;
-               else
-                       req->rq_reply_off = 0;
        } else {
-               unsigned int hsize = 4;
-
-               cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32,
-                       lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0),
-                       lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF),
-                       NULL, 0, (unsigned char *)&msg->lm_cksum, &hsize);
-               req->rq_reply_off = 0;
+               msg->lm_cksum = lustre_msg_calc_cksum(msg, PLAIN_PACK_MSG_OFF);
        }
 
        RETURN(0);