|
3 | 3 | #define __FS_CEPH_MESSENGER_H |
4 | 4 |
|
5 | 5 | #include <linux/bvec.h> |
| 6 | +#include <linux/crypto.h> |
6 | 7 | #include <linux/kref.h> |
7 | 8 | #include <linux/mutex.h> |
8 | 9 | #include <linux/net.h> |
@@ -52,6 +53,23 @@ struct ceph_connection_operations { |
52 | 53 |
|
53 | 54 | int (*sign_message) (struct ceph_msg *msg); |
54 | 55 | int (*check_message_signature) (struct ceph_msg *msg); |
| 56 | + |
| 57 | + /* msgr2 authentication exchange */ |
| 58 | + int (*get_auth_request)(struct ceph_connection *con, |
| 59 | + void *buf, int *buf_len, |
| 60 | + void **authorizer, int *authorizer_len); |
| 61 | + int (*handle_auth_reply_more)(struct ceph_connection *con, |
| 62 | + void *reply, int reply_len, |
| 63 | + void *buf, int *buf_len, |
| 64 | + void **authorizer, int *authorizer_len); |
| 65 | + int (*handle_auth_done)(struct ceph_connection *con, |
| 66 | + u64 global_id, void *reply, int reply_len, |
| 67 | + u8 *session_key, int *session_key_len, |
| 68 | + u8 *con_secret, int *con_secret_len); |
| 69 | + int (*handle_auth_bad_method)(struct ceph_connection *con, |
| 70 | + int used_proto, int result, |
| 71 | + const int *allowed_protos, int proto_cnt, |
| 72 | + const int *allowed_modes, int mode_cnt); |
55 | 73 | }; |
56 | 74 |
|
57 | 75 | /* use format string %s%lld */ |
@@ -246,8 +264,15 @@ struct ceph_msg { |
246 | 264 | #define CEPH_CON_S_PREOPEN 2 |
247 | 265 | #define CEPH_CON_S_V1_BANNER 3 |
248 | 266 | #define CEPH_CON_S_V1_CONNECT_MSG 4 |
249 | | -#define CEPH_CON_S_OPEN 5 |
250 | | -#define CEPH_CON_S_STANDBY 6 |
| 267 | +#define CEPH_CON_S_V2_BANNER_PREFIX 5 |
| 268 | +#define CEPH_CON_S_V2_BANNER_PAYLOAD 6 |
| 269 | +#define CEPH_CON_S_V2_HELLO 7 |
| 270 | +#define CEPH_CON_S_V2_AUTH 8 |
| 271 | +#define CEPH_CON_S_V2_AUTH_SIGNATURE 9 |
| 272 | +#define CEPH_CON_S_V2_SESSION_CONNECT 10 |
| 273 | +#define CEPH_CON_S_V2_SESSION_RECONNECT 11 |
| 274 | +#define CEPH_CON_S_OPEN 12 |
| 275 | +#define CEPH_CON_S_STANDBY 13 |
251 | 276 |
|
252 | 277 | /* |
253 | 278 | * ceph_connection flag bits |
@@ -301,6 +326,99 @@ struct ceph_connection_v1_info { |
301 | 326 | u32 peer_global_seq; /* peer's global seq for this connection */ |
302 | 327 | }; |
303 | 328 |
|
| 329 | +#define CEPH_CRC_LEN 4 |
| 330 | +#define CEPH_GCM_KEY_LEN 16 |
| 331 | +#define CEPH_GCM_IV_LEN sizeof(struct ceph_gcm_nonce) |
| 332 | +#define CEPH_GCM_BLOCK_LEN 16 |
| 333 | +#define CEPH_GCM_TAG_LEN 16 |
| 334 | + |
| 335 | +#define CEPH_PREAMBLE_LEN 32 |
| 336 | +#define CEPH_PREAMBLE_INLINE_LEN 48 |
| 337 | +#define CEPH_PREAMBLE_PLAIN_LEN CEPH_PREAMBLE_LEN |
| 338 | +#define CEPH_PREAMBLE_SECURE_LEN (CEPH_PREAMBLE_LEN + \ |
| 339 | + CEPH_PREAMBLE_INLINE_LEN + \ |
| 340 | + CEPH_GCM_TAG_LEN) |
| 341 | +#define CEPH_EPILOGUE_PLAIN_LEN (1 + 3 * CEPH_CRC_LEN) |
| 342 | +#define CEPH_EPILOGUE_SECURE_LEN (CEPH_GCM_BLOCK_LEN + CEPH_GCM_TAG_LEN) |
| 343 | + |
| 344 | +#define CEPH_FRAME_MAX_SEGMENT_COUNT 4 |
| 345 | + |
| 346 | +struct ceph_frame_desc { |
| 347 | + int fd_tag; /* FRAME_TAG_* */ |
| 348 | + int fd_seg_cnt; |
| 349 | + int fd_lens[CEPH_FRAME_MAX_SEGMENT_COUNT]; /* logical */ |
| 350 | + int fd_aligns[CEPH_FRAME_MAX_SEGMENT_COUNT]; |
| 351 | +}; |
| 352 | + |
| 353 | +struct ceph_gcm_nonce { |
| 354 | + __le32 fixed; |
| 355 | + __le64 counter __packed; |
| 356 | +}; |
| 357 | + |
| 358 | +struct ceph_connection_v2_info { |
| 359 | + struct iov_iter in_iter; |
| 360 | + struct kvec in_kvecs[5]; /* recvmsg */ |
| 361 | + struct bio_vec in_bvec; /* recvmsg (in_cursor) */ |
| 362 | + int in_kvec_cnt; |
| 363 | + int in_state; /* IN_S_* */ |
| 364 | + |
| 365 | + struct iov_iter out_iter; |
| 366 | + struct kvec out_kvecs[8]; /* sendmsg */ |
| 367 | + struct bio_vec out_bvec; /* sendpage (out_cursor, out_zero), |
| 368 | + sendmsg (out_enc_pages) */ |
| 369 | + int out_kvec_cnt; |
| 370 | + int out_state; /* OUT_S_* */ |
| 371 | + |
| 372 | + int out_zero; /* # of zero bytes to send */ |
| 373 | + bool out_iter_sendpage; /* use sendpage if possible */ |
| 374 | + |
| 375 | + struct ceph_frame_desc in_desc; |
| 376 | + struct ceph_msg_data_cursor in_cursor; |
| 377 | + struct ceph_msg_data_cursor out_cursor; |
| 378 | + |
| 379 | + struct crypto_shash *hmac_tfm; /* post-auth signature */ |
| 380 | + struct crypto_aead *gcm_tfm; /* on-wire encryption */ |
| 381 | + struct aead_request *gcm_req; |
| 382 | + struct crypto_wait gcm_wait; |
| 383 | + struct ceph_gcm_nonce in_gcm_nonce; |
| 384 | + struct ceph_gcm_nonce out_gcm_nonce; |
| 385 | + |
| 386 | + struct page **out_enc_pages; |
| 387 | + int out_enc_page_cnt; |
| 388 | + int out_enc_resid; |
| 389 | + int out_enc_i; |
| 390 | + |
| 391 | + int con_mode; /* CEPH_CON_MODE_* */ |
| 392 | + |
| 393 | + void *conn_bufs[16]; |
| 394 | + int conn_buf_cnt; |
| 395 | + |
| 396 | + struct kvec in_sign_kvecs[8]; |
| 397 | + struct kvec out_sign_kvecs[8]; |
| 398 | + int in_sign_kvec_cnt; |
| 399 | + int out_sign_kvec_cnt; |
| 400 | + |
| 401 | + u64 client_cookie; |
| 402 | + u64 server_cookie; |
| 403 | + u64 global_seq; |
| 404 | + u64 connect_seq; |
| 405 | + u64 peer_global_seq; |
| 406 | + |
| 407 | + u8 in_buf[CEPH_PREAMBLE_SECURE_LEN]; |
| 408 | + u8 out_buf[CEPH_PREAMBLE_SECURE_LEN]; |
| 409 | + struct { |
| 410 | + u8 late_status; /* FRAME_LATE_STATUS_* */ |
| 411 | + union { |
| 412 | + struct { |
| 413 | + u32 front_crc; |
| 414 | + u32 middle_crc; |
| 415 | + u32 data_crc; |
| 416 | + } __packed; |
| 417 | + u8 pad[CEPH_GCM_BLOCK_LEN - 1]; |
| 418 | + }; |
| 419 | + } out_epil; |
| 420 | +}; |
| 421 | + |
304 | 422 | /* |
305 | 423 | * A single connection with another host. |
306 | 424 | * |
@@ -346,7 +464,10 @@ struct ceph_connection { |
346 | 464 | struct delayed_work work; /* send|recv work */ |
347 | 465 | unsigned long delay; /* current delay interval */ |
348 | 466 |
|
349 | | - struct ceph_connection_v1_info v1; |
| 467 | + union { |
| 468 | + struct ceph_connection_v1_info v1; |
| 469 | + struct ceph_connection_v2_info v2; |
| 470 | + }; |
350 | 471 | }; |
351 | 472 |
|
352 | 473 | extern struct page *ceph_zero_page; |
@@ -397,6 +518,15 @@ bool ceph_con_v1_opened(struct ceph_connection *con); |
397 | 518 | void ceph_con_v1_reset_session(struct ceph_connection *con); |
398 | 519 | void ceph_con_v1_reset_protocol(struct ceph_connection *con); |
399 | 520 |
|
| 521 | +/* messenger_v2.c */ |
| 522 | +int ceph_con_v2_try_read(struct ceph_connection *con); |
| 523 | +int ceph_con_v2_try_write(struct ceph_connection *con); |
| 524 | +void ceph_con_v2_revoke(struct ceph_connection *con); |
| 525 | +void ceph_con_v2_revoke_incoming(struct ceph_connection *con); |
| 526 | +bool ceph_con_v2_opened(struct ceph_connection *con); |
| 527 | +void ceph_con_v2_reset_session(struct ceph_connection *con); |
| 528 | +void ceph_con_v2_reset_protocol(struct ceph_connection *con); |
| 529 | + |
400 | 530 |
|
401 | 531 | extern const char *ceph_pr_addr(const struct ceph_entity_addr *addr); |
402 | 532 |
|
|
0 commit comments