corosync 3.1.7
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
87 uint16_t ip_port;
88 uint16_t ttl;
89 uint8_t configured;
98};
99
101 void (*log_printf) (
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;
133} __attribute__((packed));
134
135enum {
136 TOTEM_PRIVATE_KEY_LEN_MIN = KNET_MIN_KEY_LEN,
137 TOTEM_PRIVATE_KEY_LEN_MAX = KNET_MAX_KEY_LEN
139
141
142typedef enum {
147
148#define MEMB_RING_ID
149struct memb_ring_id {
150 unsigned int rep;
151 unsigned long long seq;
152} __attribute__((packed));
153
154typedef enum {
158
161
162 /*
163 * network
164 */
166 struct totem_interface *orig_interfaces; /* for reload */
167 unsigned int node_id;
170 unsigned int knet_mtu;
171
172 /*
173 * key information
174 */
176
177 unsigned int private_key_len;
178
179 /*
180 * Totem configuration parameters
181 */
182 unsigned int token_timeout;
183
184 unsigned int token_warning;
185
187
188 unsigned int token_hold_timeout;
189
191
192 unsigned int join_timeout;
193
194 unsigned int send_join_timeout;
195
196 unsigned int consensus_timeout;
197
198 unsigned int merge_timeout;
199
200 unsigned int downcheck_timeout;
201
202 unsigned int fail_to_recv_const;
203
205
207
209
210 unsigned int net_mtu;
211
212 unsigned int threads;
213
215
216 unsigned int max_network_delay;
217
218 unsigned int window_size;
219
220 unsigned int max_messages;
221
222 unsigned int broadcast_use;
223
225
227
229
230 int crypto_index; /* Num of crypto config currently loaded into knet ( 1 or 2 ) */
231
232 int crypto_changed; /* Has crypto changed since last time? (it's expensive to reload) */
233
235
237
239
241
242 unsigned int miss_count_const;
243
245
246 unsigned int block_unlisted_ips;
247
249
252 unsigned int nodeid);
253
255 const struct memb_ring_id *memb_ring_id,
256 unsigned int nodeid);
257};
258
259/*
260 * Node status returned from the API
261 * Usually the same as the cfg version (except for
262 * link_status)
263 */
264#define TOTEM_NODE_STATUS_STRUCTURE_VERSION 1
266 uint32_t version; /* Structure version */
267 unsigned int nodeid;
268 uint8_t reachable;
269 uint8_t remote;
270 uint8_t external;
271 uint8_t onwire_min;
272 uint8_t onwire_max;
273 uint8_t onwire_ver;
274 struct knet_link_status link_status[KNET_MAX_LINK];
275};
276
277
278#define TOTEM_CONFIGURATION_TYPE
283
284#define TOTEM_CALLBACK_TOKEN_TYPE
289
293};
294
295#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:150
char crypto_model[CONFIG_STRING_LEN_MAX]
Definition: totem.h:224
unsigned int max_messages
Definition: totem.h:220
unsigned int heartbeat_failures_allowed
Definition: totem.h:214
unsigned int token_timeout
Definition: totem.h:182
unsigned int private_key_len
Definition: totem.h:177
unsigned int knet_mtu
Definition: totem.h:170
unsigned int node_id
Definition: totem.h:167
unsigned int broadcast_use
Definition: totem.h:222
uint32_t knet_compression_threshold
Definition: totem.h:236
unsigned int window_size
Definition: totem.h:218
unsigned int downcheck_timeout
Definition: totem.h:200
unsigned int miss_count_const
Definition: totem.h:242
totem_transport_t transport_number
Definition: totem.h:240
struct totem_interface * interfaces
Definition: totem.h:165
int crypto_changed
Definition: totem.h:232
unsigned int cancel_token_hold_on_retransmit
Definition: totem.h:248
unsigned int fail_to_recv_const
Definition: totem.h:202
unsigned int clear_node_high_bit
Definition: totem.h:168
unsigned int merge_timeout
Definition: totem.h:198
struct totem_interface * orig_interfaces
Definition: totem.h:166
int knet_compression_level
Definition: totem.h:238
unsigned int net_mtu
Definition: totem.h:210
void(* totem_memb_ring_id_create_or_load)(struct memb_ring_id *memb_ring_id, unsigned int nodeid)
Definition: totem.h:250
int version
Definition: totem.h:160
char knet_compression_model[CONFIG_STRING_LEN_MAX]
Definition: totem.h:234
unsigned int block_unlisted_ips
Definition: totem.h:246
unsigned int token_retransmits_before_loss_const
Definition: totem.h:190
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN_MAX]
Definition: totem.h:175
int crypto_index
Definition: totem.h:230
unsigned int max_network_delay
Definition: totem.h:216
unsigned int seqno_unchanged_const
Definition: totem.h:204
unsigned int consensus_timeout
Definition: totem.h:196
unsigned int knet_pmtud_interval
Definition: totem.h:169
char crypto_cipher_type[CONFIG_STRING_LEN_MAX]
Definition: totem.h:226
unsigned int threads
Definition: totem.h:212
unsigned int send_join_timeout
Definition: totem.h:194
char link_mode[TOTEM_LINK_MODE_BYTES]
Definition: totem.h:206
enum totem_ip_version_enum ip_version
Definition: totem.h:244
void(* totem_memb_ring_id_store)(const struct memb_ring_id *memb_ring_id, unsigned int nodeid)
Definition: totem.h:254
unsigned int token_retransmit_timeout
Definition: totem.h:186
char crypto_hash_type[CONFIG_STRING_LEN_MAX]
Definition: totem.h:228
unsigned int token_warning
Definition: totem.h:184
unsigned int join_timeout
Definition: totem.h:192
unsigned int token_hold_timeout
Definition: totem.h:188
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:272
uint8_t reachable
Definition: totem.h:268
uint8_t remote
Definition: totem.h:269
unsigned int nodeid
Definition: totem.h:267
uint8_t onwire_min
Definition: totem.h:271
uint8_t onwire_ver
Definition: totem.h:273
uint32_t version
Definition: totem.h:266
uint8_t external
Definition: totem.h:270
struct knet_link_status link_status[KNET_MAX_LINK]
Definition: totem.h:274
@ TOTEM_LINK_MODE_BYTES
Definition: totem.h:140
typedef __attribute__
@ TOTEM_CONFIGURATION_REGULAR
Definition: totem.h:280
@ TOTEM_CONFIGURATION_TRANSITIONAL
Definition: totem.h:281
totem_event_type
Definition: totem.h:290
@ TOTEM_EVENT_NEW_MSG
Definition: totem.h:292
@ TOTEM_EVENT_DELIVERY_CONGESTED
Definition: totem.h:291
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:154
@ CRYPTO_RECONFIG_PHASE_CLEANUP
Definition: totem.h:156
@ CRYPTO_RECONFIG_PHASE_ACTIVATE
Definition: totem.h:155
@ TOTEM_CALLBACK_TOKEN_SENT
Definition: totem.h:287
@ TOTEM_CALLBACK_TOKEN_RECEIVED
Definition: totem.h:286
#define CONFIG_STRING_LEN_MAX
Definition: totem.h:54
totem_transport_t
Definition: totem.h:142
@ TOTEM_TRANSPORT_UDPU
Definition: totem.h:144
@ TOTEM_TRANSPORT_KNET
Definition: totem.h:145
@ TOTEM_TRANSPORT_UDP
Definition: totem.h:143
#define PROCESSOR_COUNT_MAX
Definition: totem.h:47
totem_ip_version_enum
Definition: totemip.h:70