From b3fe2fe84a3a5b8e5fcabc7054797191f6723edf Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 9 Feb 2021 19:04:19 -0500 Subject: [PATCH] rgw: rgw_data_change can decode v1 format if gen was 0 but if gen>0, require decoders to understand the v2 format. this way, old clients can't decode entries with gen>0, so they won't be able to serve them to other zones Signed-off-by: Casey Bodley --- src/rgw/rgw_datalog.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_datalog.h b/src/rgw/rgw_datalog.h index 6a54a96f92a50..1fcf9a8edaf7e 100644 --- a/src/rgw/rgw_datalog.h +++ b/src/rgw/rgw_datalog.h @@ -53,7 +53,9 @@ struct rgw_data_change { uint64_t gen = 0; void encode(ceph::buffer::list& bl) const { - ENCODE_START(2, 2, bl); + // require decoders to recognize v2 when gen>0 + const uint8_t compat = (gen == 0) ? 1 : 2; + ENCODE_START(2, compat, bl); auto t = std::uint8_t(entity_type); encode(t, bl); encode(key, bl); @@ -69,10 +71,11 @@ struct rgw_data_change { entity_type = DataLogEntityType(t); decode(key, bl); decode(timestamp, bl); - if (struct_v < 2) + if (struct_v < 2) { gen = 0; - else + } else { decode(gen, bl); + } DECODE_FINISH(bl); } -- 2.39.5