From cba3ca7b8d10892b970e185211ae127ff0b7c0d9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 17 May 2012 14:46:46 -0700 Subject: [PATCH] mon: ignore election messages from outside monmap These shouldn't(tm) happen with new code, but with old code they do. And if we get them, elector can try to monmap->get_inst() on them and crash. Throw them out here; they're nonsense from our perspective anyway if the peer isn't part of our monmap. Signed-off-by: Sage Weil --- src/mon/Monitor.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index ca7facf119942..d8134d07eb0d8 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -1667,10 +1667,17 @@ bool Monitor::_ms_dispatch(Message *m) dout(0) << "MMonElection received from entity without enough caps!" << s->caps << dendl; } - if (!is_probing() && !is_slurping()) - elector.dispatch(m); - else + if (!is_probing() && !is_slurping()) { + if (monmap->contains(m->get_source_addr())) { + elector.dispatch(m); + } else { + dout(1) << "discarding election message: " << m->get_source_addr() << " not in my monmap " + << *monmap << dendl; + m->put(); + } + } else { m->put(); + } break; case MSG_FORWARD: -- 2.39.5