]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: ignore election messages from outside monmap
authorSage Weil <sage@inktank.com>
Thu, 17 May 2012 21:46:46 +0000 (14:46 -0700)
committerSage Weil <sage@inktank.com>
Fri, 18 May 2012 23:23:57 +0000 (16:23 -0700)
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 <sage@inktank.com>
src/mon/Monitor.cc

index ca7facf1199429f29c4ba60749419a497354744b..d8134d07eb0d812f24b5a7e51e89d068ace1e004 100644 (file)
@@ -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: