summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <joao.luis@inktank.com>2013-10-02 01:54:09 +0100
committerJoao Eduardo Luis <joao.luis@inktank.com>2013-10-03 19:29:45 +0100
commitd0d61b488a5eaf84bb115954272fb61735d505d2 (patch)
tree052a2e01a546d9ae3ccf6582a2395b4214be0c5a
parented1a54ecd3be6fed3410b50f318086967d10ceda (diff)
downloadceph-d0d61b488a5eaf84bb115954272fb61735d505d2.tar.gz
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 <joao.luis@inktank.com>
-rw-r--r--src/mon/Monitor.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index 54ea2f41fce..cb19dd4b25c 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());