]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
basic cap caching done
authoranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 2 Mar 2007 21:21:54 +0000 (21:21 +0000)
committeranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 2 Mar 2007 21:21:54 +0000 (21:21 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1162 29311d96-e01e-0410-9327-a35deaab8ce9

branches/aleung/security1/ceph/osd/OSD.cc
branches/aleung/security1/ceph/osd/OSD.h

index faa298cfb1ab1b3a26422b9569319e67344a2a68..75ac2049b24e4440cad48aa5870959f9e231003e 100644 (file)
@@ -369,6 +369,25 @@ int OSD::read_superblock()
 }
 
 
+// security operations
+
+// assumes the request and cap contents has already been checked
+bool OSD::verify_cap(ExtCap *cap) {
+
+  // have i already verified this cap?
+  if (!cap_cache->prev_verified(cap->get_id())) {
+    cout << "Verifying an unseen capability" << endl;
+    // actually verify
+    if (cap->verif_extcap(monmap->get_key())) {
+      // cache the verification
+      cap_cache->insert(cap);
+    }
+    else
+      return false;
+  }
+  return true;
+}
+
 // object locks
 
 PG *OSD::lock_pg(pg_t pgid) 
@@ -2863,8 +2882,7 @@ void OSD::op_read(MOSDOp *op)//, PG *pg)
   if (op->get_source().is_client()) {
     ExtCap *op_capability = op->get_capability();
     assert(op_capability);
-    cout << "OSD recieved a read capability" << endl;
-    if (op_capability->verif_extcap(monmap->get_key()))
+    if (verify_cap(op_capability))
       cout << "OSD successfully verified capability" << endl;
     else
       cout << "OSD failed to verify capability" << endl;
@@ -3219,7 +3237,9 @@ void OSD::op_modify(MOSDOp *op, PG *pg)
       && op->get_source().is_client()) {
     ExtCap *op_capability = op->get_capability();
     assert(op_capability);
-    if (op_capability->verif_extcap(monmap->get_key()))
+
+    // have i already verified this cap?
+    if (verify_cap(op_capability))
       cout << "OSD successfully verified a write capability" << endl;
     else
       cout << "OSD failed to verify a write capability" << endl;
index a682f6d6d15df67741fdf81afb599f4995120054..678e9767e11908ec6daa61f6161b920d5fb2d8a5 100644 (file)
@@ -261,6 +261,9 @@ public:
   int init();
   int shutdown();
 
+  // security ops
+  bool verify_cap(ExtCap *cap);
+
   // messages
   virtual void dispatch(Message *m);
   virtual void ms_handle_failure(Message *m, const entity_inst_t& inst);