]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/frames_v2: rename epilogue structs
authorIlya Dryomov <idryomov@gmail.com>
Mon, 4 May 2020 15:42:28 +0000 (17:42 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 14 Jun 2020 11:56:09 +0000 (11:56 +0000)
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 <idryomov@gmail.com>
src/crimson/net/ProtocolV2.cc
src/msg/async/frames_v2.cc
src/msg/async/frames_v2.h

index 3e48417e9cc526c59efdddd9dd9387cc9e23a0a9..a524497d80bdb36b8798e7d8b3a5bbe599d07330 100644 (file)
@@ -258,7 +258,7 @@ size_t ProtocolV2::get_current_msg_size() const
 
 seastar::future<Tag> 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();
@@ -346,7 +346,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());
 
@@ -355,7 +355,7 @@ seastar::future<> ProtocolV2::read_frame_payload()
       // TODO
       ceph_assert(false);
     } else {
-      auto& epilogue = *reinterpret_cast<const epilogue_plain_block_t*>(bl.get());
+      auto& epilogue = *reinterpret_cast<const epilogue_crc_rev0_block_t*>(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);
index bcbebdbd2d22923718ca8a3c358e7e23798d223a..bb292d0cf5085f6dce584908c1013fe6924cbb88 100644 (file)
@@ -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<const char*>(&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<const epilogue_plain_block_t*>(
+  ceph_assert(epilogue_bl.length() == sizeof(epilogue_crc_rev0_block_t));
+  auto epilogue = reinterpret_cast<const epilogue_crc_rev0_block_t*>(
       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<const epilogue_secure_block_t*>(
+  auto epilogue = reinterpret_cast<const epilogue_secure_rev0_block_t*>(
       epilogue_bl.c_str());
   return !(epilogue->late_flags & FRAME_FLAGS_LATEABRT);
 }
index bfb86fba947fb7843999dc5cd68d24fcaee89094..74c9d5ed9c7a9c27081f863aa2a1ed333ca53948 100644 (file)
@@ -129,27 +129,20 @@ static_assert(std::is_standard_layout<preamble_block_t>::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<epilogue_plain_block_t>::value);
+static_assert(std::is_standard_layout_v<epilogue_crc_rev0_block_t>);
 
-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<epilogue_secure_block_t>::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<epilogue_secure_rev0_block_t>);
 
 #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;