]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/ProtocolV2: fault if we connect to the wrong peer
authorSage Weil <sage@redhat.com>
Thu, 24 Jan 2019 13:33:29 +0000 (07:33 -0600)
committerRicardo Dias <rdias@suse.com>
Thu, 24 Jan 2019 16:50:28 +0000 (16:50 +0000)
Someone else may have bound to the same port.  If they identify as someone
else, fault and back off.

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

index 7084ca8ea8404f5a2ede423bee715fa2181f1333..892be9e94018fb1997434b412305326577c1bd87 100644 (file)
@@ -2322,6 +2322,13 @@ CtPtr ProtocolV2::handle_server_ident(char *payload, uint32_t length) {
                 << " flags=" << server_ident.flags() << " cookie=" << std::dec
                 << server_ident.cookie() << dendl;
 
+  // is this who we intended to talk to?
+  if (*connection->peer_addrs != server_ident.addrs()) {
+    ldout(cct,1) << __func__ << " peer identifies as " << server_ident.addrs()
+                << " not " << *connection->peer_addrs << dendl;
+    return _fault();
+  }
+
   connection->lock.unlock();
   messenger->learned_addr(server_ident.peer_addr());
   if (cct->_conf->ms_inject_internal_delays &&