]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
./ceph osd setcrushmap: validate crushmap
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 25 Oct 2010 19:24:13 +0000 (12:24 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 25 Oct 2010 19:31:49 +0000 (12:31 -0700)
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/mon/OSDMonitor.cc

index 18c0b1cad40feefebae7f661b4b81f04d919870d..7a3333685bbfd794aa79af50d6ec9c4224ca11e1 100644 (file)
@@ -1256,7 +1256,18 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
   if (m->cmd.size() > 1) {
     if (m->cmd[1] == "setcrushmap") {
       dout(10) << "prepare_command setting new crush map" << dendl;
-      pending_inc.crush = m->get_data();
+      bufferlist data(m->get_data());
+      try {
+       bufferlist::iterator bl(data.begin());
+       CrushWrapper crush;
+       crush.decode(bl);
+      }
+      catch (const std::exception &e) {
+       err = -EINVAL;
+       ss << "Failed to parse crushmap: " << e.what();
+       goto out;
+      }
+      pending_inc.crush = data;
       string rs = "set crush map";
       paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
       return true;