1 /* SPDX-License-Identifier: GPL-2.0 */
6 * Data types for message passing layer used by Ceph.
9 #define CEPH_MON_PORT 6789 /* default monitor port */
12 * tcp connection banner. include a protocol version. and adjust
13 * whenever the wire protocol changes. try to keep this string length
16 #define CEPH_BANNER "ceph v027"
17 #define CEPH_BANNER_MAX_LEN 30
21 * Rollover-safe type and comparator for 32-bit sequence numbers.
22 * Comparator returns -1, 0, or 1.
24 typedef __u32 ceph_seq_t;
26 static inline __s32 ceph_seq_cmp(__u32 a, __u32 b)
28 return (__s32)a - (__s32)b;
33 * entity_name -- logical name for a process participating in the
34 * network, e.g. 'mds0' or 'osd3'.
36 struct ceph_entity_name {
37 __u8 type; /* CEPH_ENTITY_TYPE_* */
39 } __attribute__ ((packed));
41 #define CEPH_ENTITY_TYPE_MON 0x01
42 #define CEPH_ENTITY_TYPE_MDS 0x02
43 #define CEPH_ENTITY_TYPE_OSD 0x04
44 #define CEPH_ENTITY_TYPE_CLIENT 0x08
45 #define CEPH_ENTITY_TYPE_AUTH 0x20
47 #define CEPH_ENTITY_TYPE_ANY 0xFF
49 extern const char *ceph_entity_type_name(int type);
52 * entity_addr -- network address
54 struct ceph_entity_addr {
55 __le32 type; /* CEPH_ENTITY_ADDR_TYPE_* */
56 __le32 nonce; /* unique id for process (e.g. pid) */
57 struct sockaddr_storage in_addr;
58 } __attribute__ ((packed));
60 static inline bool ceph_addr_equal_no_type(const struct ceph_entity_addr *lhs,
61 const struct ceph_entity_addr *rhs)
63 return !memcmp(&lhs->in_addr, &rhs->in_addr, sizeof(lhs->in_addr)) &&
64 lhs->nonce == rhs->nonce;
67 struct ceph_entity_inst {
68 struct ceph_entity_name name;
69 struct ceph_entity_addr addr;
70 } __attribute__ ((packed));
73 /* used by message exchange protocol */
74 #define CEPH_MSGR_TAG_READY 1 /* server->client: ready for messages */
75 #define CEPH_MSGR_TAG_RESETSESSION 2 /* server->client: reset, try again */
76 #define CEPH_MSGR_TAG_WAIT 3 /* server->client: wait for racing
77 incoming connection */
78 #define CEPH_MSGR_TAG_RETRY_SESSION 4 /* server->client + cseq: try again
80 #define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again
82 #define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */
83 #define CEPH_MSGR_TAG_MSG 7 /* message */
84 #define CEPH_MSGR_TAG_ACK 8 /* message ack */
85 #define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */
86 #define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */
87 #define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
88 #define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */
89 #define CEPH_MSGR_TAG_SEQ 13 /* 64-bit int follows with seen seq number */
90 #define CEPH_MSGR_TAG_KEEPALIVE2 14 /* keepalive2 byte + ceph_timespec */
91 #define CEPH_MSGR_TAG_KEEPALIVE2_ACK 15 /* keepalive2 reply */
92 #define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16 /* cephx v2 doing server challenge */
95 * connection negotiation
97 struct ceph_msg_connect {
98 __le64 features; /* supported feature bits */
99 __le32 host_type; /* CEPH_ENTITY_TYPE_* */
100 __le32 global_seq; /* count connections initiated by this host */
101 __le32 connect_seq; /* count connections initiated in this session */
102 __le32 protocol_version;
103 __le32 authorizer_protocol;
104 __le32 authorizer_len;
105 __u8 flags; /* CEPH_MSG_CONNECT_* */
106 } __attribute__ ((packed));
108 struct ceph_msg_connect_reply {
110 __le64 features; /* feature bits for this session */
113 __le32 protocol_version;
114 __le32 authorizer_len;
116 } __attribute__ ((packed));
118 #define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */
124 struct ceph_msg_header_old {
125 __le64 seq; /* message seq# for this session */
126 __le64 tid; /* transaction id */
127 __le16 type; /* message type */
128 __le16 priority; /* priority. higher value == higher priority */
129 __le16 version; /* version of message encoding */
131 __le32 front_len; /* bytes in main payload */
132 __le32 middle_len;/* bytes in middle payload */
133 __le32 data_len; /* bytes of data payload */
134 __le16 data_off; /* sender: include full offset;
135 receiver: mask against ~PAGE_MASK */
137 struct ceph_entity_inst src, orig_src;
139 __le32 crc; /* header crc32c */
140 } __attribute__ ((packed));
142 struct ceph_msg_header {
143 __le64 seq; /* message seq# for this session */
144 __le64 tid; /* transaction id */
145 __le16 type; /* message type */
146 __le16 priority; /* priority. higher value == higher priority */
147 __le16 version; /* version of message encoding */
149 __le32 front_len; /* bytes in main payload */
150 __le32 middle_len;/* bytes in middle payload */
151 __le32 data_len; /* bytes of data payload */
152 __le16 data_off; /* sender: include full offset;
153 receiver: mask against ~PAGE_MASK */
155 struct ceph_entity_name src;
156 __le16 compat_version;
158 __le32 crc; /* header crc32c */
159 } __attribute__ ((packed));
161 #define CEPH_MSG_PRIO_LOW 64
162 #define CEPH_MSG_PRIO_DEFAULT 127
163 #define CEPH_MSG_PRIO_HIGH 196
164 #define CEPH_MSG_PRIO_HIGHEST 255
167 * follows data payload
169 struct ceph_msg_footer_old {
170 __le32 front_crc, middle_crc, data_crc;
172 } __attribute__ ((packed));
174 struct ceph_msg_footer {
175 __le32 front_crc, middle_crc, data_crc;
176 // sig holds the 64 bits of the digital signature for the message PLR
179 } __attribute__ ((packed));
181 #define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */
182 #define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */
183 #define CEPH_MSG_FOOTER_SIGNED (1<<2) /* msg was signed */