From d0d61b488a5eaf84bb115954272fb61735d505d2 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Wed, 2 Oct 2013 01:54:09 +0100 Subject: [PATCH] mon: Monitor: drop client msg if no session exists and msg is not MAuth If we are not a monitor and we don't have a session yet, we must first authenticate with the cluster. Therefore, the first message to the monitor must be an MAuth. If not, we assume it's a stray message and just drop it. Signed-off-by: Joao Eduardo Luis --- src/mon/Monitor.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 54ea2f41fce2e..cb19dd4b25cb1 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2578,10 +2578,23 @@ bool Monitor::_ms_dispatch(Message *m) s = NULL; } if (!s) { + // if the sender is not a monitor, make sure their first message for a + // session is an MAuth. If it is not, assume it's a stray message, + // and considering that we are creating a new session it is safe to + // assume that the sender hasn't authenticated yet, so we have no way + // of assessing whether we should handle it or not. + if (!src_is_mon && m->get_type() != CEPH_MSG_AUTH) { + dout(1) << __func__ << " dropping stray message " << *m + << " from " << m->get_source_inst() << dendl; + m->put(); + return false; + } + if (!exited_quorum.is_zero() && !src_is_mon) { waitlist_or_zap_client(m); return true; } + dout(10) << "do not have session, making new one" << dendl; s = session_map.new_session(m->get_source_inst(), m->get_connection().get()); m->get_connection()->set_priv(s->get()); -- 2.39.5