From 71f1e1604b088a68a0d7ed0d1992d92bc2a12db8 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 24 Jan 2019 07:33:29 -0600 Subject: [PATCH] msg/async/ProtocolV2: fault if we connect to the wrong peer Someone else may have bound to the same port. If they identify as someone else, fault and back off. Signed-off-by: Sage Weil --- src/msg/async/ProtocolV2.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index 7084ca8ea84..892be9e9401 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -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 && -- 2.47.3