From a177503673d99ebbbff7d82f0b84156024215894 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Sat, 22 Jan 2022 13:14:31 -0500 Subject: [PATCH] rgwlc: fix compat-decoding of cls_rgw_lc_get_entry_ret Fix compat-decode of cls_rgw_lc_get_entry_ret, which had changed earlier in 394750597. While not initially a problem, the more recent change to allow radosgw-admin lc process to operate on a single bucket created a way to decode an un-upgraded structure. Fixes: https://tracker.ceph.com/issues/53927 Reported by Jeegn Chen . Signed-off-by: Matt Benjamin --- src/cls/rgw/cls_rgw_ops.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/cls/rgw/cls_rgw_ops.h b/src/cls/rgw/cls_rgw_ops.h index c5e252e645a47..a48f9aa68c56c 100644 --- a/src/cls/rgw/cls_rgw_ops.h +++ b/src/cls/rgw/cls_rgw_ops.h @@ -1092,17 +1092,32 @@ struct cls_rgw_lc_get_entry_ret { : entry(std::move(_entry)) {} void encode(ceph::buffer::list& bl) const { - ENCODE_START(1, 1, bl); + ENCODE_START(2, 2, bl); encode(entry, bl); ENCODE_FINISH(bl); } void decode(ceph::buffer::list::const_iterator& bl) { - DECODE_START(1, bl); - decode(entry, bl); + DECODE_START(2, bl); + if (struct_v < 2) { + /* there was an unmarked change in the encoding during v1, so + * if the sender version is v1, try decoding both ways (sorry) */ + ceph::buffer::list::const_iterator save_bl = bl; + try { + decode(entry, bl); + } catch (ceph::buffer::error& e) { + std::pair oe; + bl = save_bl; + decode(oe, bl); + entry.bucket = oe.first; + entry.start_time = 0; + entry.status = oe.second; + } + } else { + decode(entry, bl); + } DECODE_FINISH(bl); } - }; WRITE_CLASS_ENCODER(cls_rgw_lc_get_entry_ret) -- 2.39.5