From 64eeb79051d26b4b95e42b171dd4efcd59716181 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 10 Apr 2021 17:35:38 +0300 Subject: [PATCH] Prevent 0.6.x OSDs from talking to 0.5.x The new protocol is almost compatible - it has bitmaps, but also it has a "bitmap_length" field. It's not hard to make 0.5-0.6 OSDs and clients compatible, but for now I just assume nobody needs it. If I'm wrong and anybody requests to upgrade their production 0.5.x system to 0.6.x I'll fix it. --- src/messenger.cpp | 9 +++++++++ src/osd_ops.h | 1 + src/osd_secondary.cpp | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/messenger.cpp b/src/messenger.cpp index 96da14a5..572bcf98 100644 --- a/src/messenger.cpp +++ b/src/messenger.cpp @@ -349,6 +349,15 @@ void osd_messenger_t::check_peer_config(osd_client_t *cl) err = true; printf("Connected to OSD %lu instead of OSD %lu, peer state is outdated, disconnecting peer\n", config["osd_num"].uint64_value(), cl->osd_num); } + else if (config["protocol_version"].uint64_value() != OSD_PROTOCOL_VERSION) + { + err = true; + printf( + "OSD %lu protocol version is %lu, but only version %u is supported.\n" + " If you need to upgrade from 0.5.x please request it via the issue tracker.\n", + cl->osd_num, config["protocol_version"].uint64_value(), OSD_PROTOCOL_VERSION + ); + } } if (err) { diff --git a/src/osd_ops.h b/src/osd_ops.h index ee80d742..76b3ad3a 100644 --- a/src/osd_ops.h +++ b/src/osd_ops.h @@ -35,6 +35,7 @@ #define MEM_ALIGNMENT 512 #endif #define OSD_RW_MAX 64*1024*1024 +#define OSD_PROTOCOL_VERSION 1 // common request and reply headers struct __attribute__((__packed__)) osd_op_header_t diff --git a/src/osd_secondary.cpp b/src/osd_secondary.cpp index 5f4fb46f..bb11269a 100644 --- a/src/osd_secondary.cpp +++ b/src/osd_secondary.cpp @@ -145,7 +145,9 @@ void osd_t::exec_secondary(osd_op_t *cur_op) void osd_t::exec_show_config(osd_op_t *cur_op) { // FIXME: Send the real config, not its source - std::string cfg_str = json11::Json(config).dump(); + auto cfg_copy = config; + cfg_copy["protocol_version"] = std::to_string(OSD_PROTOCOL_VERSION); + std::string cfg_str = json11::Json(cfg_copy).dump(); cur_op->buf = malloc_or_die(cfg_str.size()+1); memcpy(cur_op->buf, cfg_str.c_str(), cfg_str.size()+1); cur_op->iov.push_back(cur_op->buf, cfg_str.size()+1);