]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
auth/cephx/CephxKeyServer: un-inline methods to reduce header dependencies 65541/head
authorMax Kellermann <max.kellermann@ionos.com>
Tue, 19 Aug 2025 11:59:00 +0000 (13:59 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Mon, 9 Mar 2026 20:29:41 +0000 (21:29 +0100)
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/auth/cephx/CephxKeyServer.cc
src/auth/cephx/CephxKeyServer.h

index d34754831ba62238be281753240d7f5e04aaa14b..e7cda2f40503f5a270b964e6aa80f087590ec0bd 100644 (file)
  * 
  */
 
-#include "common/config.h"
 #include "CephxKeyServer.h"
+#include "common/ceph_json.h"
 #include "common/Clock.h" // for ceph_clock_now()
+#include "common/config.h"
 #include "common/dout.h"
+#include "common/Formatter.h"
+
 #include <sstream>
 
 #define dout_subsys ceph_subsys_auth
@@ -31,6 +34,50 @@ using ceph::bufferptr;
 using ceph::bufferlist;
 using ceph::Formatter;
 
+void KeyServerData::encode(ceph::buffer::list& bl) const {
+  __u8 struct_v = 1;
+  using ceph::encode;
+  encode(struct_v, bl);
+  encode(version, bl);
+  encode(rotating_ver, bl);
+  encode(secrets, bl);
+  encode(rotating_secrets, bl);
+}
+
+void KeyServerData::decode(ceph::buffer::list::const_iterator& bl) {
+  using ceph::decode;
+  __u8 struct_v;
+  decode(struct_v, bl);
+  decode(version, bl);
+  decode(rotating_ver, bl);
+  decode(secrets, bl);
+  decode(rotating_secrets, bl);
+}
+
+void KeyServerData::encode_rotating(ceph::buffer::list& bl) const {
+  using ceph::encode;
+  __u8 struct_v = 1;
+  encode(struct_v, bl);
+  encode(rotating_ver, bl);
+  encode(rotating_secrets, bl);
+}
+
+void KeyServerData::decode_rotating(ceph::buffer::list& rotating_bl) {
+  using ceph::decode;
+  auto iter = rotating_bl.cbegin();
+  __u8 struct_v;
+  decode(struct_v, iter);
+  decode(rotating_ver, iter);
+  decode(rotating_secrets, iter);
+}
+
+void KeyServerData::dump(ceph::Formatter *f) const {
+  f->dump_unsigned("version", version);
+  f->dump_unsigned("rotating_version", rotating_ver);
+  encode_json("secrets", secrets, f);
+  encode_json("rotating_secrets", rotating_secrets, f);
+}
+
 bool KeyServerData::get_service_secret(CephContext *cct, uint32_t service_id,
                                       CryptoKey& secret, uint64_t& secret_id,
                                       double& ttl) const
@@ -135,6 +182,41 @@ bool KeyServerData::get_caps(CephContext *cct, const EntityName& name,
   return extra_secrets->get_caps(name, type, caps_info);
 }
 
+void KeyServerData::Incremental::encode(ceph::buffer::list& bl) const {
+  using ceph::encode;
+  __u8 struct_v = 1;
+  encode(struct_v, bl);
+  __u32 _op = (__u32)op;
+  encode(_op, bl);
+  if (op == AUTH_INC_SET_ROTATING) {
+    encode(rotating_bl, bl);
+  } else {
+    encode(name, bl);
+    encode(auth, bl);
+  }
+}
+
+void KeyServerData::Incremental::decode(ceph::buffer::list::const_iterator& bl) {
+  using ceph::decode;
+  __u8 struct_v;
+  decode(struct_v, bl);
+  __u32 _op;
+  decode(_op, bl);
+  op = (IncrementalOp)_op;
+  ceph_assert(op >= AUTH_INC_NOP && op <= AUTH_INC_SET_ROTATING);
+  if (op == AUTH_INC_SET_ROTATING) {
+    decode(rotating_bl, bl);
+  } else {
+    decode(name, bl);
+    decode(auth, bl);
+  }
+}
+
+void KeyServerData::Incremental::dump(ceph::Formatter *f) const {
+  f->dump_unsigned("op", op);
+  f->dump_object("name", name);
+  f->dump_object("auth", auth);
+}
 
 #undef dout_prefix
 #define dout_prefix *_dout << "cephx keyserver: "
@@ -301,6 +383,17 @@ bool KeyServer::generate_secret(EntityName& name, CryptoKey& secret)
   return true;
 }
 
+void KeyServer::encode(ceph::buffer::list& bl) const {
+  using ceph::encode;
+  encode(data, bl);
+}
+
+void KeyServer::decode(ceph::buffer::list::const_iterator& bl) {
+  std::scoped_lock l{lock};
+  using ceph::decode;
+  decode(data, bl);
+}
+
 bool KeyServer::contains(const EntityName& name) const
 {
   std::scoped_lock l{lock};
index 41f4699fb1ac1d4a91094127ec7e0aac2038dd44..aeefcd287e83c6048d9478e9e317b918f6c357ef 100644 (file)
 
 #include "auth/KeyRing.h"
 #include "CephxProtocol.h"
-#include "common/ceph_json.h"
 #include "common/ceph_mutex.h"
-#include "common/Formatter.h"
 #include "include/common_fwd.h"
 #include "include/encoding.h"
 #include "include/types.h" // for version_t
 
+namespace ceph { class Formatter; }
+
 struct KeyServerData {
   version_t version{0};
 
@@ -47,46 +47,12 @@ struct KeyServerData {
       extra_secrets(extra),
       rotating_ver(0) {}
 
-  void encode(ceph::buffer::list& bl) const {
-     __u8 struct_v = 1;
-    using ceph::encode;
-    encode(struct_v, bl);
-    encode(version, bl);
-    encode(rotating_ver, bl);
-    encode(secrets, bl);
-    encode(rotating_secrets, bl);
-  }
-  void decode(ceph::buffer::list::const_iterator& bl) {
-    using ceph::decode;
-    __u8 struct_v;
-    decode(struct_v, bl);
-    decode(version, bl);
-    decode(rotating_ver, bl);
-    decode(secrets, bl);
-    decode(rotating_secrets, bl);
-  }
+  void encode(ceph::buffer::list& bl) const;
+  void decode(ceph::buffer::list::const_iterator& bl);
 
-  void encode_rotating(ceph::buffer::list& bl) const {
-    using ceph::encode;
-     __u8 struct_v = 1;
-    encode(struct_v, bl);
-    encode(rotating_ver, bl);
-    encode(rotating_secrets, bl);
-  }
-  void decode_rotating(ceph::buffer::list& rotating_bl) {
-    using ceph::decode;
-    auto iter = rotating_bl.cbegin();
-    __u8 struct_v;
-    decode(struct_v, iter);
-    decode(rotating_ver, iter);
-    decode(rotating_secrets, iter);
-  }
-  void dump(ceph::Formatter *f) const {
-    f->dump_unsigned("version", version);
-    f->dump_unsigned("rotating_version", rotating_ver);
-    encode_json("secrets", secrets, f);
-    encode_json("rotating_secrets", rotating_secrets, f);
-  }
+  void encode_rotating(ceph::buffer::list& bl) const;
+  void decode_rotating(ceph::buffer::list& rotating_bl);
+  void dump(ceph::Formatter *f) const;
   static std::list<KeyServerData> generate_test_instances() {
     std::list<KeyServerData> ls;
     ls.emplace_back();
@@ -154,39 +120,9 @@ struct KeyServerData {
     EntityName name;
     EntityAuth auth;
 
-    void encode(ceph::buffer::list& bl) const {
-      using ceph::encode;
-      __u8 struct_v = 1;
-      encode(struct_v, bl);
-     __u32 _op = (__u32)op;
-      encode(_op, bl);
-      if (op == AUTH_INC_SET_ROTATING) {
-       encode(rotating_bl, bl);
-      } else {
-       encode(name, bl);
-       encode(auth, bl);
-      }
-    }
-    void decode(ceph::buffer::list::const_iterator& bl) {
-      using ceph::decode;
-      __u8 struct_v;
-      decode(struct_v, bl);
-      __u32 _op;
-      decode(_op, bl);
-      op = (IncrementalOp)_op;
-      ceph_assert(op >= AUTH_INC_NOP && op <= AUTH_INC_SET_ROTATING);
-      if (op == AUTH_INC_SET_ROTATING) {
-       decode(rotating_bl, bl);
-      } else {
-       decode(name, bl);
-       decode(auth, bl);
-      }
-    }
-    void dump(ceph::Formatter *f) const {
-      f->dump_unsigned("op", op);
-      f->dump_object("name", name);
-      f->dump_object("auth", auth);
-    }
+    void encode(ceph::buffer::list& bl) const;
+    void decode(ceph::buffer::list::const_iterator& bl);
+    void dump(ceph::Formatter *f) const;
     static std::list<Incremental> generate_test_instances() {
       std::list<Incremental> ls;
       ls.emplace_back();
@@ -277,15 +213,8 @@ public:
 
   bool generate_secret(EntityName& name, CryptoKey& secret);
 
-  void encode(ceph::buffer::list& bl) const {
-    using ceph::encode;
-    encode(data, bl);
-  }
-  void decode(ceph::buffer::list::const_iterator& bl) {
-    std::scoped_lock l{lock};
-    using ceph::decode;
-    decode(data, bl);
-  }
+  void encode(ceph::buffer::list& bl) const;
+  void decode(ceph::buffer::list::const_iterator& bl);
   void dump(ceph::Formatter *f) const;
   static std::list<KeyServer> generate_test_instances();
   bool contains(const EntityName& name) const;