Skip to content

Commit

Permalink
msg/async, v2: drop the scaffolding in preamble parsing.
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
  • Loading branch information
rzarzynski committed Feb 21, 2019
1 parent 971c141 commit c6e5411
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/msg/async/ProtocolV2.cc
Expand Up @@ -1439,11 +1439,26 @@ CtPtr ProtocolV2::handle_read_frame_preamble_main(char *buffer, int r) {
// everything through ::decode is unnecessary.
const auto& main_preamble = \
reinterpret_cast<preamble_block_t&>(*preamble.c_str());
next_tag = static_cast<Tag>(main_preamble.tag);

// FIXME: makeshift solution
ceph_assert_always(main_preamble.num_segments == 1 ||
main_preamble.num_segments == 4);
// verify preamble's CRC before any further processing
const auto rx_crc = ceph_crc32c(0,
reinterpret_cast<const unsigned char*>(&main_preamble),
sizeof(main_preamble) - sizeof(main_preamble.crc));
if (rx_crc != main_preamble.crc) {
ldout(cct, 10) << __func__ << " crc mismatch for main preamble"
<< " rx_crc=" << rx_crc
<< " tx_crc=" << main_preamble.crc << dendl;
return _fault();
}

// currently we do support only 4 or 1 segments
if (main_preamble.num_segments != 1 && main_preamble.num_segments != 4) {
ldout(cct, 10) << __func__ << " unsupported num_segments="
<< " tx_crc=" << main_preamble.num_segments << dendl;
return _fault();
}

next_tag = static_cast<Tag>(main_preamble.tag);

rx_segments_desc.clear();
rx_segments_data.clear();
Expand Down Expand Up @@ -1473,17 +1488,6 @@ CtPtr ProtocolV2::handle_read_frame_preamble_main(char *buffer, int r) {
next_payload_len += \
session_stream_handlers.rx->get_extra_size_at_final();
}

// TODO: move this ugliness into dedicated procedure
const auto rx_crc = ceph_crc32c(0,
reinterpret_cast<const unsigned char*>(&main_preamble),
sizeof(main_preamble) - sizeof(main_preamble.crc));
if (rx_crc != main_preamble.crc) {
ldout(cct, 10) << __func__ << "crc mismatch for main preamble"
<< " rx_crc=" << rx_crc
<< " tx_crc=" << main_preamble.crc << dendl;
return _fault();
}
}

// does it need throttle?
Expand Down

0 comments on commit c6e5411

Please sign in to comment.