From: Jason Dillaman Date: Tue, 17 Sep 2019 19:49:48 +0000 (-0400) Subject: cls/rbd: sanitize entity instance messenger version type X-Git-Tag: v15.1.0~1486^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c0c6b25d4f3edd8636fd0a270024d959b16c1dda;p=ceph.git cls/rbd: sanitize entity instance messenger version type 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 --- diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index 1ab5c8cc00ba..fba8d5c06398 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -4651,6 +4651,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 *entities) { obj_list_watch_response_t watchers; @@ -4662,7 +4669,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; } @@ -4894,6 +4904,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;