From: Sage Weil Date: Thu, 7 Jun 2018 01:06:23 +0000 (-0500) Subject: mon/MgrMap: fix pre-addrvec compat X-Git-Tag: v14.0.1~1163^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7e321d2d482fb0dfc5323db3d8a20264864ad193;p=ceph.git mon/MgrMap: fix pre-addrvec compat This was broken by 7f787704cdcd55df18d204c5251cdd6a3cedd604. Old code does not decode an addrvec as an addr. Take the opportunity to remove the old_available_modules field. Signed-off-by: Sage Weil --- diff --git a/src/mon/MgrMap.h b/src/mon/MgrMap.h index 282aa718eb66..dd1c226c3f77 100644 --- a/src/mon/MgrMap.h +++ b/src/mon/MgrMap.h @@ -235,7 +235,30 @@ public: void encode(bufferlist& bl, uint64_t features) const { - ENCODE_START(5, 1, bl); + if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) { + ENCODE_START(5, 1, bl); + encode(epoch, bl); + encode(active_addrs.legacy_addr(), bl, features); + encode(active_gid, bl); + encode(available, bl); + encode(active_name, bl); + encode(standbys, bl); + encode(modules, bl); + + // Pre-version 4 string list of available modules + // (replaced by direct encode of ModuleInfo below) + std::set old_available_modules; + for (const auto &i : available_modules) { + old_available_modules.insert(i.name); + } + encode(old_available_modules, bl); + + encode(services, bl); + encode(available_modules, bl); + ENCODE_FINISH(bl); + return; + } + ENCODE_START(6, 6, bl); encode(epoch, bl); encode(active_addrs, bl, features); encode(active_gid, bl); @@ -243,23 +266,15 @@ public: encode(active_name, bl); encode(standbys, bl); encode(modules, bl); - - // Pre-version 4 string list of available modules - // (replaced by direct encode of ModuleInfo below) - std::set old_available_modules; - for (const auto &i : available_modules) { - old_available_modules.insert(i.name); - } - encode(old_available_modules, bl); - encode(services, bl); encode(available_modules, bl); ENCODE_FINISH(bl); + return; } void decode(bufferlist::const_iterator& p) { - DECODE_START(5, p); + DECODE_START(6, p); decode(epoch, p); decode(active_addrs, p); decode(active_gid, p); @@ -269,17 +284,19 @@ public: if (struct_v >= 2) { decode(modules, p); - // Reconstitute ModuleInfos from names - std::set module_name_list; - decode(module_name_list, p); - // Only need to unpack this field if we won't have the full - // MgrMap::ModuleInfo structures added in v4 - if (struct_v < 4) { - for (const auto &i : module_name_list) { - MgrMap::ModuleInfo info; - info.name = i; - available_modules.push_back(std::move(info)); - } + if (struct_v < 6) { + // Reconstitute ModuleInfos from names + std::set module_name_list; + decode(module_name_list, p); + // Only need to unpack this field if we won't have the full + // MgrMap::ModuleInfo structures added in v4 + if (struct_v < 4) { + for (const auto &i : module_name_list) { + MgrMap::ModuleInfo info; + info.name = i; + available_modules.push_back(std::move(info)); + } + } } } if (struct_v >= 3) {