From: Marcel Lauhoff Date: Fri, 20 Sep 2024 15:39:50 +0000 (+0200) Subject: msg: Add dump() to Protocol{V1,V2} X-Git-Tag: v20.3.0~373^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b478ff8dbd07340800e327adcf8689b333482bfd;p=ceph.git msg: Add dump() to Protocol{V1,V2} Add dump() methods to the async messenger protocol layer. Export cipher and compressor name from the respective handlers to be able to export a human understandable information here. Signed-off-by: Marcel Lauhoff --- diff --git a/src/msg/async/Protocol.h b/src/msg/async/Protocol.h index 10436307ebf8..0878b6cddaa9 100644 --- a/src/msg/async/Protocol.h +++ b/src/msg/async/Protocol.h @@ -132,6 +132,8 @@ public: virtual void write_event() = 0; virtual bool is_queued() = 0; + virtual void dump(Formatter *f) = 0; + int get_con_mode() const { return auth_meta->con_mode; } diff --git a/src/msg/async/ProtocolV1.cc b/src/msg/async/ProtocolV1.cc index 17d3dcfbe2c8..c93f940b6af9 100644 --- a/src/msg/async/ProtocolV1.cc +++ b/src/msg/async/ProtocolV1.cc @@ -422,6 +422,17 @@ bool ProtocolV1::is_queued() { return !out_q.empty() || connection->is_queued(); } +void ProtocolV1::dump(Formatter* f) { + f->open_object_section("v1"); + f->dump_string("state", get_state_name(state)); + f->dump_unsigned("connect_seq", connect_seq); + f->dump_unsigned("peer_global_seq", peer_global_seq); + if (auth_meta) { + f->dump_string("con_mode", ceph_con_mode_name(auth_meta->con_mode)); + } + f->close_section(); // v1 +} + void ProtocolV1::run_continuation(CtPtr pcontinuation) { if (pcontinuation) { CONTINUATION_RUN(*pcontinuation); diff --git a/src/msg/async/ProtocolV1.h b/src/msg/async/ProtocolV1.h index 63bc1cd09466..8b8a938ff4ac 100644 --- a/src/msg/async/ProtocolV1.h +++ b/src/msg/async/ProtocolV1.h @@ -235,6 +235,8 @@ public: virtual void write_event() override; virtual bool is_queued() override; + virtual void dump(Formatter *f) override; + // Client Protocol private: int global_seq; diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index fd1dfb5470e2..58e4f4df21df 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -766,6 +766,40 @@ bool ProtocolV2::is_queued() { return !out_queue.empty() || connection->is_queued(); } +void ProtocolV2::dump(Formatter *f) { + f->open_object_section("v2"); + f->dump_string("state", get_state_name(state)); + if (auth_meta) { + f->dump_string("con_mode", ceph_con_mode_name(auth_meta->con_mode)); + } + f->dump_bool("rev1", HAVE_MSGR2_FEATURE(peer_supported_features, REVISION_1)); + f->dump_unsigned("connect_seq", connect_seq); + f->dump_unsigned("peer_global_seq", peer_global_seq); + + f->open_object_section("crypto"); + f->dump_string( + "rx", session_stream_handlers.rx + ? session_stream_handlers.rx->cipher_name() + : "PLAIN"); + f->dump_string( + "tx", session_stream_handlers.tx + ? session_stream_handlers.tx->cipher_name() + : "PLAIN"); + f->close_section(); // crypto + + f->open_object_section("compression"); + f->dump_string( + "rx", session_compression_handlers.rx + ? session_compression_handlers.rx->compressor_name() + : "UNCOMPRESSED"); + f->dump_string( + "tx", session_compression_handlers.tx + ? session_compression_handlers.tx->compressor_name() + : "UNCOMPRESSED"); + f->close_section(); // compression + f->close_section(); // v2 +} + CtPtr ProtocolV2::read(CONTINUATION_RXBPTR_TYPE &next, rx_buffer_t &&buffer) { const auto len = buffer->length(); diff --git a/src/msg/async/ProtocolV2.h b/src/msg/async/ProtocolV2.h index 1ee258c49755..aa7006b03216 100644 --- a/src/msg/async/ProtocolV2.h +++ b/src/msg/async/ProtocolV2.h @@ -223,6 +223,8 @@ public: virtual void write_event() override; virtual bool is_queued() override; + virtual void dump(Formatter *f) override; + private: // Client Protocol CONTINUATION_DECL(ProtocolV2, start_client_banner_exchange); diff --git a/src/msg/async/compression_onwire.cc b/src/msg/async/compression_onwire.cc index 9e6d07cfd195..5f6a1e3c5663 100644 --- a/src/msg/async/compression_onwire.cc +++ b/src/msg/async/compression_onwire.cc @@ -83,4 +83,12 @@ void TxHandler::done() ldout(m_cct, 25) << __func__ << " compression ratio=" << get_ratio() << dendl; } +std::string_view RxHandler::compressor_name() const { + return m_compressor->get_type_name(); +} + +std::string_view TxHandler::compressor_name() const { + return m_compressor->get_type_name(); +} + } // namespace ceph::compression::onwire diff --git a/src/msg/async/compression_onwire.h b/src/msg/async/compression_onwire.h index d3b35a4655c1..f7ac8cb757d9 100644 --- a/src/msg/async/compression_onwire.h +++ b/src/msg/async/compression_onwire.h @@ -41,6 +41,8 @@ namespace ceph::compression::onwire { * @returns true on success, false on failure */ std::optional decompress(const ceph::bufferlist &input); + + std::string_view compressor_name() const; }; class TxHandler final : private Handler { @@ -82,6 +84,8 @@ namespace ceph::compression::onwire { return m_onwire_size; } + std::string_view compressor_name() const; + private: uint64_t m_min_size; Compressor::CompressionMode m_mode; diff --git a/src/msg/async/crypto_onwire.cc b/src/msg/async/crypto_onwire.cc index 615820b35ba3..d51922b9d02f 100644 --- a/src/msg/async/crypto_onwire.cc +++ b/src/msg/async/crypto_onwire.cc @@ -76,6 +76,10 @@ public: void authenticated_encrypt_update(const ceph::bufferlist& plaintext) override; ceph::bufferlist authenticated_encrypt_final() override; + + std::string_view cipher_name() const override { + return "AES-128-GCM"; + }; }; void AES128GCM_OnWireTxHandler::reset_tx_handler(const uint32_t* first, @@ -198,6 +202,10 @@ public: void reset_rx_handler() override; void authenticated_decrypt_update(ceph::bufferlist& bl) override; void authenticated_decrypt_update_final(ceph::bufferlist& bl) override; + + std::string_view cipher_name() const override { + return "AES-128-GCM"; + }; }; void AES128GCM_OnWireRxHandler::reset_rx_handler() diff --git a/src/msg/async/crypto_onwire.h b/src/msg/async/crypto_onwire.h index 55f7550868fb..19ee69c93e69 100644 --- a/src/msg/async/crypto_onwire.h +++ b/src/msg/async/crypto_onwire.h @@ -86,6 +86,8 @@ struct TxHandler { // Generates authentication signature and returns bufferlist crafted // basing on plaintext from preceding call to _update(). virtual ceph::bufferlist authenticated_encrypt_final() = 0; + + virtual std::string_view cipher_name() const = 0; }; class RxHandler { @@ -109,6 +111,8 @@ public: // for overall decryption sequence. // Throws on integrity/authenticity checks virtual void authenticated_decrypt_update_final(ceph::bufferlist& bl) = 0; + + virtual std::string_view cipher_name() const = 0; }; struct rxtx_t {