blob: 9e50aede46c8327bec9309b2ad21eb1ecff2c711 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sage Weil5cd068c2010-07-07 08:38:17 -07002#ifndef CEPH_MSGR_H
3#define CEPH_MSGR_H
Sage Weil0dee3c22009-10-06 11:31:06 -07004
5/*
6 * Data types for message passing layer used by Ceph.
7 */
8
9#define CEPH_MON_PORT 6789 /* default monitor port */
10
11/*
12 * client-side processes will try to bind to ports in this
13 * range, simply for the benefit of tools like nmap or wireshark
14 * that would like to identify the protocol.
15 */
16#define CEPH_PORT_FIRST 6789
17#define CEPH_PORT_START 6800 /* non-monitors start here */
18#define CEPH_PORT_LAST 6900
19
20/*
21 * tcp connection banner. include a protocol version. and adjust
22 * whenever the wire protocol changes. try to keep this string length
23 * constant.
24 */
Sage Weilac8839d2010-01-27 14:28:10 -080025#define CEPH_BANNER "ceph v027"
Sage Weil0dee3c22009-10-06 11:31:06 -070026#define CEPH_BANNER_MAX_LEN 30
27
28
29/*
30 * Rollover-safe type and comparator for 32-bit sequence numbers.
31 * Comparator returns -1, 0, or 1.
32 */
33typedef __u32 ceph_seq_t;
34
35static inline __s32 ceph_seq_cmp(__u32 a, __u32 b)
36{
37 return (__s32)a - (__s32)b;
38}
39
40
41/*
42 * entity_name -- logical name for a process participating in the
43 * network, e.g. 'mds0' or 'osd3'.
44 */
45struct ceph_entity_name {
46 __u8 type; /* CEPH_ENTITY_TYPE_* */
47 __le64 num;
48} __attribute__ ((packed));
49
Sage Weil4e7a5dc2009-11-18 16:19:57 -080050#define CEPH_ENTITY_TYPE_MON 0x01
51#define CEPH_ENTITY_TYPE_MDS 0x02
52#define CEPH_ENTITY_TYPE_OSD 0x04
53#define CEPH_ENTITY_TYPE_CLIENT 0x08
Sage Weil4e7a5dc2009-11-18 16:19:57 -080054#define CEPH_ENTITY_TYPE_AUTH 0x20
55
56#define CEPH_ENTITY_TYPE_ANY 0xFF
57
58extern const char *ceph_entity_type_name(int type);
Sage Weil0dee3c22009-10-06 11:31:06 -070059
60/*
61 * entity_addr -- network address
62 */
63struct ceph_entity_addr {
Sage Weilac8839d2010-01-27 14:28:10 -080064 __le32 type;
65 __le32 nonce; /* unique id for process (e.g. pid) */
Sage Weil0dee3c22009-10-06 11:31:06 -070066 struct sockaddr_storage in_addr;
67} __attribute__ ((packed));
68
Sage Weil0dee3c22009-10-06 11:31:06 -070069struct ceph_entity_inst {
70 struct ceph_entity_name name;
71 struct ceph_entity_addr addr;
72} __attribute__ ((packed));
73
74
75/* used by message exchange protocol */
76#define CEPH_MSGR_TAG_READY 1 /* server->client: ready for messages */
77#define CEPH_MSGR_TAG_RESETSESSION 2 /* server->client: reset, try again */
78#define CEPH_MSGR_TAG_WAIT 3 /* server->client: wait for racing
79 incoming connection */
80#define CEPH_MSGR_TAG_RETRY_SESSION 4 /* server->client + cseq: try again
81 with higher cseq */
82#define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again
83 with higher gseq */
84#define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */
85#define CEPH_MSGR_TAG_MSG 7 /* message */
86#define CEPH_MSGR_TAG_ACK 8 /* message ack */
87#define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */
Yan, Zheng8b9558a2015-09-01 17:19:38 +080088#define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */
Sage Weil4e7a5dc2009-11-18 16:19:57 -080089#define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
Sage Weil04a419f2009-12-23 09:30:21 -080090#define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */
Sage Weil3a230832013-03-25 08:47:40 -070091#define CEPH_MSGR_TAG_SEQ 13 /* 64-bit int follows with seen seq number */
Yan, Zheng8b9558a2015-09-01 17:19:38 +080092#define CEPH_MSGR_TAG_KEEPALIVE2 14 /* keepalive2 byte + ceph_timespec */
93#define CEPH_MSGR_TAG_KEEPALIVE2_ACK 15 /* keepalive2 reply */
Ilya Dryomov6daca132018-07-27 19:18:34 +020094#define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16 /* cephx v2 doing server challenge */
Sage Weil0dee3c22009-10-06 11:31:06 -070095
96/*
97 * connection negotiation
98 */
99struct ceph_msg_connect {
Sage Weil04a419f2009-12-23 09:30:21 -0800100 __le64 features; /* supported feature bits */
Sage Weil0dee3c22009-10-06 11:31:06 -0700101 __le32 host_type; /* CEPH_ENTITY_TYPE_* */
102 __le32 global_seq; /* count connections initiated by this host */
103 __le32 connect_seq; /* count connections initiated in this session */
104 __le32 protocol_version;
Sage Weil4e7a5dc2009-11-18 16:19:57 -0800105 __le32 authorizer_protocol;
106 __le32 authorizer_len;
Sage Weil0dee3c22009-10-06 11:31:06 -0700107 __u8 flags; /* CEPH_MSG_CONNECT_* */
108} __attribute__ ((packed));
109
110struct ceph_msg_connect_reply {
111 __u8 tag;
Sage Weil04a419f2009-12-23 09:30:21 -0800112 __le64 features; /* feature bits for this session */
Sage Weil0dee3c22009-10-06 11:31:06 -0700113 __le32 global_seq;
114 __le32 connect_seq;
115 __le32 protocol_version;
Sage Weil4e7a5dc2009-11-18 16:19:57 -0800116 __le32 authorizer_len;
Sage Weil0dee3c22009-10-06 11:31:06 -0700117 __u8 flags;
118} __attribute__ ((packed));
119
120#define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */
121
122
123/*
124 * message header
125 */
Sage Weildbad1852010-03-25 15:45:38 -0700126struct ceph_msg_header_old {
Sage Weil0dee3c22009-10-06 11:31:06 -0700127 __le64 seq; /* message seq# for this session */
Sage Weil6df058c2009-12-22 11:24:33 -0800128 __le64 tid; /* transaction id */
Sage Weil0dee3c22009-10-06 11:31:06 -0700129 __le16 type; /* message type */
130 __le16 priority; /* priority. higher value == higher priority */
Sage Weil535bbb52009-10-13 12:55:26 -0700131 __le16 version; /* version of message encoding */
Sage Weil0dee3c22009-10-06 11:31:06 -0700132
133 __le32 front_len; /* bytes in main payload */
134 __le32 middle_len;/* bytes in middle payload */
135 __le32 data_len; /* bytes of data payload */
136 __le16 data_off; /* sender: include full offset;
137 receiver: mask against ~PAGE_MASK */
138
139 struct ceph_entity_inst src, orig_src;
Sage Weil103e2d32010-01-07 16:12:36 -0800140 __le32 reserved;
Sage Weil0dee3c22009-10-06 11:31:06 -0700141 __le32 crc; /* header crc32c */
142} __attribute__ ((packed));
143
Sage Weildbad1852010-03-25 15:45:38 -0700144struct ceph_msg_header {
145 __le64 seq; /* message seq# for this session */
146 __le64 tid; /* transaction id */
147 __le16 type; /* message type */
148 __le16 priority; /* priority. higher value == higher priority */
149 __le16 version; /* version of message encoding */
150
151 __le32 front_len; /* bytes in main payload */
152 __le32 middle_len;/* bytes in middle payload */
153 __le32 data_len; /* bytes of data payload */
154 __le16 data_off; /* sender: include full offset;
155 receiver: mask against ~PAGE_MASK */
156
157 struct ceph_entity_name src;
John Sprayd4e1a4e2014-10-16 12:05:34 +0100158 __le16 compat_version;
159 __le16 reserved;
Sage Weildbad1852010-03-25 15:45:38 -0700160 __le32 crc; /* header crc32c */
161} __attribute__ ((packed));
162
Sage Weil0dee3c22009-10-06 11:31:06 -0700163#define CEPH_MSG_PRIO_LOW 64
164#define CEPH_MSG_PRIO_DEFAULT 127
165#define CEPH_MSG_PRIO_HIGH 196
166#define CEPH_MSG_PRIO_HIGHEST 255
167
168/*
169 * follows data payload
170 */
Yan, Zheng33d07332014-11-04 16:33:37 +0800171struct ceph_msg_footer_old {
172 __le32 front_crc, middle_crc, data_crc;
173 __u8 flags;
174} __attribute__ ((packed));
175
Sage Weil0dee3c22009-10-06 11:31:06 -0700176struct ceph_msg_footer {
177 __le32 front_crc, middle_crc, data_crc;
Yan, Zheng33d07332014-11-04 16:33:37 +0800178 // sig holds the 64 bits of the digital signature for the message PLR
179 __le64 sig;
Sage Weil0dee3c22009-10-06 11:31:06 -0700180 __u8 flags;
181} __attribute__ ((packed));
182
183#define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */
184#define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */
Yan, Zheng33d07332014-11-04 16:33:37 +0800185#define CEPH_MSG_FOOTER_SIGNED (1<<2) /* msg was signed */
Sage Weil0dee3c22009-10-06 11:31:06 -0700186
187
188#endif