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 {
56 __le32 nonce; /* unique id for process (e.g. pid) */
57 struct sockaddr_storage in_addr;
58 } __attribute__ ((packed));
60 struct ceph_entity_inst {
61 struct ceph_entity_name name;
62 struct ceph_entity_addr addr;
63 } __attribute__ ((packed));
66 /* used by message exchange protocol */
67 #define CEPH_MSGR_TAG_READY 1 /* server->client: ready for messages */
68 #define CEPH_MSGR_TAG_RESETSESSION 2 /* server->client: reset, try again */
69 #define CEPH_MSGR_TAG_WAIT 3 /* server->client: wait for racing
70 incoming connection */
71 #define CEPH_MSGR_TAG_RETRY_SESSION 4 /* server->client + cseq: try again
73 #define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again
75 #define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */
76 #define CEPH_MSGR_TAG_MSG 7 /* message */
77 #define CEPH_MSGR_TAG_ACK 8 /* message ack */
78 #define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */
79 #define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */
80 #define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
81 #define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */
82 #define CEPH_MSGR_TAG_SEQ 13 /* 64-bit int follows with seen seq number */
83 #define CEPH_MSGR_TAG_KEEPALIVE2 14 /* keepalive2 byte + ceph_timespec */
84 #define CEPH_MSGR_TAG_KEEPALIVE2_ACK 15 /* keepalive2 reply */
85 #define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16 /* cephx v2 doing server challenge */
88 * connection negotiation
90 struct ceph_msg_connect {
91 __le64 features; /* supported feature bits */
92 __le32 host_type; /* CEPH_ENTITY_TYPE_* */
93 __le32 global_seq; /* count connections initiated by this host */
94 __le32 connect_seq; /* count connections initiated in this session */
95 __le32 protocol_version;
96 __le32 authorizer_protocol;
97 __le32 authorizer_len;
98 __u8 flags; /* CEPH_MSG_CONNECT_* */
99 } __attribute__ ((packed));
101 struct ceph_msg_connect_reply {
103 __le64 features; /* feature bits for this session */
106 __le32 protocol_version;
107 __le32 authorizer_len;
109 } __attribute__ ((packed));
111 #define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */
117 struct ceph_msg_header_old {
118 __le64 seq; /* message seq# for this session */
119 __le64 tid; /* transaction id */
120 __le16 type; /* message type */
121 __le16 priority; /* priority. higher value == higher priority */
122 __le16 version; /* version of message encoding */
124 __le32 front_len; /* bytes in main payload */
125 __le32 middle_len;/* bytes in middle payload */
126 __le32 data_len; /* bytes of data payload */
127 __le16 data_off; /* sender: include full offset;
128 receiver: mask against ~PAGE_MASK */
130 struct ceph_entity_inst src, orig_src;
132 __le32 crc; /* header crc32c */
133 } __attribute__ ((packed));
135 struct ceph_msg_header {
136 __le64 seq; /* message seq# for this session */
137 __le64 tid; /* transaction id */
138 __le16 type; /* message type */
139 __le16 priority; /* priority. higher value == higher priority */
140 __le16 version; /* version of message encoding */
142 __le32 front_len; /* bytes in main payload */
143 __le32 middle_len;/* bytes in middle payload */
144 __le32 data_len; /* bytes of data payload */
145 __le16 data_off; /* sender: include full offset;
146 receiver: mask against ~PAGE_MASK */
148 struct ceph_entity_name src;
149 __le16 compat_version;
151 __le32 crc; /* header crc32c */
152 } __attribute__ ((packed));
154 #define CEPH_MSG_PRIO_LOW 64
155 #define CEPH_MSG_PRIO_DEFAULT 127
156 #define CEPH_MSG_PRIO_HIGH 196
157 #define CEPH_MSG_PRIO_HIGHEST 255
160 * follows data payload
162 struct ceph_msg_footer_old {
163 __le32 front_crc, middle_crc, data_crc;
165 } __attribute__ ((packed));
167 struct ceph_msg_footer {
168 __le32 front_crc, middle_crc, data_crc;
169 // sig holds the 64 bits of the digital signature for the message PLR
172 } __attribute__ ((packed));
174 #define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */
175 #define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */
176 #define CEPH_MSG_FOOTER_SIGNED (1<<2) /* msg was signed */