xref: /linux/include/linux/ceph/messenger.h (revision 8bd9238e511d02831022ff0270865c54ccc482d6)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __FS_CEPH_MESSENGER_H
3 #define __FS_CEPH_MESSENGER_H
4 
5 #include <crypto/sha2.h>
6 #include <linux/bvec.h>
7 #include <linux/crypto.h>
8 #include <linux/kref.h>
9 #include <linux/mutex.h>
10 #include <linux/net.h>
11 #include <linux/radix-tree.h>
12 #include <linux/uio.h>
13 #include <linux/workqueue.h>
14 #include <net/net_namespace.h>
15 
16 #include <linux/ceph/types.h>
17 #include <linux/ceph/buffer.h>
18 
19 struct ceph_msg;
20 struct ceph_connection;
21 struct ceph_msg_data_cursor;
22 
23 /*
24  * Ceph defines these callbacks for handling connection events.
25  */
26 struct ceph_connection_operations {
27 	struct ceph_connection *(*get)(struct ceph_connection *);
28 	void (*put)(struct ceph_connection *);
29 
30 	/* handle an incoming message. */
31 	void (*dispatch) (struct ceph_connection *con, struct ceph_msg *m);
32 
33 	/* authorize an outgoing connection */
34 	struct ceph_auth_handshake *(*get_authorizer) (
35 				struct ceph_connection *con,
36 			       int *proto, int force_new);
37 	int (*add_authorizer_challenge)(struct ceph_connection *con,
38 					void *challenge_buf,
39 					int challenge_buf_len);
40 	int (*verify_authorizer_reply) (struct ceph_connection *con);
41 	int (*invalidate_authorizer)(struct ceph_connection *con);
42 
43 	/* there was some error on the socket (disconnect, whatever) */
44 	void (*fault) (struct ceph_connection *con);
45 
46 	/* a remote host as terminated a message exchange session, and messages
47 	 * we sent (or they tried to send us) may be lost. */
48 	void (*peer_reset) (struct ceph_connection *con);
49 
50 	struct ceph_msg * (*alloc_msg) (struct ceph_connection *con,
51 					struct ceph_msg_header *hdr,
52 					int *skip);
53 
54 	void (*reencode_message) (struct ceph_msg *msg);
55 
56 	int (*sign_message) (struct ceph_msg *msg);
57 	int (*check_message_signature) (struct ceph_msg *msg);
58 
59 	/* msgr2 authentication exchange */
60 	int (*get_auth_request)(struct ceph_connection *con,
61 				void *buf, int *buf_len,
62 				void **authorizer, int *authorizer_len);
63 	int (*handle_auth_reply_more)(struct ceph_connection *con,
64 				      void *reply, int reply_len,
65 				      void *buf, int *buf_len,
66 				      void **authorizer, int *authorizer_len);
67 	int (*handle_auth_done)(struct ceph_connection *con,
68 				u64 global_id, void *reply, int reply_len,
69 				u8 *session_key, int *session_key_len,
70 				u8 *con_secret, int *con_secret_len);
71 	int (*handle_auth_bad_method)(struct ceph_connection *con,
72 				      int used_proto, int result,
73 				      const int *allowed_protos, int proto_cnt,
74 				      const int *allowed_modes, int mode_cnt);
75 
76 	/**
77 	 * sparse_read: read sparse data
78 	 * @con: connection we're reading from
79 	 * @cursor: data cursor for reading extents
80 	 * @buf: optional buffer to read into
81 	 *
82 	 * This should be called more than once, each time setting up to
83 	 * receive an extent into the current cursor position, and zeroing
84 	 * the holes between them.
85 	 *
86 	 * Returns amount of data to be read (in bytes), 0 if reading is
87 	 * complete, or -errno if there was an error.
88 	 *
89 	 * If @buf is set on a >0 return, then the data should be read into
90 	 * the provided buffer. Otherwise, it should be read into the cursor.
91 	 *
92 	 * The sparse read operation is expected to initialize the cursor
93 	 * with a length covering up to the end of the last extent.
94 	 */
95 	int (*sparse_read)(struct ceph_connection *con,
96 			   struct ceph_msg_data_cursor *cursor,
97 			   char **buf);
98 
99 };
100 
101 /* use format string %s%lld */
102 #define ENTITY_NAME(n) ceph_entity_type_name((n).type), le64_to_cpu((n).num)
103 
104 struct ceph_messenger {
105 	struct ceph_entity_inst inst;    /* my name+address */
106 	struct ceph_entity_addr my_enc_addr;
107 
108 	atomic_t stopping;
109 	possible_net_t net;
110 
111 	/*
112 	 * the global_seq counts connections i (attempt to) initiate
113 	 * in order to disambiguate certain connect race conditions.
114 	 */
115 	u32 global_seq;
116 	spinlock_t global_seq_lock;
117 };
118 
119 enum ceph_msg_data_type {
120 	CEPH_MSG_DATA_NONE,	/* message contains no data payload */
121 	CEPH_MSG_DATA_PAGES,	/* data source/destination is a page array */
122 	CEPH_MSG_DATA_PAGELIST,	/* data source/destination is a pagelist */
123 #ifdef CONFIG_BLOCK
124 	CEPH_MSG_DATA_BIO,	/* data source/destination is a bio list */
125 #endif /* CONFIG_BLOCK */
126 	CEPH_MSG_DATA_BVECS,	/* data source/destination is a bio_vec array */
127 	CEPH_MSG_DATA_ITER,	/* data source/destination is an iov_iter */
128 };
129 
130 #ifdef CONFIG_BLOCK
131 
132 struct ceph_bio_iter {
133 	struct bio *bio;
134 	struct bvec_iter iter;
135 };
136 
137 #define __ceph_bio_iter_advance_step(it, n, STEP) do {			      \
138 	unsigned int __n = (n), __cur_n;				      \
139 									      \
140 	while (__n) {							      \
141 		BUG_ON(!(it)->iter.bi_size);				      \
142 		__cur_n = min((it)->iter.bi_size, __n);			      \
143 		(void)(STEP);						      \
144 		bio_advance_iter((it)->bio, &(it)->iter, __cur_n);	      \
145 		if (!(it)->iter.bi_size && (it)->bio->bi_next) {	      \
146 			dout("__ceph_bio_iter_advance_step next bio\n");      \
147 			(it)->bio = (it)->bio->bi_next;			      \
148 			(it)->iter = (it)->bio->bi_iter;		      \
149 		}							      \
150 		__n -= __cur_n;						      \
151 	}								      \
152 } while (0)
153 
154 /*
155  * Advance @it by @n bytes.
156  */
157 #define ceph_bio_iter_advance(it, n)					      \
158 	__ceph_bio_iter_advance_step(it, n, 0)
159 
160 /*
161  * Advance @it by @n bytes, executing BVEC_STEP for each bio_vec.
162  */
163 #define ceph_bio_iter_advance_step(it, n, BVEC_STEP)			      \
164 	__ceph_bio_iter_advance_step(it, n, ({				      \
165 		struct bio_vec bv;					      \
166 		struct bvec_iter __cur_iter;				      \
167 									      \
168 		__cur_iter = (it)->iter;				      \
169 		__cur_iter.bi_size = __cur_n;				      \
170 		__bio_for_each_segment(bv, (it)->bio, __cur_iter, __cur_iter) \
171 			(void)(BVEC_STEP);				      \
172 	}))
173 
174 #endif /* CONFIG_BLOCK */
175 
176 struct ceph_bvec_iter {
177 	struct bio_vec *bvecs;
178 	struct bvec_iter iter;
179 };
180 
181 #define __ceph_bvec_iter_advance_step(it, n, STEP) do {			      \
182 	BUG_ON((n) > (it)->iter.bi_size);				      \
183 	(void)(STEP);							      \
184 	bvec_iter_advance((it)->bvecs, &(it)->iter, (n));		      \
185 } while (0)
186 
187 /*
188  * Advance @it by @n bytes.
189  */
190 #define ceph_bvec_iter_advance(it, n)					      \
191 	__ceph_bvec_iter_advance_step(it, n, 0)
192 
193 /*
194  * Advance @it by @n bytes, executing BVEC_STEP for each bio_vec.
195  */
196 #define ceph_bvec_iter_advance_step(it, n, BVEC_STEP)			      \
197 	__ceph_bvec_iter_advance_step(it, n, ({				      \
198 		struct bio_vec bv;					      \
199 		struct bvec_iter __cur_iter;				      \
200 									      \
201 		__cur_iter = (it)->iter;				      \
202 		__cur_iter.bi_size = (n);				      \
203 		for_each_bvec(bv, (it)->bvecs, __cur_iter, __cur_iter)	      \
204 			(void)(BVEC_STEP);				      \
205 	}))
206 
207 #define ceph_bvec_iter_shorten(it, n) do {				      \
208 	BUG_ON((n) > (it)->iter.bi_size);				      \
209 	(it)->iter.bi_size = (n);					      \
210 } while (0)
211 
212 struct ceph_msg_data {
213 	enum ceph_msg_data_type		type;
214 	union {
215 #ifdef CONFIG_BLOCK
216 		struct {
217 			struct ceph_bio_iter	bio_pos;
218 			u32			bio_length;
219 		};
220 #endif /* CONFIG_BLOCK */
221 		struct ceph_bvec_iter	bvec_pos;
222 		struct {
223 			struct page	**pages;
224 			size_t		length;		/* total # bytes */
225 			unsigned int	alignment;	/* first page */
226 			bool		own_pages;
227 		};
228 		struct ceph_pagelist	*pagelist;
229 		struct iov_iter		iter;
230 	};
231 };
232 
233 struct ceph_msg_data_cursor {
234 	size_t			total_resid;	/* across all data items */
235 
236 	struct ceph_msg_data	*data;		/* current data item */
237 	size_t			resid;		/* bytes not yet consumed */
238 	int			sr_resid;	/* residual sparse_read len */
239 	bool			need_crc;	/* crc update needed */
240 	union {
241 #ifdef CONFIG_BLOCK
242 		struct ceph_bio_iter	bio_iter;
243 #endif /* CONFIG_BLOCK */
244 		struct bvec_iter	bvec_iter;
245 		struct {				/* pages */
246 			unsigned int	page_offset;	/* offset in page */
247 			unsigned short	page_index;	/* index in array */
248 			unsigned short	page_count;	/* pages in array */
249 		};
250 		struct {				/* pagelist */
251 			struct page	*page;		/* page from list */
252 			size_t		offset;		/* bytes from list */
253 		};
254 		struct {
255 			struct iov_iter		iov_iter;
256 			unsigned int		lastlen;
257 		};
258 	};
259 };
260 
261 /*
262  * a single message.  it contains a header (src, dest, message type, etc.),
263  * footer (crc values, mainly), a "front" message body, and possibly a
264  * data payload (stored in some number of pages).
265  */
266 struct ceph_msg {
267 	struct ceph_msg_header hdr;	/* header */
268 	union {
269 		struct ceph_msg_footer footer;		/* footer */
270 		struct ceph_msg_footer_old old_footer;	/* old format footer */
271 	};
272 	struct kvec front;              /* unaligned blobs of message */
273 	struct ceph_buffer *middle;
274 
275 	size_t				data_length;
276 	struct ceph_msg_data		*data;
277 	int				num_data_items;
278 	int				max_data_items;
279 	struct ceph_msg_data_cursor	cursor;
280 
281 	struct ceph_connection *con;
282 	struct list_head list_head;	/* links for connection lists */
283 
284 	struct kref kref;
285 	bool more_to_follow;
286 	bool needs_out_seq;
287 	u64 sparse_read_total;
288 	int front_alloc_len;
289 
290 	struct ceph_msgpool *pool;
291 };
292 
293 /*
294  * connection states
295  */
296 #define CEPH_CON_S_CLOSED		1
297 #define CEPH_CON_S_PREOPEN		2
298 #define CEPH_CON_S_V1_BANNER		3
299 #define CEPH_CON_S_V1_CONNECT_MSG	4
300 #define CEPH_CON_S_V2_BANNER_PREFIX	5
301 #define CEPH_CON_S_V2_BANNER_PAYLOAD	6
302 #define CEPH_CON_S_V2_HELLO		7
303 #define CEPH_CON_S_V2_AUTH		8
304 #define CEPH_CON_S_V2_AUTH_SIGNATURE	9
305 #define CEPH_CON_S_V2_SESSION_CONNECT	10
306 #define CEPH_CON_S_V2_SESSION_RECONNECT	11
307 #define CEPH_CON_S_OPEN			12
308 #define CEPH_CON_S_STANDBY		13
309 
310 /*
311  * ceph_connection flag bits
312  */
313 #define CEPH_CON_F_LOSSYTX		0  /* we can close channel or drop
314 					      messages on errors */
315 #define CEPH_CON_F_KEEPALIVE_PENDING	1  /* we need to send a keepalive */
316 #define CEPH_CON_F_WRITE_PENDING	2  /* we have data ready to send */
317 #define CEPH_CON_F_SOCK_CLOSED		3  /* socket state changed to closed */
318 #define CEPH_CON_F_BACKOFF		4  /* need to retry queuing delayed
319 					      work */
320 
321 /* ceph connection fault delay defaults, for exponential backoff */
322 #define BASE_DELAY_INTERVAL	(HZ / 4)
323 #define MAX_DELAY_INTERVAL	(15 * HZ)
324 
325 struct ceph_connection_v1_info {
326 	struct kvec out_kvec[8],         /* sending header/footer data */
327 		*out_kvec_cur;
328 	int out_kvec_left;   /* kvec's left in out_kvec */
329 	int out_skip;        /* skip this many bytes */
330 	int out_kvec_bytes;  /* total bytes left */
331 	bool out_more;       /* there is more data after the kvecs */
332 	bool out_msg_done;
333 
334 	struct ceph_auth_handshake *auth;
335 	int auth_retry;       /* true if we need a newer authorizer */
336 
337 	/* connection negotiation temps */
338 	u8 in_banner[CEPH_BANNER_MAX_LEN];
339 	struct ceph_entity_addr actual_peer_addr;
340 	struct ceph_entity_addr peer_addr_for_me;
341 	struct ceph_msg_connect out_connect;
342 	struct ceph_msg_connect_reply in_reply;
343 
344 	int in_base_pos;     /* bytes read */
345 
346 	/* sparse reads */
347 	struct kvec in_sr_kvec; /* current location to receive into */
348 	u64 in_sr_len;		/* amount of data in this extent */
349 
350 	/* message in temps */
351 	u8 in_tag;           /* protocol control byte */
352 	struct ceph_msg_header in_hdr;
353 	__le64 in_temp_ack;  /* for reading an ack */
354 
355 	/* message out temps */
356 	struct ceph_msg_header out_hdr;
357 	__le64 out_temp_ack;  /* for writing an ack */
358 	struct ceph_timespec out_temp_keepalive2;  /* for writing keepalive2
359 						      stamp */
360 
361 	u32 connect_seq;      /* identify the most recent connection
362 				 attempt for this session */
363 	u32 peer_global_seq;  /* peer's global seq for this connection */
364 };
365 
366 #define CEPH_CRC_LEN			4
367 #define CEPH_GCM_KEY_LEN		16
368 #define CEPH_GCM_IV_LEN			sizeof(struct ceph_gcm_nonce)
369 #define CEPH_GCM_BLOCK_LEN		16
370 #define CEPH_GCM_TAG_LEN		16
371 
372 #define CEPH_PREAMBLE_LEN		32
373 #define CEPH_PREAMBLE_INLINE_LEN	48
374 #define CEPH_PREAMBLE_PLAIN_LEN		CEPH_PREAMBLE_LEN
375 #define CEPH_PREAMBLE_SECURE_LEN	(CEPH_PREAMBLE_LEN +		\
376 					 CEPH_PREAMBLE_INLINE_LEN +	\
377 					 CEPH_GCM_TAG_LEN)
378 #define CEPH_EPILOGUE_PLAIN_LEN		(1 + 3 * CEPH_CRC_LEN)
379 #define CEPH_EPILOGUE_SECURE_LEN	(CEPH_GCM_BLOCK_LEN + CEPH_GCM_TAG_LEN)
380 
381 #define CEPH_FRAME_MAX_SEGMENT_COUNT	4
382 
383 struct ceph_frame_desc {
384 	int fd_tag;  /* FRAME_TAG_* */
385 	int fd_seg_cnt;
386 	int fd_lens[CEPH_FRAME_MAX_SEGMENT_COUNT];  /* logical */
387 	int fd_aligns[CEPH_FRAME_MAX_SEGMENT_COUNT];
388 };
389 
390 struct ceph_gcm_nonce {
391 	__le32 fixed;
392 	__le64 counter __packed;
393 };
394 
395 struct ceph_connection_v2_info {
396 	struct iov_iter in_iter;
397 	struct kvec in_kvecs[5];  /* recvmsg */
398 	struct bio_vec in_bvec;  /* recvmsg (in_cursor) */
399 	int in_kvec_cnt;
400 	int in_state;  /* IN_S_* */
401 
402 	struct iov_iter out_iter;
403 	struct kvec out_kvecs[8];  /* sendmsg */
404 	struct bio_vec out_bvec;  /* sendpage (out_cursor, out_zero),
405 				     sendmsg (out_enc_pages) */
406 	int out_kvec_cnt;
407 	int out_state;  /* OUT_S_* */
408 
409 	int out_zero;  /* # of zero bytes to send */
410 	bool out_iter_sendpage;  /* use sendpage if possible */
411 
412 	struct ceph_frame_desc in_desc;
413 	struct ceph_msg_data_cursor in_cursor;
414 	struct ceph_msg_data_cursor out_cursor;
415 
416 	struct hmac_sha256_key hmac_key;  /* post-auth signature */
417 	bool hmac_key_set;
418 	struct crypto_aead *gcm_tfm;  /* on-wire encryption */
419 	struct aead_request *gcm_req;
420 	struct crypto_wait gcm_wait;
421 	struct ceph_gcm_nonce in_gcm_nonce;
422 	struct ceph_gcm_nonce out_gcm_nonce;
423 
424 	struct page **in_enc_pages;
425 	int in_enc_page_cnt;
426 	int in_enc_resid;
427 	int in_enc_i;
428 	struct page **out_enc_pages;
429 	int out_enc_page_cnt;
430 	int out_enc_resid;
431 	int out_enc_i;
432 
433 	int con_mode;  /* CEPH_CON_MODE_* */
434 
435 	void *conn_bufs[16];
436 	int conn_buf_cnt;
437 	int data_len_remain;
438 
439 	struct kvec in_sign_kvecs[8];
440 	struct kvec out_sign_kvecs[8];
441 	int in_sign_kvec_cnt;
442 	int out_sign_kvec_cnt;
443 
444 	u64 client_cookie;
445 	u64 server_cookie;
446 	u64 global_seq;
447 	u64 connect_seq;
448 	u64 peer_global_seq;
449 
450 	u8 in_buf[CEPH_PREAMBLE_SECURE_LEN];
451 	u8 out_buf[CEPH_PREAMBLE_SECURE_LEN];
452 	struct {
453 		u8 late_status;  /* FRAME_LATE_STATUS_* */
454 		union {
455 			struct {
456 				u32 front_crc;
457 				u32 middle_crc;
458 				u32 data_crc;
459 			} __packed;
460 			u8 pad[CEPH_GCM_BLOCK_LEN - 1];
461 		};
462 	} out_epil;
463 };
464 
465 /*
466  * A single connection with another host.
467  *
468  * We maintain a queue of outgoing messages, and some session state to
469  * ensure that we can preserve the lossless, ordered delivery of
470  * messages in the case of a TCP disconnect.
471  */
472 struct ceph_connection {
473 	void *private;
474 
475 	const struct ceph_connection_operations *ops;
476 
477 	struct ceph_messenger *msgr;
478 
479 	int state;  /* CEPH_CON_S_* */
480 	atomic_t sock_state;
481 	struct socket *sock;
482 
483 	unsigned long flags;  /* CEPH_CON_F_* */
484 	const char *error_msg;  /* error message, if any */
485 
486 	struct ceph_entity_name peer_name; /* peer name */
487 	struct ceph_entity_addr peer_addr; /* peer address */
488 	u64 peer_features;
489 
490 	struct mutex mutex;
491 
492 	/* out queue */
493 	struct list_head out_queue;
494 	struct list_head out_sent;   /* sending or sent but unacked */
495 	u64 out_seq;		     /* last message queued for send */
496 
497 	u64 in_seq, in_seq_acked;  /* last message received, acked */
498 
499 	struct ceph_msg *in_msg;
500 	struct ceph_msg *out_msg;        /* sending message (== tail of
501 					    out_sent) */
502 
503 	struct page *bounce_page;
504 	u32 in_front_crc, in_middle_crc, in_data_crc;  /* calculated crc */
505 
506 	struct timespec64 last_keepalive_ack; /* keepalive2 ack stamp */
507 
508 	struct delayed_work work;	    /* send|recv work */
509 	unsigned long       delay;          /* current delay interval */
510 
511 	union {
512 		struct ceph_connection_v1_info v1;
513 		struct ceph_connection_v2_info v2;
514 	};
515 };
516 
517 extern struct page *ceph_zero_page;
518 
519 void ceph_con_flag_clear(struct ceph_connection *con, unsigned long con_flag);
520 void ceph_con_flag_set(struct ceph_connection *con, unsigned long con_flag);
521 bool ceph_con_flag_test(struct ceph_connection *con, unsigned long con_flag);
522 bool ceph_con_flag_test_and_clear(struct ceph_connection *con,
523 				  unsigned long con_flag);
524 bool ceph_con_flag_test_and_set(struct ceph_connection *con,
525 				unsigned long con_flag);
526 
527 void ceph_encode_my_addr(struct ceph_messenger *msgr);
528 
529 int ceph_tcp_connect(struct ceph_connection *con);
530 int ceph_con_close_socket(struct ceph_connection *con);
531 void ceph_con_reset_session(struct ceph_connection *con);
532 
533 u32 ceph_get_global_seq(struct ceph_messenger *msgr, u32 gt);
534 void ceph_con_discard_sent(struct ceph_connection *con, u64 ack_seq);
535 void ceph_con_discard_requeued(struct ceph_connection *con, u64 reconnect_seq);
536 
537 void ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor,
538 			       struct ceph_msg *msg, size_t length);
539 struct page *ceph_msg_data_next(struct ceph_msg_data_cursor *cursor,
540 				size_t *page_offset, size_t *length);
541 void ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor, size_t bytes);
542 
543 u32 ceph_crc32c_page(u32 crc, struct page *page, unsigned int page_offset,
544 		     unsigned int length);
545 
546 bool ceph_addr_is_blank(const struct ceph_entity_addr *addr);
547 int ceph_addr_port(const struct ceph_entity_addr *addr);
548 void ceph_addr_set_port(struct ceph_entity_addr *addr, int p);
549 
550 void ceph_con_process_message(struct ceph_connection *con);
551 int ceph_con_in_msg_alloc(struct ceph_connection *con,
552 			  struct ceph_msg_header *hdr, int *skip);
553 struct ceph_msg *ceph_con_get_out_msg(struct ceph_connection *con);
554 
555 /* messenger_v1.c */
556 int ceph_con_v1_try_read(struct ceph_connection *con);
557 int ceph_con_v1_try_write(struct ceph_connection *con);
558 void ceph_con_v1_revoke(struct ceph_connection *con, struct ceph_msg *msg);
559 void ceph_con_v1_revoke_incoming(struct ceph_connection *con);
560 bool ceph_con_v1_opened(struct ceph_connection *con);
561 void ceph_con_v1_reset_session(struct ceph_connection *con);
562 void ceph_con_v1_reset_protocol(struct ceph_connection *con);
563 
564 /* messenger_v2.c */
565 int ceph_con_v2_try_read(struct ceph_connection *con);
566 int ceph_con_v2_try_write(struct ceph_connection *con);
567 void ceph_con_v2_revoke(struct ceph_connection *con, struct ceph_msg *msg);
568 void ceph_con_v2_revoke_incoming(struct ceph_connection *con);
569 bool ceph_con_v2_opened(struct ceph_connection *con);
570 void ceph_con_v2_reset_session(struct ceph_connection *con);
571 void ceph_con_v2_reset_protocol(struct ceph_connection *con);
572 
573 
574 extern const char *ceph_pr_addr(const struct ceph_entity_addr *addr);
575 
576 extern int ceph_parse_ips(const char *c, const char *end,
577 			  struct ceph_entity_addr *addr,
578 			  int max_count, int *count, char delim);
579 
580 extern int ceph_msgr_init(void);
581 extern void ceph_msgr_exit(void);
582 extern void ceph_msgr_flush(void);
583 
584 extern void ceph_messenger_init(struct ceph_messenger *msgr,
585 				struct ceph_entity_addr *myaddr);
586 extern void ceph_messenger_fini(struct ceph_messenger *msgr);
587 extern void ceph_messenger_reset_nonce(struct ceph_messenger *msgr);
588 
589 extern void ceph_con_init(struct ceph_connection *con, void *private,
590 			const struct ceph_connection_operations *ops,
591 			struct ceph_messenger *msgr);
592 extern void ceph_con_open(struct ceph_connection *con,
593 			  __u8 entity_type, __u64 entity_num,
594 			  struct ceph_entity_addr *addr);
595 extern bool ceph_con_opened(struct ceph_connection *con);
596 extern void ceph_con_close(struct ceph_connection *con);
597 extern void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg);
598 
599 extern void ceph_msg_revoke(struct ceph_msg *msg);
600 extern void ceph_msg_revoke_incoming(struct ceph_msg *msg);
601 
602 extern void ceph_con_keepalive(struct ceph_connection *con);
603 extern bool ceph_con_keepalive_expired(struct ceph_connection *con,
604 				       unsigned long interval);
605 
606 void ceph_msg_data_add_pages(struct ceph_msg *msg, struct page **pages,
607 			     size_t length, size_t alignment, bool own_pages);
608 extern void ceph_msg_data_add_pagelist(struct ceph_msg *msg,
609 				struct ceph_pagelist *pagelist);
610 #ifdef CONFIG_BLOCK
611 void ceph_msg_data_add_bio(struct ceph_msg *msg, struct ceph_bio_iter *bio_pos,
612 			   u32 length);
613 #endif /* CONFIG_BLOCK */
614 void ceph_msg_data_add_bvecs(struct ceph_msg *msg,
615 			     struct ceph_bvec_iter *bvec_pos);
616 void ceph_msg_data_add_iter(struct ceph_msg *msg,
617 			    struct iov_iter *iter);
618 
619 struct ceph_msg *ceph_msg_new2(int type, int front_len, int max_data_items,
620 			       gfp_t flags, bool can_fail);
621 extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
622 				     bool can_fail);
623 
624 extern struct ceph_msg *ceph_msg_get(struct ceph_msg *msg);
625 extern void ceph_msg_put(struct ceph_msg *msg);
626 
627 extern void ceph_msg_dump(struct ceph_msg *msg);
628 
629 #endif
630