]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/ProtocolV2: always send non-empty addrvec for self
authorSage Weil <sage@redhat.com>
Fri, 25 Jan 2019 20:14:55 +0000 (14:14 -0600)
committerSage Weil <sage@redhat.com>
Fri, 25 Jan 2019 20:17:34 +0000 (14:17 -0600)
If we don't know our address yet, send the peer a 0.0.0.0 or :: address with an empty
port and a populated nonce.  That way the peer can infer our final addr the same way
we do from learned_addr.

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

index 666187a720deebaaf85d466fbe03e1dd6c77429a..79242be035fddebde8db25ae5868074e23163c49 100644 (file)
@@ -357,6 +357,10 @@ public:
     return stack;
   }
 
+  uint64_t get_nonce() const {
+    return nonce;
+  }
+
   /**
    * Increment the global sequence for this AsyncMessenger and return it.
    * This is for the connect protocol, although it doesn't hurt if somebody
index bff2a61882e8565284962ddb633c8b7396439b0f..e87b202f2a6dbd353ce49b9114d19f2127f53562 100644 (file)
@@ -2197,13 +2197,24 @@ CtPtr ProtocolV2::send_client_ident() {
     flags |= CEPH_MSG_CONNECT_LOSSY;
   }
 
-  ClientIdentFrame client_ident(this, messenger->get_myaddrs(),
+  entity_addrvec_t ma = messenger->get_myaddrs();
+  if (ma.empty()) {
+    entity_addr_t a;
+    if (connection->target_addr.is_ipv6()) {
+      a.parse("[::]:0");
+    } else {
+      a.parse("0.0.0.0:0");
+    }
+    a.set_nonce(messenger->get_nonce());
+    ma.v.push_back(a);
+  }
+  ClientIdentFrame client_ident(this, ma,
                                 messenger->get_myname().num(), global_seq,
                                 connection->policy.features_supported,
                                 connection->policy.features_required, flags);
 
   ldout(cct, 5) << __func__ << " sending identification: "
-                << "addrs=" << messenger->get_myaddrs()
+                << "addrs=" << ma
                 << " gid=" << messenger->get_myname().num()
                 << " global_seq=" << global_seq
                 << " features_supported=" << std::hex
@@ -2554,7 +2565,7 @@ CtPtr ProtocolV2::handle_client_ident(char *payload, uint32_t length) {
   connection->target_addr.set_type(entity_addr_t::TYPE_MSGR2);
 
   if (client_ident.addrs().empty()) {
-    connection->set_peer_addr(connection->target_addr);
+    return _fault();  // a v2 peer should never do this
   } else {
     for (auto &peer_addr : client_ident.addrs().v) {
       if (peer_addr.is_blank_ip()) {