Merge PR #26327 into master

* refs/pull/26327/head:
	doc/dev/msgr2: bring up to date with new HELLO, different RECONNECT
	msg/async/ProtocolV2: separate IDENT into {CLIENT,SERVER}_IDENT

Reviewed-by: Ricardo Dias <rdias@suse.com>
This commit is contained in:
Sage Weil 2019-02-09 08:29:18 -06:00
commit 33582d2290
3 changed files with 49 additions and 29 deletions

View File

@ -101,6 +101,17 @@ the form::
has completed (TAG_AUTH_DONE has been sent) and signatures are
enabled.
Hello
-----
* TAG_HELLO: client->server and server->client::
__u8 entity_type
entity_addr_t peer_socket_address
- We immediately share our entity type and the address of the peer (which can be useful
for detecting our effective IP address, especially in the presence of NAT).
Authentication
--------------
@ -235,19 +246,20 @@ Message flow handshake
In this phase the peers identify each other and (if desired) reconnect to
an established session.
* TAG_IDENT: identify ourselves::
* TAG_CLIENT_IDENT (client->server): identify ourselves::
entity_addrvec_t addr(s)
__u8 my type (CEPH_ENTITY_TYPE_*)
__le32 num_addrs
entity_addrvec_t*num_addrs entity addrs
__le64 gid (numeric part of osd.0, client.123456, ...)
__le64 global_seq
__le64 features supported (CEPH_FEATURE_* bitmask)
__le64 features required (CEPH_FEATURE_* bitmask)
__le64 flags (CEPH_MSG_CONNECT_* bitmask)
__le64 cookie (a client identifier, assigned by the sender. unique on the sender.)
- client will send first, server will reply with same. if this is a
new session, the client and server can proceed to the message exchange.
- type.gid (entity_name_t) is set here. this means we don't need it
- type.gid (entity_name_t) is set here, by combinging the type shared in the hello
frame with the gid here. this means we don't need it
in the header of every message. it also means that we can't send
messages "from" other entity_name_t's. the current
implementations set this at the top of _send_message etc so this
@ -255,24 +267,39 @@ an established session.
likely want to mask this against what the authenticated credential
allows.
- we've dropped the 'protocol_version' field from msgr1
- for lossy sessions, cookie is meaningless. for lossless sessions,
we assign a local value that identifies the local Connection
state. when we receive this from a peer, we make a note of their
cookie, so that on reconnect we can reattach (see below).
* TAG_IDENT_MISSING_FEATURES (server only): complain about a TAG_IDENT
* TAG_IDENT_MISSING_FEATURES (server->client): complain about a TAG_IDENT
with too few features::
__le64 features we require that the peer didn't advertise
* TAG_RECONNECT (client only): reconnect to an established session::
* TAG_SERVER_IDENT (server->client): accept client ident and identify server::
__le32 num_addrs
entity_addrvec_t*num_addrs entity addrs
__le64 gid (numeric part of osd.0, client.123456, ...)
__le64 global_seq
__le64 features supported (CEPH_FEATURE_* bitmask)
__le64 features required (CEPH_FEATURE_* bitmask)
__le64 flags (CEPH_MSG_CONNECT_* bitmask)
__le64 cookie
- The cookie can be used by the client if it is later disconnected and wants to
reconnect and resume the session.
* TAG_RECONNECT (client->server): reconnect to an established session::
__le32 num_addrs
entity_addr_t * num_addrs
__le64 cookie
__le64 id (of name.id, e.g., osd.123 -> 123)
__le64 global_seq
__le64 connect_seq
__le64 supported_features
__le64 required_features
__le64 msg_seq (the last msg seq received)
* TAG_RECONNECT_OK (server only): acknowledge a reconnect attempt::
* TAG_RECONNECT_OK (server->client): acknowledge a reconnect attempt::
__le64 msg_seq (last msg seq received)

View File

@ -311,7 +311,7 @@ struct SignedEncryptedFrame : public PayloadFrame<T, Args..., signature_t> {
struct ClientIdentFrame
: public SignedEncryptedFrame<ClientIdentFrame, entity_addrvec_t, int64_t,
uint64_t, uint64_t, uint64_t, uint64_t> {
const ProtocolV2::Tag tag = ProtocolV2::Tag::IDENT;
const ProtocolV2::Tag tag = ProtocolV2::Tag::CLIENT_IDENT;
using SignedEncryptedFrame::SignedEncryptedFrame;
inline entity_addrvec_t &addrs() { return get_val<0>(); }
@ -326,7 +326,7 @@ struct ServerIdentFrame
: public SignedEncryptedFrame<ServerIdentFrame, entity_addrvec_t,
int64_t, uint64_t, uint64_t,
uint64_t, uint64_t, uint64_t> {
const ProtocolV2::Tag tag = ProtocolV2::Tag::IDENT;
const ProtocolV2::Tag tag = ProtocolV2::Tag::SERVER_IDENT;
using SignedEncryptedFrame::SignedEncryptedFrame;
inline entity_addrvec_t &addrs() { return get_val<0>(); }
@ -1417,7 +1417,8 @@ CtPtr ProtocolV2::handle_read_frame_length_and_tag(char *buffer, int r) {
case Tag::AUTH_REPLY_MORE:
case Tag::AUTH_REQUEST_MORE:
case Tag::AUTH_DONE:
case Tag::IDENT:
case Tag::CLIENT_IDENT:
case Tag::SERVER_IDENT:
case Tag::IDENT_MISSING_FEATURES:
case Tag::SESSION_RECONNECT:
case Tag::SESSION_RETRY:
@ -1472,8 +1473,10 @@ CtPtr ProtocolV2::handle_frame_payload(char *buffer, int r) {
return handle_auth_request_more(buffer, next_payload_len);
case Tag::AUTH_DONE:
return handle_auth_done(buffer, next_payload_len);
case Tag::IDENT:
return handle_ident(buffer, next_payload_len);
case Tag::CLIENT_IDENT:
return handle_client_ident(buffer, next_payload_len);
case Tag::SERVER_IDENT:
return handle_server_ident(buffer, next_payload_len);
case Tag::IDENT_MISSING_FEATURES:
return handle_ident_missing_features(buffer, next_payload_len);
case Tag::SESSION_RECONNECT:
@ -1496,16 +1499,6 @@ CtPtr ProtocolV2::handle_frame_payload(char *buffer, int r) {
return nullptr;
}
CtPtr ProtocolV2::handle_ident(char *payload, uint32_t length) {
if (state == CONNECTING) {
return handle_server_ident(payload, length);
}
if (state == ACCEPTING) {
return handle_client_ident(payload, length);
}
ceph_abort("wrong state at handle_ident");
}
CtPtr ProtocolV2::ready() {
ldout(cct, 25) << __func__ << dendl;

View File

@ -53,7 +53,8 @@ public:
AUTH_REPLY_MORE,
AUTH_REQUEST_MORE,
AUTH_DONE,
IDENT,
CLIENT_IDENT,
SERVER_IDENT,
IDENT_MISSING_FEATURES,
SESSION_RECONNECT,
SESSION_RESET,
@ -155,7 +156,6 @@ private:
Ct<ProtocolV2> *read_frame();
Ct<ProtocolV2> *handle_read_frame_length_and_tag(char *buffer, int r);
Ct<ProtocolV2> *handle_frame_payload(char *buffer, int r);
Ct<ProtocolV2> *handle_ident(char *payload, uint32_t length);
Ct<ProtocolV2> *ready();