From edebb341c20b48f3a2e0eeea65765b1350f80bd0 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 20 Mar 2013 14:30:29 -0700 Subject: [PATCH] OSDMonitor: factor out check_source helper Signed-off-by: Samuel Just --- src/mon/OSDMonitor.cc | 32 ++++++++++++++++++++------------ src/mon/OSDMonitor.h | 2 ++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 8c4d1a43c77..952b3721c2b 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -625,25 +625,33 @@ bool OSDMonitor::should_propose(double& delay) // failure -- +bool OSDMonitor::check_source(PaxosServiceMessage *m, uuid_d fsid) { + // check permissions + MonSession *session = m->get_session(); + if (!session) + return true; + if (!session->caps.check_privileges(PAXOS_OSDMAP, MON_CAP_X)) { + dout(0) << "got osdmap change request from entity with insufficient caps " + << session->caps << dendl; + return true; + } + if (fsid != mon->monmap->fsid) { + dout(0) << "check_source: on fsid " << fsid + << " != " << mon->monmap->fsid << dendl; + return true; + } + return false; +} + + bool OSDMonitor::preprocess_failure(MOSDFailure *m) { // who is target_osd int badboy = m->get_target().name.num(); // check permissions - MonSession *session = m->get_session(); - if (!session) + if (check_source(m, m->fsid)) goto didit; - if (!session->caps.check_privileges(PAXOS_OSDMAP, MON_CAP_X)) { - dout(0) << "got MOSDFailure from entity with insufficient caps " - << session->caps << dendl; - goto didit; - } - - if (m->fsid != mon->monmap->fsid) { - dout(0) << "preprocess_failure on fsid " << m->fsid << " != " << mon->monmap->fsid << dendl; - goto didit; - } // first, verify the reporting host is valid if (m->get_orig_source().is_osd()) { diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 42d241ec2b1..4dd6feecc1d 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -171,6 +171,8 @@ private: void remove_redundant_pg_temp(); void remove_down_pg_temp(); int reweight_by_utilization(int oload, std::string& out_str); + + bool check_source(PaxosServiceMessage *m, uuid_d fsid); bool preprocess_failure(class MOSDFailure *m); bool prepare_failure(class MOSDFailure *m);