From 675e4c41bcfd66f6e3061d9cc557555cef971719 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 7 Feb 2012 14:18:52 -0800 Subject: [PATCH] mon: drop election messages with bad rank The bad message came from old code pre-bfbeae68c045de76ede86ca4f72d2a760a19c84b. Fixes: #1909 Signed-off-by: Sage Weil --- src/mon/Elector.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc index 1e2abee8ad502..a7bac193ca491 100644 --- a/src/mon/Elector.cc +++ b/src/mon/Elector.cc @@ -223,7 +223,7 @@ void Elector::handle_ack(MMonElection *m) { dout(5) << "handle_ack from " << m->get_source() << dendl; int from = m->get_source().num(); - + assert(m->epoch % 2 == 1); // election if (m->epoch > epoch) { dout(5) << "woah, that's a newer epoch, i must have rebooted. bumping and re-starting!" << dendl; @@ -293,6 +293,12 @@ void Elector::dispatch(Message *m) m->put(); return; } + if (m->get_source().num() >= mon->monmap->size()) { + dout(5) << " ignoring bogus election message with bad mon rank " << m->get_source() << dendl; + m->put(); + return; + } + MMonElection *em = (MMonElection*)m; // assume an old message encoding would have matched -- 2.39.5