]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: clean auth related interfaces
authorYingxin Cheng <yingxincheng@gmail.com>
Mon, 1 Apr 2019 14:24:31 +0000 (22:24 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 5 Apr 2019 03:21:19 +0000 (11:21 +0800)
Signed-off-by: Yingxin Cheng <yingxincheng@gmail.com>
src/crimson/auth/AuthServer.h
src/crimson/net/Messenger.h
src/crimson/net/ProtocolV2.cc

index e15d47bb1594a56965a6bbef97f9001cea6a1556..ce24bd953367cf507fc387798eb9b5043858a86c 100644 (file)
@@ -19,15 +19,13 @@ public:
   virtual ~AuthServer() {}
 
   // Get authentication methods and connection modes for the given peer type
-  virtual void get_supported_auth_methods(
-    int peer_type,
-    std::vector<uint32_t> *methods,
-    std::vector<uint32_t> *modes = nullptr) {
-    // auth_registry.get_supported_methods(peer_type, methods, modes);
-    *methods = { CEPH_AUTH_NONE };
-    if (modes != nullptr) {
-      *modes = { CEPH_CON_MODE_CRC };
-    }
+  virtual std::pair<std::vector<uint32_t>, std::vector<uint32_t>>
+  get_supported_auth_methods(
+    int peer_type) {
+    // std::vector<uint32_t> methods;
+    // std::vector<uint32_t> modes;
+    // auth_registry.get_supported_methods(peer_type, &methods, &modes);
+    return {{CEPH_AUTH_NONE}, {CEPH_AUTH_NONE}};
   }
 
   // Get support connection modes for the given peer type and auth method
index fd423482e2b1c5b27182ae6b19a35bdecc0b4677..76328f80119b7e88fd24e764aadf10630a722d89 100644 (file)
@@ -37,10 +37,8 @@ class Messenger {
   entity_addrvec_t my_addrs;
   uint32_t global_seq = 0;
   uint32_t crc_flags = 0;
-
- public:
-  ceph::auth::AuthClient *auth_client = 0;
-  ceph::auth::AuthServer *auth_server = 0;
+  ceph::auth::AuthClient* auth_client = nullptr;
+  ceph::auth::AuthServer* auth_server = nullptr;
 
  public:
   Messenger(const entity_name_t& name)
@@ -97,9 +95,11 @@ class Messenger {
     crc_flags |= MSG_CRC_HEADER;
   }
 
+  ceph::auth::AuthClient* get_auth_client() const { return auth_client; }
   void set_auth_client(ceph::auth::AuthClient *ac) {
     auth_client = ac;
   }
+  ceph::auth::AuthServer* get_auth_server() const { return auth_server; }
   void set_auth_server(ceph::auth::AuthServer *as) {
     auth_server = as;
   }
index 038733f57c793ac396cb01c0287b9fc97eca05e8..3d74b9ca9db97a57e60a32ca014282965806f0ac 100644 (file)
@@ -464,8 +464,8 @@ seastar::future<> ProtocolV2::handle_auth_reply()
                         "allowed methods={}, allowed modes={}",
                         conn, bad_method.method(), cpp_strerror(bad_method.result()),
                         bad_method.allowed_methods(), bad_method.allowed_modes());
-          ceph_assert(messenger.auth_client);
-          int r = messenger.auth_client->handle_auth_bad_method(
+          ceph_assert(messenger.get_auth_client());
+          int r = messenger.get_auth_client()->handle_auth_bad_method(
               conn.shared_from_this(), auth_meta,
               bad_method.method(), bad_method.result(),
               bad_method.allowed_methods(), bad_method.allowed_modes());
@@ -483,9 +483,9 @@ seastar::future<> ProtocolV2::handle_auth_reply()
           auto auth_more = AuthReplyMoreFrame::Decode(rx_segments_data.back());
           logger().debug("{} auth reply more len={}",
                          conn, auth_more.auth_payload().length());
-          ceph_assert(messenger.auth_client);
+          ceph_assert(messenger.get_auth_client());
           ceph::bufferlist reply;
-          int r = messenger.auth_client->handle_auth_reply_more(
+          int r = messenger.get_auth_client()->handle_auth_reply_more(
                conn.shared_from_this(), auth_meta, auth_more.auth_payload(), &reply);
           if (r < 0) {
             logger().error("{} auth_client handle_auth_reply_more returned {}",
@@ -502,8 +502,8 @@ seastar::future<> ProtocolV2::handle_auth_reply()
         .then([this] {
           // handle_auth_done() logic
           auto auth_done = AuthDoneFrame::Decode(rx_segments_data.back());
-          ceph_assert(messenger.auth_client);
-          int r = messenger.auth_client->handle_auth_done(
+          ceph_assert(messenger.get_auth_client());
+          int r = messenger.get_auth_client()->handle_auth_done(
               conn.shared_from_this(), auth_meta,
               auth_done.global_id(),
               auth_done.con_mode(),
@@ -530,11 +530,11 @@ seastar::future<> ProtocolV2::handle_auth_reply()
 seastar::future<> ProtocolV2::client_auth(std::vector<uint32_t> &allowed_methods)
 {
   // send_auth_request() logic
-  ceph_assert(messenger.auth_client);
+  ceph_assert(messenger.get_auth_client());
 
   bufferlist bl;
   vector<uint32_t> preferred_modes;
-  int r = messenger.auth_client->get_auth_request(
+  int r = messenger.get_auth_client()->get_auth_request(
       conn.shared_from_this(), auth_meta, &auth_meta->auth_method,
       &preferred_modes, &bl);
   if (r < 0) {
@@ -810,10 +810,8 @@ seastar::future<> ProtocolV2::_auth_bad_method(int r)
 {
   // _auth_bad_method() logic
   ceph_assert(r < 0);
-  std::vector<uint32_t> allowed_methods;
-  std::vector<uint32_t> allowed_modes;
-  messenger.auth_server->get_supported_auth_methods(
-      conn.get_peer_type(), &allowed_methods, &allowed_modes);
+  auto [allowed_methods, allowed_modes] =
+      messenger.get_auth_server()->get_supported_auth_methods(conn.get_peer_type());
   logger().warn("{} send AuthBadMethod(auth_method={}, r={}, "
                 "allowed_methods={}, allowed_modes={})",
                 conn, auth_meta->auth_method, cpp_strerror(r),
@@ -829,9 +827,9 @@ seastar::future<> ProtocolV2::_auth_bad_method(int r)
 seastar::future<> ProtocolV2::_handle_auth_request(bufferlist& auth_payload, bool more)
 {
   // _handle_auth_request() logic
-  ceph_assert(messenger.auth_server);
+  ceph_assert(messenger.get_auth_server());
   bufferlist reply;
-  int r = messenger.auth_server->handle_auth_request(
+  int r = messenger.get_auth_server()->handle_auth_request(
       conn.shared_from_this(), auth_meta,
       more, auth_meta->auth_method, auth_payload,
       &reply);
@@ -887,7 +885,7 @@ seastar::future<> ProtocolV2::server_auth()
                    conn, request.method(), request.preferred_modes(),
                    request.auth_payload().length());
     auth_meta->auth_method = request.method();
-    auth_meta->con_mode = messenger.auth_server->pick_con_mode(
+    auth_meta->con_mode = messenger.get_auth_server()->pick_con_mode(
         conn.get_peer_type(), auth_meta->auth_method,
         request.preferred_modes());
     if (auth_meta->con_mode == CEPH_CON_MODE_UNKNOWN) {