mon/MonClient.cc
${PROJECT_SOURCE_DIR}/src/mon/MonSub.cc)
set(crimson_net_srcs
- net/Dispatcher.cc
net/Errors.cc
net/Messenger.cc
net/SocketConnection.cc
+++ /dev/null
-#include "auth/Auth.h"
-#include "Dispatcher.h"
-
-namespace ceph::net
-{
-seastar::future<std::unique_ptr<AuthAuthorizer>>
-Dispatcher::ms_get_authorizer(peer_type_t)
-{
- return seastar::make_ready_future<std::unique_ptr<AuthAuthorizer>>(nullptr);
-}
-}
bufferlist&) {
return seastar::make_ready_future<msgr_tag_t, bufferlist>(0, bufferlist{});
}
- virtual seastar::future<std::unique_ptr<AuthAuthorizer>>
- ms_get_authorizer(peer_type_t);
+ virtual AuthAuthorizer* ms_get_authorizer(peer_type_t) const {
+ return nullptr;
+ }
// get the local dispatcher shard if it is accessed by another core
virtual Dispatcher* get_local_shard() {
h.authorizer->session_key,
features));
}
- h.authorizer.reset();
+ h.authorizer = nullptr;
return seastar::make_ready_future<stop_t>(stop_t::yes);
});
break;
// this is fyi, actually, server decides!
h.connect.flags = policy.lossy ? CEPH_MSG_CONNECT_LOSSY : 0;
- return dispatcher.ms_get_authorizer(peer_type)
- .then([this](auto&& auth) {
- h.authorizer = std::move(auth);
- bufferlist bl;
- if (h.authorizer) {
- h.connect.authorizer_protocol = h.authorizer->protocol;
- h.connect.authorizer_len = h.authorizer->bl.length();
- bl.append(create_static(h.connect));
- bl.append(h.authorizer->bl);
- } else {
- h.connect.authorizer_protocol = 0;
- h.connect.authorizer_len = 0;
- bl.append(create_static(h.connect));
- };
- return socket->write_flush(std::move(bl));
- }).then([this] {
- // read the reply
+ h.authorizer = dispatcher.ms_get_authorizer(peer_type);
+ bufferlist bl;
+ if (h.authorizer) {
+ h.connect.authorizer_protocol = h.authorizer->protocol;
+ h.connect.authorizer_len = h.authorizer->bl.length();
+ bl.append(create_static(h.connect));
+ bl.append(h.authorizer->bl);
+ } else {
+ h.connect.authorizer_protocol = 0;
+ h.connect.authorizer_len = 0;
+ bl.append(create_static(h.connect));
+ }
+ return socket->write_flush(std::move(bl))
+ .then([this] {
+ // read the reply
return socket->read(sizeof(h.reply));
}).then([this] (bufferlist bl) {
auto p = bl.cbegin();
struct Handshake {
ceph_msg_connect connect;
ceph_msg_connect_reply reply;
- std::unique_ptr<AuthAuthorizer> authorizer;
+ AuthAuthorizer* authorizer = nullptr;
std::chrono::milliseconds backoff;
uint32_t connect_seq = 0;
uint32_t peer_global_seq = 0;
});
}
-seastar::future<std::unique_ptr<AuthAuthorizer>>
-ChainedDispatchers::ms_get_authorizer(peer_type_t peer_type)
+AuthAuthorizer*
+ChainedDispatchers::ms_get_authorizer(peer_type_t peer_type) const
{
// since dispatcher returns a nullptr if it does not have the authorizer,
// let's use the chain-of-responsibility pattern here.
- struct Params {
- peer_type_t peer_type;
- std::deque<Dispatcher*>::iterator first, last;
- } params = {peer_type, dispatchers.begin(), dispatchers.end()};
- return seastar::do_with(Params{params}, [this] (Params& params) {
- using result_t = std::unique_ptr<AuthAuthorizer>;
- return seastar::repeat_until_value([&] () {
- auto& first = params.first;
- if (first == params.last) {
- // just give up
- return seastar::make_ready_future<std::optional<result_t>>(result_t{});
- } else {
- return (*first)->ms_get_authorizer(params.peer_type)
- .then([&] (auto&& auth)-> std::optional<result_t> {
- if (auth) {
- // hooray!
- return std::move(auth);
- } else {
- // try next one
- ++first;
- return {};
- }
- });
- }
- });
- });
+ for (auto dispatcher : dispatchers) {
+ if (auto auth = dispatcher->ms_get_authorizer(peer_type); auth) {
+ return auth;
+ }
+ }
+ // just give up
+ return nullptr;
}
seastar::future<> ms_handle_connect(ceph::net::ConnectionRef conn) override;
seastar::future<> ms_handle_reset(ceph::net::ConnectionRef conn) override;
seastar::future<> ms_handle_remote_reset(ceph::net::ConnectionRef conn) override;
- seastar::future<std::unique_ptr<AuthAuthorizer>>
- ms_get_authorizer(peer_type_t peer_type) override;
+ AuthAuthorizer* ms_get_authorizer(peer_type_t peer_type) const override;
};