corosync  3.0.2
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 /*
55  * Estimation of required buffer size for totemudp and totemudpu - it should be at least
56  * sizeof(memb_join) + PROCESSOR_MAX * 2 * sizeof(srp_addr))
57  * if we want to support PROCESSOR_MAX nodes, but because we don't have
58  * srp_addr and memb_join, we have to use estimation.
59  * TODO: Consider moving srp_addr/memb_join into totem headers instead of totemsrp.c
60  */
61 #define UDP_RECEIVE_FRAME_SIZE_MAX (PROCESSOR_COUNT_MAX * (INTERFACE_MAX * 2 * sizeof(struct totem_ip_address)) + 1024)
62 
63 #define TRANSMITS_ALLOWED 16
64 #define SEND_THREADS_MAX 16
65 
66 /* This must be <= KNET_MAX_LINK */
67 #define INTERFACE_MAX 8
68 
69 #define BIND_MAX_RETRIES 10
70 #define BIND_RETRIES_INTERVAL 100
71 
75 #define MAX_NO_CONT_GATHER 3
76 /*
77  * Maximum number of continuous failures get from sendmsg call
78  */
79 #define MAX_NO_CONT_SENDMSG_FAILURES 30
80 
85  uint16_t ip_port;
86  uint16_t ttl;
87  uint8_t configured;
96 };
97 
99  void (*log_printf) (
100  int level,
101  int subsys,
102  const char *function_name,
103  const char *file_name,
104  int file_line,
105  const char *format,
106  ...) __attribute__((format(printf, 6, 7)));
107 
108  int log_level_security;
115 };
116 
117 
118 /*
119  * COrosync TOtem. Also used as an endian_detector.
120  */
121 #define TOTEM_MH_MAGIC 0xC070
122 #define TOTEM_MH_VERSION 0x03
123 
125  unsigned short magic;
126  char version;
127  char type;
129  unsigned int nodeid;
130  unsigned int target_nodeid;
131 } __attribute__((packed));
132 
133 enum {
134  TOTEM_PRIVATE_KEY_LEN_MIN = KNET_MIN_KEY_LEN,
135  TOTEM_PRIVATE_KEY_LEN_MAX = KNET_MAX_KEY_LEN
136 };
137 
138 enum { TOTEM_LINK_MODE_BYTES = 64 };
139 
140 typedef enum {
145 
146 #define MEMB_RING_ID
147 struct memb_ring_id {
148  unsigned int rep;
149  unsigned long long seq;
150 } __attribute__((packed));
151 
152 struct totem_config {
153  int version;
154 
155  /*
156  * network
157  */
159  struct totem_interface *orig_interfaces; /* for reload */
160  unsigned int node_id;
161  unsigned int clear_node_high_bit;
162  unsigned int knet_pmtud_interval;
163 
164  /*
165  * key information
166  */
168 
169  unsigned int private_key_len;
170 
171  /*
172  * Totem configuration parameters
173  */
174  unsigned int token_timeout;
175 
176  unsigned int token_warning;
177 
179 
180  unsigned int token_hold_timeout;
181 
183 
184  unsigned int join_timeout;
185 
186  unsigned int send_join_timeout;
187 
188  unsigned int consensus_timeout;
189 
190  unsigned int merge_timeout;
191 
192  unsigned int downcheck_timeout;
193 
194  unsigned int fail_to_recv_const;
195 
196  unsigned int seqno_unchanged_const;
197 
199 
201 
202  unsigned int net_mtu;
203 
204  unsigned int threads;
205 
207 
208  unsigned int max_network_delay;
209 
210  unsigned int window_size;
211 
212  unsigned int max_messages;
213 
214  const char *vsf_type;
215 
216  unsigned int broadcast_use;
217 
219 
221 
223 
225 
227 
229 
231 
232  unsigned int miss_count_const;
233 
235 
236  unsigned int block_unlisted_ips;
237 
239  struct memb_ring_id *memb_ring_id,
240  unsigned int nodeid);
241 
243  const struct memb_ring_id *memb_ring_id,
244  unsigned int nodeid);
245 };
246 
247 #define TOTEM_CONFIGURATION_TYPE
251 };
252 
253 #define TOTEM_CALLBACK_TOKEN_TYPE
257 };
258 
262 };
263 
264 #endif /* TOTEM_H_DEFINED */
totem_config::token_warning
unsigned int token_warning
Definition: totem.h:176
totem_config::max_messages
unsigned int max_messages
Definition: totem.h:212
TOTEM_EVENT_DELIVERY_CONGESTED
Definition: totem.h:260
totem_config::heartbeat_failures_allowed
unsigned int heartbeat_failures_allowed
Definition: totem.h:206
totem_logging_configuration::log_level_error
int log_level_error
Definition: totem.h:109
totem_ip_version_enum
totem_ip_version_enum
Definition: totemip.h:70
totem_callback_token_type
totem_callback_token_type
The totem_callback_token_type enum.
Definition: coroapi.h:142
totem_config::node_id
unsigned int node_id
Definition: totem.h:160
totem_message_header::type
char type
Definition: totem.h:127
totem_config::token_retransmits_before_loss_const
unsigned int token_retransmits_before_loss_const
Definition: totem.h:182
totem_configuration_type
totem_configuration_type
The totem_configuration_type enum.
Definition: coroapi.h:132
TOTEM_CALLBACK_TOKEN_RECEIVED
Definition: totem.h:255
totem_interface::knet_ping_precision
int knet_ping_precision
Definition: totem.h:92
totem_config::join_timeout
unsigned int join_timeout
Definition: totem.h:184
TOTEM_TRANSPORT_UDPU
Definition: totem.h:142
totem_logging_configuration::log_level_trace
int log_level_trace
Definition: totem.h:113
totem_config::downcheck_timeout
unsigned int downcheck_timeout
Definition: totem.h:192
totem_interface::member_count
int member_count
Definition: totem.h:88
totem_interface::member_list
struct totem_ip_address member_list[PROCESSOR_COUNT_MAX]
Definition: totem.h:95
hdb.h
totem_config::totem_memb_ring_id_store
void(* totem_memb_ring_id_store)(const struct memb_ring_id *memb_ring_id, unsigned int nodeid)
Definition: totem.h:242
totem_config::knet_pmtud_interval
unsigned int knet_pmtud_interval
Definition: totem.h:162
totem_message_header::nodeid
unsigned int nodeid
Definition: totem.h:129
memb_ring_id::rep
unsigned int rep
Definition: totem.h:148
totem_config::fail_to_recv_const
unsigned int fail_to_recv_const
Definition: totem.h:194
totem_logging_configuration::log_level_debug
int log_level_debug
Definition: totem.h:112
TOTEM_CONFIGURATION_TRANSITIONAL
Definition: totem.h:250
totem_logging_configuration::log_level_notice
int log_level_notice
Definition: totem.h:111
totem_interface::knet_link_priority
int knet_link_priority
Definition: totem.h:89
totem_transport_t
totem_transport_t
Definition: totem.h:140
TOTEM_TRANSPORT_KNET
Definition: totem.h:143
totem_message_header::encapsulated
char encapsulated
Definition: totem.h:128
totem_config::broadcast_use
unsigned int broadcast_use
Definition: totem.h:216
totem_config::merge_timeout
unsigned int merge_timeout
Definition: totem.h:190
totem_interface
Definition: totem.h:81
totem_config::token_timeout
unsigned int token_timeout
Definition: totem.h:174
totem_config::ip_version
enum totem_ip_version_enum ip_version
Definition: totem.h:234
totem_config::interfaces
struct totem_interface * interfaces
Definition: totem.h:158
totem_config::version
int version
Definition: totem.h:153
totem_interface::knet_transport
int knet_transport
Definition: totem.h:94
totem_config::knet_compression_level
int knet_compression_level
Definition: totem.h:228
totem_config::transport_number
totem_transport_t transport_number
Definition: totem.h:230
TOTEM_TRANSPORT_UDP
Definition: totem.h:141
totem_config::token_hold_timeout
unsigned int token_hold_timeout
Definition: totem.h:180
totem_config::net_mtu
unsigned int net_mtu
Definition: totem.h:202
totem_config::clear_node_high_bit
unsigned int clear_node_high_bit
Definition: totem.h:161
totemip.h
totem_config::knet_compression_threshold
uint32_t knet_compression_threshold
Definition: totem.h:226
totem_interface::ttl
uint16_t ttl
Definition: totem.h:86
PROCESSOR_COUNT_MAX
#define PROCESSOR_COUNT_MAX
Definition: totem.h:47
totem_interface::configured
uint8_t configured
Definition: totem.h:87
totem_interface::boundto
struct totem_ip_address boundto
Definition: totem.h:83
totem_config::miss_count_const
unsigned int miss_count_const
Definition: totem.h:232
totem_config::crypto_model
char * crypto_model
Definition: totem.h:218
totem_logging_configuration::log_subsys_id
int log_subsys_id
Definition: totem.h:114
totem_config::link_mode
char link_mode[TOTEM_LINK_MODE_BYTES]
Definition: totem.h:198
totem_interface::mcast_addr
struct totem_ip_address mcast_addr
Definition: totem.h:84
totem_config
Definition: totem.h:152
totem_config::orig_interfaces
struct totem_interface * orig_interfaces
Definition: totem.h:159
totem_ip_address
The totem_ip_address struct.
Definition: coroapi.h:111
totem_config::vsf_type
const char * vsf_type
Definition: totem.h:214
totem_message_header
Definition: totem.h:124
memb_ring_id
The memb_ring_id struct.
Definition: coroapi.h:122
totem_interface::knet_pong_count
int knet_pong_count
Definition: totem.h:93
totem_interface::ip_port
uint16_t ip_port
Definition: totem.h:85
TOTEM_PRIVATE_KEY_LEN_MIN
Definition: totem.h:134
totem_interface::knet_ping_interval
int knet_ping_interval
Definition: totem.h:90
nodeid
unsigned int nodeid
Definition: totem.h:57
totem_logging_configuration::log_level_warning
int log_level_warning
Definition: totem.h:110
totem_logging_configuration::log_level_security
void(*) in log_level_security)
Definition: totem.h:106
totem_event_type
totem_event_type
Definition: totem.h:259
TOTEM_PRIVATE_KEY_LEN_MAX
Definition: totem.h:135
totem_config::token_retransmit_timeout
unsigned int token_retransmit_timeout
Definition: totem.h:178
totem_message_header::magic
unsigned short magic
Definition: totem.h:125
totem_message_header::version
char version
Definition: totem.h:126
totem_interface::knet_ping_timeout
int knet_ping_timeout
Definition: totem.h:91
totem_config::totem_memb_ring_id_create_or_load
void(* totem_memb_ring_id_create_or_load)(struct memb_ring_id *memb_ring_id, unsigned int nodeid)
Definition: totem.h:238
__attribute__
enum @4 __attribute__
totem_config::seqno_unchanged_const
unsigned int seqno_unchanged_const
Definition: totem.h:196
memb_ring_id::seq
unsigned long long seq
Definition: coroapi.h:124
totem_config::private_key
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN_MAX]
Definition: totem.h:167
totem_config::send_join_timeout
unsigned int send_join_timeout
Definition: totem.h:186
totem_config::window_size
unsigned int window_size
Definition: totem.h:210
totem_config::threads
unsigned int threads
Definition: totem.h:204
totem_config::crypto_hash_type
char * crypto_hash_type
Definition: totem.h:222
TOTEM_EVENT_NEW_MSG
Definition: totem.h:261
totem_logging_configuration::log_printf
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:99
totem_interface::bindnet
struct totem_ip_address bindnet
Definition: totem.h:82
totem_config::private_key_len
unsigned int private_key_len
Definition: totem.h:169
totem_config::crypto_cipher_type
char * crypto_cipher_type
Definition: totem.h:220
TOTEM_CALLBACK_TOKEN_SENT
Definition: totem.h:256
totem_logging_configuration
Definition: totem.h:98
TOTEM_LINK_MODE_BYTES
Definition: totem.h:138
TOTEM_CONFIGURATION_REGULAR
Definition: totem.h:249
totem_config::block_unlisted_ips
unsigned int block_unlisted_ips
Definition: totem.h:236
totem_config::max_network_delay
unsigned int max_network_delay
Definition: totem.h:208
totemstats.h
totem_message_header::target_nodeid
unsigned int target_nodeid
Definition: totem.h:130
totem_config::consensus_timeout
unsigned int consensus_timeout
Definition: totem.h:188
totem_config::knet_compression_model
char * knet_compression_model
Definition: totem.h:224