From: Ilya Dryomov Date: Tue, 21 Apr 2020 08:22:25 +0000 (+0200) Subject: msg/async/ProtocolV2: add msgr2.1 feature bit X-Git-Tag: v17.0.0~2033^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=afc288608c71530d0feff5db14c84587da29e134;p=ceph.git msg/async/ProtocolV2: add msgr2.1 feature bit Use msgr2.1 if the peer supports it and fall back to msgr2.0 otherwise. Signed-off-by: Ilya Dryomov --- diff --git a/src/include/msgr.h b/src/include/msgr.h index bda8108082475..f7b2a07816ba4 100644 --- a/src/include/msgr.h +++ b/src/include/msgr.h @@ -52,15 +52,16 @@ #define DEFINE_MSGR2_FEATURE(bit, incarnation, name) \ const static uint64_t CEPH_MSGR2_FEATURE_##name = (1ULL << bit); \ const static uint64_t CEPH_MSGR2_FEATUREMASK_##name = \ - (1ULL << bit | CEPH_FEATURE_INCARNATION_##incarnation); + (1ULL << bit | CEPH_MSGR2_INCARNATION_##incarnation); #define HAVE_MSGR2_FEATURE(x, name) \ (((x) & (CEPH_MSGR2_FEATUREMASK_##name)) == (CEPH_MSGR2_FEATUREMASK_##name)) +DEFINE_MSGR2_FEATURE( 0, 1, REVISION_1) // msgr2.1 -#define CEPH_MSGR2_SUPPORTED_FEATURES (0ull) +#define CEPH_MSGR2_SUPPORTED_FEATURES (CEPH_MSGR2_FEATURE_REVISION_1) -#define CEPH_MSGR2_REQUIRED_FEATURES (CEPH_MSGR2_SUPPORTED_FEATURES) +#define CEPH_MSGR2_REQUIRED_FEATURES (0ull) /* diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index e2a5ac6ea3e3c..409d7f1e79531 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -24,6 +24,8 @@ std::ostream &ProtocolV2::_conn_prefix(std::ostream *_dout) { << " :" << connection->port << " s=" << get_state_name(state) << " pgs=" << peer_global_seq << " cs=" << connect_seq << " l=" << connection->policy.lossy + << " rev1=" << HAVE_MSGR2_FEATURE(peer_supported_features, + REVISION_1) << " rx=" << session_stream_handlers.rx.get() << " tx=" << session_stream_handlers.tx.get() << ")."; @@ -935,6 +937,11 @@ CtPtr ProtocolV2::_handle_peer_banner_payload(rx_buffer_t &&buffer, int r) { this->connection_features = msgr2_required; } + // if the peer supports msgr2.1, switch to it + bool is_rev1 = HAVE_MSGR2_FEATURE(peer_supported_features, REVISION_1); + tx_frame_asm.set_is_rev1(is_rev1); + rx_frame_asm.set_is_rev1(is_rev1); + if (state == BANNER_CONNECTING) { state = HELLO_CONNECTING; } @@ -1806,8 +1813,9 @@ CtPtr ProtocolV2::handle_auth_done(ceph::bufferlist &payload) return _fault(); } auth_meta->con_mode = auth_done.con_mode(); + bool is_rev1 = HAVE_MSGR2_FEATURE(peer_supported_features, REVISION_1); session_stream_handlers = ceph::crypto::onwire::rxtx_t::create_handler_pair( - cct, *auth_meta, /*new_nonce_format=*/false, /*crossed=*/false); + cct, *auth_meta, /*new_nonce_format=*/is_rev1, /*crossed=*/false); state = AUTH_CONNECTING_SIGN; @@ -2186,8 +2194,9 @@ CtPtr ProtocolV2::finish_auth() ceph_assert(auth_meta); // TODO: having a possibility to check whether we're server or client could // allow reusing finish_auth(). + bool is_rev1 = HAVE_MSGR2_FEATURE(peer_supported_features, REVISION_1); session_stream_handlers = ceph::crypto::onwire::rxtx_t::create_handler_pair( - cct, *auth_meta, /*new_nonce_format=*/false, /*crossed=*/true); + cct, *auth_meta, /*new_nonce_format=*/is_rev1, /*crossed=*/true); const auto sig = auth_meta->session_key.empty() ? sha256_digest_t() : auth_meta->session_key.hmac_sha256(cct, pre_auth.rxbuf); diff --git a/src/msg/async/frames_v2.h b/src/msg/async/frames_v2.h index 0003b273096ea..709bbbdd7363f 100644 --- a/src/msg/async/frames_v2.h +++ b/src/msg/async/frames_v2.h @@ -179,6 +179,11 @@ public: FrameAssembler(const ceph::crypto::onwire::rxtx_t* crypto, bool is_rev1) : m_crypto(crypto), m_is_rev1(is_rev1) {} + void set_is_rev1(bool is_rev1) { + m_descs.clear(); + m_is_rev1 = is_rev1; + } + size_t get_num_segments() const { ceph_assert(!m_descs.empty()); return m_descs.size();