From 86c99bf0232a20aa29bf8c15092e91a20f543992 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 7 Feb 2019 17:03:41 -0600 Subject: [PATCH] msg/async/ProtocolV2: separate IDENT into {CLIENT,SERVER}_IDENT This is less ambiguous and easier to document since the frame payloads are different. Signed-off-by: Sage Weil --- doc/dev/msgr2.rst | 32 +++++++++++++++++++++----------- src/msg/async/ProtocolV2.cc | 23 ++++++++--------------- src/msg/async/ProtocolV2.h | 4 ++-- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/doc/dev/msgr2.rst b/doc/dev/msgr2.rst index 7cbfe8acefa23..72979a2b732c8 100644 --- a/doc/dev/msgr2.rst +++ b/doc/dev/msgr2.rst @@ -235,19 +235,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,17 +256,26 @@ 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. + __le64 cookie __le64 global_seq diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index 8f2c5c787b8cd..1b8522c2270a7 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -311,7 +311,7 @@ struct SignedEncryptedFrame : public PayloadFrame { struct ClientIdentFrame : public SignedEncryptedFrame { - 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 { - 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; diff --git a/src/msg/async/ProtocolV2.h b/src/msg/async/ProtocolV2.h index 8185c57636346..64bc10f4c1a54 100644 --- a/src/msg/async/ProtocolV2.h +++ b/src/msg/async/ProtocolV2.h @@ -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 *read_frame(); Ct *handle_read_frame_length_and_tag(char *buffer, int r); Ct *handle_frame_payload(char *buffer, int r); - Ct *handle_ident(char *payload, uint32_t length); Ct *ready(); -- 2.39.5