]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async: fix should_use_msgr2 behavior (including monc)
authorSage Weil <sage@redhat.com>
Sun, 27 Jan 2019 13:32:21 +0000 (07:32 -0600)
committerSage Weil <sage@redhat.com>
Sun, 27 Jan 2019 13:33:51 +0000 (07:33 -0600)
Be consistent about whether we should use v2 to connect or not, and fix
teh monclient check to use the same logic.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MonClient.cc
src/msg/Messenger.h
src/msg/async/AsyncMessenger.cc
src/msg/async/AsyncMessenger.h

index 6917ab2a1bdecac62db4feaba228b36d7ca5f025..d628e819d9f65031288c6056a965156e548d6239 100644 (file)
@@ -382,12 +382,12 @@ void MonClient::handle_monmap(MMonMap *m)
                     << " went away" << dendl;
       // can't find the mon we were talking to (above)
       _reopen_session();
-    } else if (monmap.get_addrs(new_rank) != con_addrs) {
-      // FIXME: we might make this a more sophisticated check later if we do
-      // multiprotocol IPV4/IPV6 and have a strict preference
-      ldout(cct,10) << " mon." << new_rank << " has addrs "
-                   << monmap.get_addrs(new_rank) << " but i'm connected to "
-                   << con_addrs << dendl;
+    } else if (messenger->should_use_msgr2() &&
+              monmap.get_addrs(new_rank).has_msgr2() &&
+              !con_addrs.has_msgr2()) {
+      ldout(cct,1) << " mon." << new_rank << " has (v2) addrs "
+                  << monmap.get_addrs(new_rank) << " but i'm connected to "
+                  << con_addrs << ", reconnecting" << dendl;
       _reopen_session();
     }
   }
index 4c41dfce95ed899919741687c9ff5513d6a7da96..fd23813418ad0cfed92d250d99d73bed949115df 100644 (file)
@@ -390,6 +390,11 @@ public:
 
   virtual int bindv(const entity_addrvec_t& addrs);
 
+
+  virtual bool should_use_msgr2() {
+    return false;
+  }
+
   /**
    * @} // Configuration
    */
index 908052f11c41cdf88c8b85d7439074854736ce74..dba88e886f1b473d62d32045d7577a282a2df4c6 100644 (file)
@@ -607,17 +607,22 @@ ConnectionRef AsyncMessenger::get_loopback_connection()
   return local_connection;
 }
 
+bool AsyncMessenger::should_use_msgr2()
+{
+  // if we are bound to v1 only, and we are connecting to a v2 peer,
+  // we cannot use the peer's v2 address. otherwise the connection
+  // is assymetrical, because they would have to use v1 to connect
+  // to us, and we would use v2, and connection race detection etc
+  // would totally break down (among other things).  or, the other
+  // end will be confused that we advertise ourselve with a v1
+  // address only (that we bound to) but connected with protocol v2.
+  return !did_bind || get_myaddrs().has_msgr2();
+}
+
 entity_addrvec_t AsyncMessenger::_filter_addrs(int type,
                                               const entity_addrvec_t& addrs)
 {
-  if (did_bind &&
-      !get_myaddrs().has_msgr2() &&
-      get_mytype() == type) {
-    // if we are bound to v1 only, and we are connecting to a peer, we cannot
-    // use the peer's v2 address (yet). otherwise the connection is assymetrical,
-    // because they would have to use v1 to connect to us, and we would use v2,
-    // and connection race detection etc would totally break down (among other
-    // things).
+  if (!should_use_msgr2()) {
     ldout(cct, 10) << __func__ << " " << addrs << " type " << type
                   << " limiting to v1 ()" << dendl;
     entity_addrvec_t r;
index 79242be035fddebde8db25ae5868074e23163c49..f13e30c0b962da252a212f34dbe138231f5151ad 100644 (file)
@@ -121,6 +121,8 @@ public:
 
   int bindv(const entity_addrvec_t& bind_addrs) override;
 
+  bool should_use_msgr2() override;
+
   /** @} Configuration functions */
 
   /**