]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/ProtocolV2: add msgr2.1 feature bit
authorIlya Dryomov <idryomov@gmail.com>
Tue, 21 Apr 2020 08:22:25 +0000 (10:22 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 17 Jun 2020 19:56:50 +0000 (21:56 +0200)
Use msgr2.1 if the peer supports it and fall back to msgr2.0
otherwise.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/include/msgr.h
src/msg/async/ProtocolV2.cc
src/msg/async/frames_v2.h

index bda8108082475f8a13b67920cc41658acc204060..f7b2a07816ba4843bc9e692f860782bc41d25981 100644 (file)
 #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)
 
 
 /*
index e2a5ac6ea3e3cbddf8797d965efcae0c42c96dcc..409d7f1e79531d9e38ec61323469f83f6e8ac786 100644 (file)
@@ -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);
index 0003b273096ea2a441ff3f647d9ab54ae2244130..709bbbdd7363f7ba6431f54f86e54b57d7d61a9c 100644 (file)
@@ -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();