corosync  3.1.0
totem.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005 MontaVista Software, Inc.
3  * Copyright (c) 2006-2012 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;
128  char version;
129  char type;
131  unsigned int nodeid;
132  unsigned int target_nodeid;
133 } __attribute__((packed));
134 
135 enum {
136  TOTEM_PRIVATE_KEY_LEN_MIN = KNET_MIN_KEY_LEN,
137  TOTEM_PRIVATE_KEY_LEN_MAX = KNET_MAX_KEY_LEN
138 };
139 
140 enum { TOTEM_LINK_MODE_BYTES = 64 };
141 
142 typedef enum {
147 
148 #define MEMB_RING_ID
149 struct memb_ring_id {
150  unsigned int rep;
151  unsigned long long seq;
152 } __attribute__((packed));
153 
154 typedef enum {
158 
159 struct totem_config {
160  int version;
161 
162  /*
163  * network
164  */
166  struct totem_interface *orig_interfaces; /* for reload */
167  unsigned int node_id;
168  unsigned int clear_node_high_bit;
169  unsigned int knet_pmtud_interval;
170 
171  /*
172  * key information
173  */
175 
176  unsigned int private_key_len;
177 
178  /*
179  * Totem configuration parameters
180  */
181  unsigned int token_timeout;
182 
183  unsigned int token_warning;
184 
186 
187  unsigned int token_hold_timeout;
188 
190 
191  unsigned int join_timeout;
192 
193  unsigned int send_join_timeout;
194 
195  unsigned int consensus_timeout;
196 
197  unsigned int merge_timeout;
198 
199  unsigned int downcheck_timeout;
200 
201  unsigned int fail_to_recv_const;
202 
203  unsigned int seqno_unchanged_const;
204 
206 
208 
209  unsigned int net_mtu;
210 
211  unsigned int threads;
212 
214 
215  unsigned int max_network_delay;
216 
217  unsigned int window_size;
218 
219  unsigned int max_messages;
220 
221  unsigned int broadcast_use;
222 
224 
226 
228 
229  int crypto_index; /* Num of crypto config currently loaded into knet ( 1 or 2 ) */
230 
231  int crypto_changed; /* Has crypto changed since last time? (it's expensive to reload) */
232 
234 
236 
238 
240 
241  unsigned int miss_count_const;
242 
244 
245  unsigned int block_unlisted_ips;
246 
248  struct memb_ring_id *memb_ring_id,
249  unsigned int nodeid);
250 
252  const struct memb_ring_id *memb_ring_id,
253  unsigned int nodeid);
254 };
255 
256 #define TOTEM_CONFIGURATION_TYPE
260 };
261 
262 #define TOTEM_CALLBACK_TOKEN_TYPE
266 };
267 
271 };
272 
273 #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:223
unsigned int max_messages
Definition: totem.h:219
unsigned int heartbeat_failures_allowed
Definition: totem.h:213
unsigned int token_timeout
Definition: totem.h:181
unsigned int private_key_len
Definition: totem.h:176
unsigned int node_id
Definition: totem.h:167
unsigned int broadcast_use
Definition: totem.h:221
uint32_t knet_compression_threshold
Definition: totem.h:235
unsigned int window_size
Definition: totem.h:217
unsigned int downcheck_timeout
Definition: totem.h:199
unsigned int miss_count_const
Definition: totem.h:241
totem_transport_t transport_number
Definition: totem.h:239
struct totem_interface * interfaces
Definition: totem.h:165
int crypto_changed
Definition: totem.h:231
unsigned int fail_to_recv_const
Definition: totem.h:201
unsigned int clear_node_high_bit
Definition: totem.h:168
unsigned int merge_timeout
Definition: totem.h:197
struct totem_interface * orig_interfaces
Definition: totem.h:166
int knet_compression_level
Definition: totem.h:237
unsigned int net_mtu
Definition: totem.h:209
void(* totem_memb_ring_id_create_or_load)(struct memb_ring_id *memb_ring_id, unsigned int nodeid)
Definition: totem.h:247
int version
Definition: totem.h:160
char knet_compression_model[CONFIG_STRING_LEN_MAX]
Definition: totem.h:233
unsigned int block_unlisted_ips
Definition: totem.h:245
unsigned int token_retransmits_before_loss_const
Definition: totem.h:189
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN_MAX]
Definition: totem.h:174
int crypto_index
Definition: totem.h:229
unsigned int max_network_delay
Definition: totem.h:215
unsigned int seqno_unchanged_const
Definition: totem.h:203
unsigned int consensus_timeout
Definition: totem.h:195
unsigned int knet_pmtud_interval
Definition: totem.h:169
char crypto_cipher_type[CONFIG_STRING_LEN_MAX]
Definition: totem.h:225
unsigned int threads
Definition: totem.h:211
unsigned int send_join_timeout
Definition: totem.h:193
char link_mode[TOTEM_LINK_MODE_BYTES]
Definition: totem.h:205
enum totem_ip_version_enum ip_version
Definition: totem.h:243
void(* totem_memb_ring_id_store)(const struct memb_ring_id *memb_ring_id, unsigned int nodeid)
Definition: totem.h:251
unsigned int token_retransmit_timeout
Definition: totem.h:185
char crypto_hash_type[CONFIG_STRING_LEN_MAX]
Definition: totem.h:227
unsigned int token_warning
Definition: totem.h:183
unsigned int join_timeout
Definition: totem.h:191
unsigned int token_hold_timeout
Definition: totem.h:187
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:108
unsigned int target_nodeid
Definition: totem.h:132
unsigned int nodeid
Definition: totem.h:131
unsigned short magic
Definition: totem.h:127
@ TOTEM_LINK_MODE_BYTES
Definition: totem.h:140
typedef __attribute__
@ TOTEM_CONFIGURATION_REGULAR
Definition: totem.h:258
@ TOTEM_CONFIGURATION_TRANSITIONAL
Definition: totem.h:259
totem_event_type
Definition: totem.h:268
@ TOTEM_EVENT_NEW_MSG
Definition: totem.h:270
@ TOTEM_EVENT_DELIVERY_CONGESTED
Definition: totem.h:269
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:265
@ TOTEM_CALLBACK_TOKEN_RECEIVED
Definition: totem.h:264
#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