]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rbd: sanitize entity instance messenger version type 30822/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 17 Sep 2019 19:49:48 +0000 (15:49 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 9 Oct 2019 19:49:03 +0000 (15:49 -0400)
The entity_addr_t::type field does not uniquely identify the connection
and might switch back and forth between LEGACY, V2, and ALL depending on
the client, the OSD, and the OSD map feature bits. Therefore, always
fix the entity address type to ANY prior to any comparisons.

Fixes: https://tracker.ceph.com/issues/41833
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit c0c6b25d4f3edd8636fd0a270024d959b16c1dda)

src/cls/rbd/cls_rbd.cc

index 3a810e2e91452bbbba88bd3411538f81fdac75de..22a261baac270dc978c9bb94454481d3ac32b627 100644 (file)
@@ -4590,6 +4590,13 @@ int uuid_get(cls_method_context_t hctx, std::string *mirror_uuid) {
   return 0;
 }
 
+void sanitize_entity_inst(entity_inst_t* entity_inst) {
+  // make all addrs of type ANY because the type isn't what uniquely
+  // identifies them and clients and on-disk formats can be encoded
+  // with different backwards compatibility settings.
+  entity_inst->addr.set_type(entity_addr_t::TYPE_ANY);
+}
+
 int list_watchers(cls_method_context_t hctx,
                   std::set<entity_inst_t> *entities) {
   obj_list_watch_response_t watchers;
@@ -4601,7 +4608,10 @@ int list_watchers(cls_method_context_t hctx,
 
   entities->clear();
   for (auto &w : watchers.entries) {
-    entities->emplace(w.name, w.addr);
+    entity_inst_t entity_inst{w.name, w.addr};
+    sanitize_entity_inst(&entity_inst);
+
+    entities->insert(entity_inst);
   }
   return 0;
 }
@@ -4833,6 +4843,7 @@ int image_status_set(cls_method_context_t hctx, const string &global_image_id,
   ondisk_status.last_update = ceph_clock_now();
 
   int r = cls_get_request_origin(hctx, &ondisk_status.origin);
+  sanitize_entity_inst(&ondisk_status.origin);
   ceph_assert(r == 0);
 
   bufferlist bl;