corosync
totem.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 MontaVista Software, Inc.
3 * Copyright (c) 2006-2022 Red Hat, Inc.
4 *
5 * Author: Steven Dake (sdake@redhat.com)
6 *
7 * All rights reserved.
8 *
9 * This software licensed under BSD license, the text of which follows:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * - Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * - Neither the name of the MontaVista Software, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived from this
21 * software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
34 */
35#ifndef TOTEM_H_DEFINED
36#define TOTEM_H_DEFINED
37#include "totemip.h"
38#include <libknet.h>
39#include <corosync/hdb.h>
41
42#ifdef HAVE_SMALL_MEMORY_FOOTPRINT
43#define PROCESSOR_COUNT_MAX 16
44#define MESSAGE_SIZE_MAX 1024*64
45#define MESSAGE_QUEUE_MAX 512
46#else
47#define PROCESSOR_COUNT_MAX 384
48#define MESSAGE_SIZE_MAX 1024*1024 /* (1MB) */
49#define MESSAGE_QUEUE_MAX ((4 * MESSAGE_SIZE_MAX) / totem_config->net_mtu)
50#endif /* HAVE_SMALL_MEMORY_FOOTPRINT */
51
52#define FRAME_SIZE_MAX KNET_MAX_PACKET_SIZE
53
54#define CONFIG_STRING_LEN_MAX 128
55/*
56 * Estimation of required buffer size for totemudp and totemudpu - it should be at least
57 * sizeof(memb_join) + PROCESSOR_MAX * 2 * sizeof(srp_addr))
58 * if we want to support PROCESSOR_MAX nodes, but because we don't have
59 * srp_addr and memb_join, we have to use estimation.
60 * TODO: Consider moving srp_addr/memb_join into totem headers instead of totemsrp.c
61 */
62#define UDP_RECEIVE_FRAME_SIZE_MAX (PROCESSOR_COUNT_MAX * (INTERFACE_MAX * 2 * sizeof(struct totem_ip_address)) + 1024)
63
64#define TRANSMITS_ALLOWED 16
65#define SEND_THREADS_MAX 16
66
67/* This must be <= KNET_MAX_LINK */
68#define INTERFACE_MAX 8
69
70#define BIND_MAX_RETRIES 10
71#define BIND_RETRIES_INTERVAL 100
72
76#define MAX_NO_CONT_GATHER 3
77/*
78 * Maximum number of continuous failures get from sendmsg call
79 */
80#define MAX_NO_CONT_SENDMSG_FAILURES 30
81
99
102 int level,
103 int subsys,
104 const char *function_name,
105 const char *file_name,
106 int file_line,
107 const char *format,
108 ...) __attribute__((format(printf, 6, 7)));
109
117};
118
119
120/*
121 * COrosync TOtem. Also used as an endian_detector.
122 */
123#define TOTEM_MH_MAGIC 0xC070
124#define TOTEM_MH_VERSION 0x03
125
127 unsigned short magic;
129 char type;
131 unsigned int nodeid;
132 unsigned int target_nodeid;
134
135enum {
139
141
142
143/*
144 * Keep compatibility with old applications. For Corosync 4.0, remove
145 * TOTEM_TRANSPORT_UDP/TOTEM_TRANSPORT_UDPU, set TOTEM_TRANSPORT_KNET to 1
146 * and change totemnet.c
147 */
153
154#define MEMB_RING_ID
155struct memb_ring_id {
156 unsigned int rep;
157 unsigned long long seq;
159
164
167
168 /*
169 * network
170 */
172 struct totem_interface *orig_interfaces; /* for reload */
173 unsigned int node_id;
176 unsigned int knet_mtu;
177
178 /*
179 * key information
180 */
182
183 unsigned int private_key_len;
184
185 /*
186 * Totem configuration parameters
187 */
188 unsigned int token_timeout;
189
190 unsigned int token_warning;
191
193
194 unsigned int token_hold_timeout;
195
197
198 unsigned int join_timeout;
199
200 unsigned int send_join_timeout;
201
202 unsigned int consensus_timeout;
203
204 unsigned int merge_timeout;
205
206 unsigned int downcheck_timeout;
207
208 unsigned int fail_to_recv_const;
209
211
213
215
216 unsigned int net_mtu;
217
218 unsigned int threads;
219
221
222 unsigned int max_network_delay;
223
224 unsigned int window_size;
225
226 unsigned int max_messages;
227
228 unsigned int broadcast_use;
229
231
233
235
236 int crypto_index; /* Num of crypto config currently loaded into knet ( 1 or 2 ) */
237
238 int crypto_changed; /* Has crypto changed since last time? (it's expensive to reload) */
239
241
243
245
247
248 unsigned int miss_count_const;
249
251
252 unsigned int block_unlisted_ips;
253
255
256 unsigned char ip_dscp;
257
260 unsigned int nodeid);
261
263 const struct memb_ring_id *memb_ring_id,
264 unsigned int nodeid);
265};
266
267/*
268 * Node status returned from the API
269 * Usually the same as the cfg version (except for
270 * link_status)
271 */
272#define TOTEM_NODE_STATUS_STRUCTURE_VERSION 1
284
285
286#define TOTEM_CONFIGURATION_TYPE
291
292#define TOTEM_CALLBACK_TOKEN_TYPE
297
302
303#endif /* TOTEM_H_DEFINED */
totem_configuration_type
The totem_configuration_type enum.
Definition coroapi.h:132
totem_callback_token_type
The totem_callback_token_type enum.
Definition coroapi.h:142
The memb_ring_id struct.
Definition coroapi.h:122
unsigned long long seq
Definition coroapi.h:124
unsigned int rep
Definition totem.h:156
char crypto_model[CONFIG_STRING_LEN_MAX]
Definition totem.h:230
unsigned int max_messages
Definition totem.h:226
unsigned int heartbeat_failures_allowed
Definition totem.h:220
unsigned int token_timeout
Definition totem.h:188
unsigned int private_key_len
Definition totem.h:183
unsigned int knet_mtu
Definition totem.h:176
unsigned int node_id
Definition totem.h:173
unsigned int broadcast_use
Definition totem.h:228
uint32_t knet_compression_threshold
Definition totem.h:242
unsigned int window_size
Definition totem.h:224
unsigned int downcheck_timeout
Definition totem.h:206
unsigned int miss_count_const
Definition totem.h:248
totem_transport_t transport_number
Definition totem.h:246
struct totem_interface * interfaces
Definition totem.h:171
int crypto_changed
Definition totem.h:238
unsigned int cancel_token_hold_on_retransmit
Definition totem.h:254
unsigned int fail_to_recv_const
Definition totem.h:208
unsigned int clear_node_high_bit
Definition totem.h:174
unsigned int merge_timeout
Definition totem.h:204
struct totem_interface * orig_interfaces
Definition totem.h:172
unsigned char ip_dscp
Definition totem.h:256
int knet_compression_level
Definition totem.h:244
unsigned int net_mtu
Definition totem.h:216
void(* totem_memb_ring_id_create_or_load)(struct memb_ring_id *memb_ring_id, unsigned int nodeid)
Definition totem.h:258
int version
Definition totem.h:166
char knet_compression_model[CONFIG_STRING_LEN_MAX]
Definition totem.h:240
unsigned int block_unlisted_ips
Definition totem.h:252
unsigned int token_retransmits_before_loss_const
Definition totem.h:196
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN_MAX]
Definition totem.h:181
int crypto_index
Definition totem.h:236
unsigned int max_network_delay
Definition totem.h:222
unsigned int seqno_unchanged_const
Definition totem.h:210
unsigned int consensus_timeout
Definition totem.h:202
unsigned int knet_pmtud_interval
Definition totem.h:175
char crypto_cipher_type[CONFIG_STRING_LEN_MAX]
Definition totem.h:232
unsigned int threads
Definition totem.h:218
unsigned int send_join_timeout
Definition totem.h:200
char link_mode[TOTEM_LINK_MODE_BYTES]
Definition totem.h:212
enum totem_ip_version_enum ip_version
Definition totem.h:250
void(* totem_memb_ring_id_store)(const struct memb_ring_id *memb_ring_id, unsigned int nodeid)
Definition totem.h:262
unsigned int token_retransmit_timeout
Definition totem.h:192
char crypto_hash_type[CONFIG_STRING_LEN_MAX]
Definition totem.h:234
unsigned int token_warning
Definition totem.h:190
unsigned int join_timeout
Definition totem.h:198
unsigned int token_hold_timeout
Definition totem.h:194
struct totem_ip_address local_ip
Definition totem.h:86
int knet_ping_timeout
Definition totem.h:93
int knet_link_priority
Definition totem.h:91
struct totem_ip_address boundto
Definition totem.h:84
uint16_t ip_port
Definition totem.h:87
int knet_ping_interval
Definition totem.h:92
uint8_t configured
Definition totem.h:89
int knet_ping_precision
Definition totem.h:94
int knet_pong_count
Definition totem.h:95
int knet_transport
Definition totem.h:96
int member_count
Definition totem.h:90
struct totem_ip_address bindnet
Definition totem.h:83
struct totem_ip_address member_list[PROCESSOR_COUNT_MAX]
Definition totem.h:97
uint16_t ttl
Definition totem.h:88
struct totem_ip_address mcast_addr
Definition totem.h:85
The totem_ip_address struct.
Definition coroapi.h:111
void(* log_printf)(int level, int subsys, const char *function_name, const char *file_name, int file_line, const char *format,...) __attribute__((format(printf
Definition totem.h:101
void(*) in log_level_security)
Definition totem.h:110
unsigned int target_nodeid
Definition totem.h:132
unsigned int nodeid
Definition totem.h:131
unsigned short magic
Definition totem.h:127
uint8_t onwire_max
Definition totem.h:280
uint8_t reachable
Definition totem.h:276
uint8_t remote
Definition totem.h:277
unsigned int nodeid
Definition totem.h:275
uint8_t onwire_min
Definition totem.h:279
uint8_t onwire_ver
Definition totem.h:281
uint32_t version
Definition totem.h:274
uint8_t external
Definition totem.h:278
struct knet_link_status link_status[KNET_MAX_LINK]
Definition totem.h:282
@ TOTEM_LINK_MODE_BYTES
Definition totem.h:140
typedef __attribute__
@ TOTEM_CONFIGURATION_REGULAR
Definition totem.h:288
@ TOTEM_CONFIGURATION_TRANSITIONAL
Definition totem.h:289
totem_event_type
Definition totem.h:298
@ TOTEM_EVENT_NEW_MSG
Definition totem.h:300
@ TOTEM_EVENT_DELIVERY_CONGESTED
Definition totem.h:299
unsigned int nodeid
Definition totem.h:4
@ TOTEM_PRIVATE_KEY_LEN_MAX
Definition totem.h:137
@ TOTEM_PRIVATE_KEY_LEN_MIN
Definition totem.h:136
cfg_message_crypto_reconfig_phase_t
Definition totem.h:160
@ CRYPTO_RECONFIG_PHASE_CLEANUP
Definition totem.h:162
@ CRYPTO_RECONFIG_PHASE_ACTIVATE
Definition totem.h:161
@ TOTEM_CALLBACK_TOKEN_SENT
Definition totem.h:295
@ TOTEM_CALLBACK_TOKEN_RECEIVED
Definition totem.h:294
#define CONFIG_STRING_LEN_MAX
Definition totem.h:54
totem_transport_t
Definition totem.h:148
@ TOTEM_TRANSPORT_UDPU
Definition totem.h:150
@ TOTEM_TRANSPORT_KNET
Definition totem.h:151
@ TOTEM_TRANSPORT_UDP
Definition totem.h:149
#define PROCESSOR_COUNT_MAX
Definition totem.h:47
totem_ip_version_enum
Definition totemip.h:70