1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
9 class AuthSessionHandler
;
11 namespace crimson::net
{
13 class ProtocolV1 final
: public Protocol
{
15 ProtocolV1(ChainedDispatchers
& dispatchers
,
16 SocketConnection
& conn
,
17 SocketMessenger
& messenger
);
18 ~ProtocolV1() override
;
19 void print(std::ostream
&) const final
;
21 void on_closed() override
;
22 bool is_connected() const override
;
24 void start_connect(const entity_addr_t
& peer_addr
,
25 const entity_name_t
& peer_name
) override
;
27 void start_accept(SocketRef
&& socket
,
28 const entity_addr_t
& peer_addr
) override
;
30 void trigger_close() override
;
32 ceph::bufferlist
do_sweep_messages(
33 const std::deque
<MessageRef
>& msgs
,
35 bool require_keepalive
,
36 std::optional
<utime_t
> keepalive_ack
,
37 bool require_ack
) override
;
40 SocketMessenger
&messenger
;
51 state_t state
= state_t::none
;
53 // state for handshake
55 ceph_msg_connect connect
;
56 ceph_msg_connect_reply reply
;
57 ceph::bufferlist auth_payload
; // auth(orizer) payload read off the wire
58 ceph::bufferlist auth_more
; // connect-side auth retry (we added challenge)
59 std::chrono::milliseconds backoff
;
60 uint32_t connect_seq
= 0;
61 uint32_t peer_global_seq
= 0;
65 std::unique_ptr
<AuthSessionHandler
> session_security
;
67 // state for an incoming message
68 struct MessageReader
{
69 ceph_msg_header header
;
70 ceph_msg_footer footer
;
78 const char tag
= CEPH_MSGR_TAG_KEEPALIVE2
;
80 } __attribute__((packed
)) req
;
82 const char tag
= CEPH_MSGR_TAG_KEEPALIVE2_ACK
;
84 } __attribute__((packed
)) ack
;
85 ceph_timespec ack_stamp
;
91 seastar::future
<stop_t
> handle_connect_reply(crimson::net::msgr_tag_t tag
);
92 seastar::future
<stop_t
> repeat_connect();
93 ceph::bufferlist
get_auth_payload();
96 seastar::future
<stop_t
> send_connect_reply(
97 msgr_tag_t tag
, bufferlist
&& authorizer_reply
= {});
98 seastar::future
<stop_t
> send_connect_reply_ready(
99 msgr_tag_t tag
, bufferlist
&& authorizer_reply
);
100 seastar::future
<stop_t
> replace_existing(
101 SocketConnectionRef existing
,
102 bufferlist
&& authorizer_reply
,
103 bool is_reset_from_peer
= false);
104 seastar::future
<stop_t
> handle_connect_with_existing(
105 SocketConnectionRef existing
, bufferlist
&& authorizer_reply
);
106 bool require_auth_feature() const;
107 bool require_cephx_v2_feature() const;
108 seastar::future
<stop_t
> repeat_handle_connect();
111 seastar::future
<> handle_keepalive2_ack();
112 seastar::future
<> handle_keepalive2();
113 seastar::future
<> handle_ack();
114 seastar::future
<> maybe_throttle();
115 seastar::future
<> read_message();
116 seastar::future
<> handle_tags();
122 void execute_open(open_t type
);
125 // the number of connections initiated in this session, increment when a
126 // new connection is established
127 uint32_t connect_seq() const { return h
.connect_seq
; }
128 // the client side should connect us with a gseq. it will be reset with
129 // the one of exsting connection if it's greater.
130 uint32_t peer_global_seq() const { return h
.peer_global_seq
; }
131 // current state of ProtocolV1
132 state_t
get_state() const { return state
; }
134 seastar::future
<> fault();
137 } // namespace crimson::net