]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgwlc: fix compat-decoding of cls_rgw_lc_get_entry_ret
authorMatt Benjamin <mbenjamin@redhat.com>
Sat, 22 Jan 2022 18:14:31 +0000 (13:14 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 28 Jan 2022 22:04:48 +0000 (17:04 -0500)
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 <jeegnchen@gmail.com>.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/cls/rgw/cls_rgw_ops.h

index c5e252e645a4785d4b2f8e9e0d3042117bf1d308..a48f9aa68c56c110b5f36f402716e9d39bfc277f 100644 (file)
@@ -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<std::string, int> 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)