From: Ilya Dryomov Date: Mon, 4 May 2020 15:42:28 +0000 (+0200) Subject: msg/async/frames_v2: rename epilogue structs X-Git-Tag: v15.2.5~164^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=29aeaeedad51e3787ab3b5d47580f435c51c0ded;p=ceph.git msg/async/frames_v2: rename epilogue structs In preparation for msgr2,1, rename epilogue structs: epilogue_plain_block_t to epilogue_crc_rev0_block_t and epilogue_secure_block_t to epilogue_secure_rev0_block_t (rev0 stands for revision 0). Also, get rid of size constants that just disguise the struct type. Signed-off-by: Ilya Dryomov (cherry picked from commit 712915b3d46652c07c2b05162d610afd64891e9e) --- diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index d373048f89f..390f8bffa1b 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -284,7 +284,7 @@ size_t ProtocolV2::get_current_msg_size() const seastar::future ProtocolV2::read_main_preamble() { - return read_exactly(FRAME_PREAMBLE_SIZE) + return read_exactly(sizeof(preamble_block_t)) .then([this] (auto bl) { if (session_stream_handlers.rx) { session_stream_handlers.rx->reset_rx_handler(); @@ -372,7 +372,7 @@ seastar::future<> ProtocolV2::read_frame_payload() ).then([this] { // TODO: get_epilogue_size() ceph_assert(!session_stream_handlers.rx); - return read_exactly(FRAME_PLAIN_EPILOGUE_SIZE); + return read_exactly(sizeof(epilogue_crc_rev0_block_t)); }).then([this] (auto bl) { logger().trace("{} RECV({}) frame epilogue", conn, bl.size()); @@ -381,7 +381,7 @@ seastar::future<> ProtocolV2::read_frame_payload() // TODO ceph_assert(false); } else { - auto& epilogue = *reinterpret_cast(bl.get()); + auto& epilogue = *reinterpret_cast(bl.get()); for (std::uint8_t idx = 0; idx < rx_segments_data.size(); idx++) { const __u32 expected_crc = epilogue.crc_values[idx]; const __u32 calculated_crc = rx_segments_data[idx].crc32c(-1); diff --git a/src/msg/async/frames_v2.cc b/src/msg/async/frames_v2.cc index bcbebdbd2d2..bb292d0cf50 100644 --- a/src/msg/async/frames_v2.cc +++ b/src/msg/async/frames_v2.cc @@ -87,7 +87,7 @@ uint64_t FrameAssembler::get_frame_onwire_len() const { bufferlist FrameAssembler::asm_crc_rev0(const preamble_block_t& preamble, bufferlist segment_bls[]) const { - epilogue_plain_block_t epilogue; + epilogue_crc_rev0_block_t epilogue; // FIPS zeroization audit 20191115: this memset is not security related. ::memset(&epilogue, 0, sizeof(epilogue)); @@ -110,7 +110,7 @@ bufferlist FrameAssembler::asm_secure_rev0(const preamble_block_t& preamble, preamble_bl.append(reinterpret_cast(&preamble), sizeof(preamble)); - epilogue_secure_block_t epilogue; + epilogue_secure_rev0_block_t epilogue; // FIPS zeroization audit 20191115: this memset is not security related. ::memset(&epilogue, 0, sizeof(epilogue)); bufferlist epilogue_bl(sizeof(epilogue)); @@ -207,8 +207,8 @@ Tag FrameAssembler::disassemble_preamble(bufferlist& preamble_bl) { bool FrameAssembler::disasm_all_crc_rev0(bufferlist segment_bls[], bufferlist& epilogue_bl) const { - ceph_assert(epilogue_bl.length() == sizeof(epilogue_plain_block_t)); - auto epilogue = reinterpret_cast( + ceph_assert(epilogue_bl.length() == sizeof(epilogue_crc_rev0_block_t)); + auto epilogue = reinterpret_cast( epilogue_bl.c_str()); for (size_t i = 0; i < m_descs.size(); i++) { @@ -228,10 +228,10 @@ bool FrameAssembler::disasm_all_secure_rev0(bufferlist segment_bls[], } } - ceph_assert(epilogue_bl.length() == sizeof(epilogue_secure_block_t) + + ceph_assert(epilogue_bl.length() == sizeof(epilogue_secure_rev0_block_t) + get_auth_tag_len()); m_crypto->rx->authenticated_decrypt_update_final(epilogue_bl); - auto epilogue = reinterpret_cast( + auto epilogue = reinterpret_cast( epilogue_bl.c_str()); return !(epilogue->late_flags & FRAME_FLAGS_LATEABRT); } diff --git a/src/msg/async/frames_v2.h b/src/msg/async/frames_v2.h index f61ed8531e0..07ce8f55a55 100644 --- a/src/msg/async/frames_v2.h +++ b/src/msg/async/frames_v2.h @@ -129,27 +129,20 @@ static_assert(std::is_standard_layout::value); // In addition to integrity/authenticity data each variant of epilogue // conveys late_flags. The initial user of this field will be the late // frame abortion facility. -struct epilogue_plain_block_t { +struct epilogue_crc_rev0_block_t { __u8 late_flags; ceph_le32 crc_values[MAX_NUM_SEGMENTS]; } __attribute__((packed)); -static_assert(std::is_standard_layout::value); +static_assert(std::is_standard_layout_v); -struct epilogue_secure_block_t { +struct epilogue_secure_rev0_block_t { __u8 late_flags; __u8 padding[CRYPTO_BLOCK_SIZE - sizeof(late_flags)]; __u8 ciphers_private_data[]; } __attribute__((packed)); -static_assert(sizeof(epilogue_secure_block_t) % CRYPTO_BLOCK_SIZE == 0); -static_assert(std::is_standard_layout::value); - - -static constexpr uint32_t FRAME_PREAMBLE_SIZE = sizeof(preamble_block_t); -static constexpr uint32_t FRAME_PLAIN_EPILOGUE_SIZE = - sizeof(epilogue_plain_block_t); -static constexpr uint32_t FRAME_SECURE_EPILOGUE_SIZE = - sizeof(epilogue_secure_block_t); +static_assert(sizeof(epilogue_secure_rev0_block_t) % CRYPTO_BLOCK_SIZE == 0); +static_assert(std::is_standard_layout_v); #define FRAME_FLAGS_LATEABRT (1<<0) /* frame was aborted after txing data */ @@ -193,9 +186,9 @@ public: uint32_t get_epilogue_onwire_len() const { ceph_assert(!m_descs.empty()); if (m_crypto->rx) { - return sizeof(epilogue_secure_block_t) + get_auth_tag_len(); + return sizeof(epilogue_secure_rev0_block_t) + get_auth_tag_len(); } - return sizeof(epilogue_plain_block_t); + return sizeof(epilogue_crc_rev0_block_t); } uint64_t get_frame_logical_len() const;