]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/ProtocolV2: fix handling for v2 client connection with v1 addr
authorSage Weil <sage@redhat.com>
Sat, 26 Jan 2019 07:28:13 +0000 (01:28 -0600)
committerSage Weil <sage@redhat.com>
Sat, 26 Jan 2019 17:44:55 +0000 (11:44 -0600)
Switch it to be v2.  Reject the case where the client sends and addrvec, though;
that should only happen for clients that did_bind, and they should only connect to
v2 if they have a v2 bound addr.

Signed-off-by: Sage Weil <sage@redhat.com>
src/msg/async/ProtocolV2.cc

index b25132fb3d2e44cc0e06d206e208afbadfc28d3f..a7381ff325cf71c30700003a35e1c1401d2ebf19 100644 (file)
@@ -2568,12 +2568,25 @@ CtPtr ProtocolV2::handle_client_ident(char *payload, uint32_t length) {
                 << client_ident.supported_features()
                 << " features_required=" << client_ident.required_features()
                 << " flags=" << client_ident.flags() << std::dec << dendl;
-  if (client_ident.addrs().empty() ||
-      !client_ident.addrs().has_msgr2()) {
+  if (client_ident.addrs().empty()) {
     return _fault();  // a v2 peer should never do this
   }
-  connection->set_peer_addrs(client_ident.addrs());
-  connection->target_addr = client_ident.addrs().msgr2_addr();
+  entity_addr_t peer_addr = client_ident.addrs().msgr2_addr();
+  if (peer_addr.type == entity_addr_t::TYPE_NONE) {
+    // no v2 addr!  they must be a client
+    if (client_ident.addrs().v.size() > 1) {
+      lderr(cct) << __func__ << " rejecting addrvec with >1 addr but no msgr2: " << client_ident.addrs() << dendl;
+      return _fault();
+    }
+    peer_addr = client_ident.addrs().legacy_addr();
+    peer_addr.set_type(entity_addr_t::TYPE_MSGR2);
+    entity_addrvec_t addrs;
+    addrs.v.push_back(peer_addr);
+    connection->set_peer_addrs(addrs);
+  } else {
+    connection->set_peer_addrs(client_ident.addrs());
+  }
+  connection->target_addr = peer_addr;
 
   peer_name = entity_name_t(connection->get_peer_type(), client_ident.gid());