totem.h
Go to the documentation of this file.
/*
* Copyright (c) 2005 MontaVista Software, Inc.
* Copyright (c) 2006-2022 Red Hat, Inc.
*
* Author: Steven Dake (sdake@redhat.com)
*
* All rights reserved.
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TOTEM_H_DEFINED
#define TOTEM_H_DEFINED
#include "totemip.h"
#include <libknet.h>
#include <corosync/hdb.h>
#include <corosync/totem/totemstats.h>
#ifdef HAVE_SMALL_MEMORY_FOOTPRINT
#define PROCESSOR_COUNT_MAX 16
#define MESSAGE_SIZE_MAX 1024*64
#define MESSAGE_QUEUE_MAX 512
#else
#define PROCESSOR_COUNT_MAX 384
#define MESSAGE_SIZE_MAX 1024*1024 /* (1MB) */
#define MESSAGE_QUEUE_MAX ((4 * MESSAGE_SIZE_MAX) / totem_config->net_mtu)
#endif /* HAVE_SMALL_MEMORY_FOOTPRINT */
#define FRAME_SIZE_MAX KNET_MAX_PACKET_SIZE
#define CONFIG_STRING_LEN_MAX 128
/*
* Estimation of required buffer size for totemudp and totemudpu - it should be at least
* sizeof(memb_join) + PROCESSOR_MAX * 2 * sizeof(srp_addr))
* if we want to support PROCESSOR_MAX nodes, but because we don't have
* srp_addr and memb_join, we have to use estimation.
* TODO: Consider moving srp_addr/memb_join into totem headers instead of totemsrp.c
*/
#define UDP_RECEIVE_FRAME_SIZE_MAX (PROCESSOR_COUNT_MAX * (INTERFACE_MAX * 2 * sizeof(struct totem_ip_address)) + 1024)
#define TRANSMITS_ALLOWED 16
#define SEND_THREADS_MAX 16
/* This must be <= KNET_MAX_LINK */
#define INTERFACE_MAX 8
#define BIND_MAX_RETRIES 10
#define BIND_RETRIES_INTERVAL 100
#define MAX_NO_CONT_GATHER 3
/*
* Maximum number of continuous failures get from sendmsg call
*/
#define MAX_NO_CONT_SENDMSG_FAILURES 30
struct totem_interface {
struct totem_ip_address bindnet;
struct totem_ip_address boundto;
struct totem_ip_address mcast_addr;
struct totem_ip_address local_ip;
uint16_t ip_port;
uint16_t ttl;
uint8_t configured;
int member_count;
int knet_link_priority;
int knet_ping_interval;
int knet_ping_timeout;
int knet_ping_precision;
int knet_pong_count;
int knet_transport;
struct totem_ip_address member_list[PROCESSOR_COUNT_MAX];
};
struct totem_logging_configuration {
void (*log_printf) (
int level,
int subsys,
const char *function_name,
const char *file_name,
int file_line,
const char *format,
...) __attribute__((format(printf, 6, 7)));
int log_level_security;
int log_level_error;
int log_level_warning;
int log_level_notice;
int log_level_debug;
int log_level_trace;
int log_subsys_id;
};
/*
* COrosync TOtem. Also used as an endian_detector.
*/
#define TOTEM_MH_MAGIC 0xC070
#define TOTEM_MH_VERSION 0x03
struct totem_message_header {
unsigned short magic;
char version;
char type;
char encapsulated;
unsigned int nodeid;
unsigned int target_nodeid;
} __attribute__((packed));
enum {
TOTEM_PRIVATE_KEY_LEN_MIN = KNET_MIN_KEY_LEN,
TOTEM_PRIVATE_KEY_LEN_MAX = KNET_MAX_KEY_LEN
};
enum { TOTEM_LINK_MODE_BYTES = 64 };
typedef enum {
TOTEM_TRANSPORT_UDP = 0,
TOTEM_TRANSPORT_UDPU = 1,
TOTEM_TRANSPORT_KNET = 2
} totem_transport_t;
#define MEMB_RING_ID
struct memb_ring_id {
unsigned int rep;
unsigned long long seq;
} __attribute__((packed));
typedef enum {
CRYPTO_RECONFIG_PHASE_ACTIVATE = 1,
CRYPTO_RECONFIG_PHASE_CLEANUP = 2,
} cfg_message_crypto_reconfig_phase_t;
struct totem_config {
int version;
/*
* network
*/
struct totem_interface *interfaces;
struct totem_interface *orig_interfaces; /* for reload */
unsigned int node_id;
unsigned int clear_node_high_bit;
unsigned int knet_pmtud_interval;
unsigned int knet_mtu;
/*
* key information
*/
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN_MAX];
unsigned int private_key_len;
/*
* Totem configuration parameters
*/
unsigned int token_timeout;
unsigned int token_warning;
unsigned int token_retransmit_timeout;
unsigned int token_hold_timeout;
unsigned int token_retransmits_before_loss_const;
unsigned int join_timeout;
unsigned int send_join_timeout;
unsigned int consensus_timeout;
unsigned int merge_timeout;
unsigned int downcheck_timeout;
unsigned int fail_to_recv_const;
unsigned int seqno_unchanged_const;
char link_mode[TOTEM_LINK_MODE_BYTES];
struct totem_logging_configuration totem_logging_configuration;
unsigned int net_mtu;
unsigned int threads;
unsigned int heartbeat_failures_allowed;
unsigned int max_network_delay;
unsigned int window_size;
unsigned int max_messages;
unsigned int broadcast_use;
char crypto_model[CONFIG_STRING_LEN_MAX];
char crypto_cipher_type[CONFIG_STRING_LEN_MAX];
char crypto_hash_type[CONFIG_STRING_LEN_MAX];
int crypto_index; /* Num of crypto config currently loaded into knet ( 1 or 2 ) */
int crypto_changed; /* Has crypto changed since last time? (it's expensive to reload) */
char knet_compression_model[CONFIG_STRING_LEN_MAX];
uint32_t knet_compression_threshold;
int knet_compression_level;
totem_transport_t transport_number;
unsigned int miss_count_const;
enum totem_ip_version_enum ip_version;
unsigned int block_unlisted_ips;
unsigned int cancel_token_hold_on_retransmit;
unsigned char ip_dscp;
void (*totem_memb_ring_id_create_or_load) (
struct memb_ring_id *memb_ring_id,
unsigned int nodeid);
void (*totem_memb_ring_id_store) (
const struct memb_ring_id *memb_ring_id,
unsigned int nodeid);
};
/*
* Node status returned from the API
* Usually the same as the cfg version (except for
* link_status)
*/
#define TOTEM_NODE_STATUS_STRUCTURE_VERSION 1
struct totem_node_status {
uint32_t version; /* Structure version */
unsigned int nodeid;
uint8_t reachable;
uint8_t remote;
uint8_t external;
uint8_t onwire_min;
uint8_t onwire_max;
uint8_t onwire_ver;
struct knet_link_status link_status[KNET_MAX_LINK];
};
#define TOTEM_CONFIGURATION_TYPE
enum totem_configuration_type {
TOTEM_CONFIGURATION_REGULAR,
TOTEM_CONFIGURATION_TRANSITIONAL
};
#define TOTEM_CALLBACK_TOKEN_TYPE
enum totem_callback_token_type {
TOTEM_CALLBACK_TOKEN_RECEIVED = 1,
TOTEM_CALLBACK_TOKEN_SENT = 2
};
enum totem_event_type {
TOTEM_EVENT_DELIVERY_CONGESTED,
TOTEM_EVENT_NEW_MSG,
};
#endif /* TOTEM_H_DEFINED */
totem_configuration_type
totem_configuration_type
The totem_configuration_type enum.
Definition coroapi.h:132
TOTEM_CONFIGURATION_REGULAR
@ TOTEM_CONFIGURATION_REGULAR
Definition coroapi.h:133
TOTEM_CONFIGURATION_TRANSITIONAL
@ TOTEM_CONFIGURATION_TRANSITIONAL
Definition coroapi.h:134
totem_callback_token_type
totem_callback_token_type
The totem_callback_token_type enum.
Definition coroapi.h:142
TOTEM_CALLBACK_TOKEN_SENT
@ TOTEM_CALLBACK_TOKEN_SENT
Definition coroapi.h:144
TOTEM_CALLBACK_TOKEN_RECEIVED
@ TOTEM_CALLBACK_TOKEN_RECEIVED
Definition coroapi.h:143
hdb.h
memb_ring_id
The memb_ring_id struct.
Definition coroapi.h:122
memb_ring_id::seq
unsigned long long seq
Definition coroapi.h:124
memb_ring_id::rep
unsigned int rep
Definition totem.h:150
totem_config
Definition totem.h:159
totem_config::crypto_model
char crypto_model[CONFIG_STRING_LEN_MAX]
Definition totem.h:224
totem_config::max_messages
unsigned int max_messages
Definition totem.h:220
totem_config::heartbeat_failures_allowed
unsigned int heartbeat_failures_allowed
Definition totem.h:214
totem_config::token_timeout
unsigned int token_timeout
Definition totem.h:182
totem_config::private_key_len
unsigned int private_key_len
Definition totem.h:177
totem_config::knet_mtu
unsigned int knet_mtu
Definition totem.h:170
totem_config::node_id
unsigned int node_id
Definition totem.h:167
totem_config::broadcast_use
unsigned int broadcast_use
Definition totem.h:222
totem_config::knet_compression_threshold
uint32_t knet_compression_threshold
Definition totem.h:236
totem_config::window_size
unsigned int window_size
Definition totem.h:218
totem_config::totem_logging_configuration
struct totem_logging_configuration totem_logging_configuration
Definition totem.h:208
totem_config::downcheck_timeout
unsigned int downcheck_timeout
Definition totem.h:200
totem_config::miss_count_const
unsigned int miss_count_const
Definition totem.h:242
totem_config::transport_number
totem_transport_t transport_number
Definition totem.h:240
totem_config::interfaces
struct totem_interface * interfaces
Definition totem.h:165
totem_config::crypto_changed
int crypto_changed
Definition totem.h:232
totem_config::cancel_token_hold_on_retransmit
unsigned int cancel_token_hold_on_retransmit
Definition totem.h:248
totem_config::fail_to_recv_const
unsigned int fail_to_recv_const
Definition totem.h:202
totem_config::clear_node_high_bit
unsigned int clear_node_high_bit
Definition totem.h:168
totem_config::merge_timeout
unsigned int merge_timeout
Definition totem.h:198
totem_config::orig_interfaces
struct totem_interface * orig_interfaces
Definition totem.h:166
totem_config::ip_dscp
unsigned char ip_dscp
Definition totem.h:250
totem_config::knet_compression_level
int knet_compression_level
Definition totem.h:238
totem_config::net_mtu
unsigned int net_mtu
Definition totem.h:210
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:252
totem_config::version
int version
Definition totem.h:160
totem_config::knet_compression_model
char knet_compression_model[CONFIG_STRING_LEN_MAX]
Definition totem.h:234
totem_config::block_unlisted_ips
unsigned int block_unlisted_ips
Definition totem.h:246
totem_config::token_retransmits_before_loss_const
unsigned int token_retransmits_before_loss_const
Definition totem.h:190
totem_config::private_key
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN_MAX]
Definition totem.h:175
totem_config::crypto_index
int crypto_index
Definition totem.h:230
totem_config::max_network_delay
unsigned int max_network_delay
Definition totem.h:216
totem_config::seqno_unchanged_const
unsigned int seqno_unchanged_const
Definition totem.h:204
totem_config::consensus_timeout
unsigned int consensus_timeout
Definition totem.h:196
totem_config::knet_pmtud_interval
unsigned int knet_pmtud_interval
Definition totem.h:169
totem_config::crypto_cipher_type
char crypto_cipher_type[CONFIG_STRING_LEN_MAX]
Definition totem.h:226
totem_config::threads
unsigned int threads
Definition totem.h:212
totem_config::send_join_timeout
unsigned int send_join_timeout
Definition totem.h:194
totem_config::link_mode
char link_mode[TOTEM_LINK_MODE_BYTES]
Definition totem.h:206
totem_config::ip_version
enum totem_ip_version_enum ip_version
Definition totem.h:244
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:256
totem_config::token_retransmit_timeout
unsigned int token_retransmit_timeout
Definition totem.h:186
totem_config::crypto_hash_type
char crypto_hash_type[CONFIG_STRING_LEN_MAX]
Definition totem.h:228
totem_config::token_warning
unsigned int token_warning
Definition totem.h:184
totem_config::join_timeout
unsigned int join_timeout
Definition totem.h:192
totem_config::token_hold_timeout
unsigned int token_hold_timeout
Definition totem.h:188
totem_interface
Definition totem.h:82
totem_interface::local_ip
struct totem_ip_address local_ip
Definition totem.h:86
totem_interface::knet_ping_timeout
int knet_ping_timeout
Definition totem.h:93
totem_interface::knet_link_priority
int knet_link_priority
Definition totem.h:91
totem_interface::boundto
struct totem_ip_address boundto
Definition totem.h:84
totem_interface::ip_port
uint16_t ip_port
Definition totem.h:87
totem_interface::knet_ping_interval
int knet_ping_interval
Definition totem.h:92
totem_interface::configured
uint8_t configured
Definition totem.h:89
totem_interface::knet_ping_precision
int knet_ping_precision
Definition totem.h:94
totem_interface::knet_pong_count
int knet_pong_count
Definition totem.h:95
totem_interface::knet_transport
int knet_transport
Definition totem.h:96
totem_interface::member_count
int member_count
Definition totem.h:90
totem_interface::bindnet
struct totem_ip_address bindnet
Definition totem.h:83
totem_interface::member_list
struct totem_ip_address member_list[PROCESSOR_COUNT_MAX]
Definition totem.h:97
totem_interface::ttl
uint16_t ttl
Definition totem.h:88
totem_interface::mcast_addr
struct totem_ip_address mcast_addr
Definition totem.h:85
totem_ip_address
The totem_ip_address struct.
Definition coroapi.h:111
totem_logging_configuration
Definition totem.h:100
totem_logging_configuration::log_level_security
void int log_level_security
Definition totem.h:110
totem_logging_configuration::log_subsys_id
int log_subsys_id
Definition totem.h:116
totem_logging_configuration::log_level_error
int log_level_error
Definition totem.h:111
totem_logging_configuration::log_level_notice
int log_level_notice
Definition totem.h:113
totem_logging_configuration::log_level_debug
int log_level_debug
Definition totem.h:114
totem_logging_configuration::log_level_warning
int log_level_warning
Definition totem.h:112
totem_logging_configuration::log_level_trace
int log_level_trace
Definition totem.h:115
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:101
totem_message_header
Definition totem.h:126
totem_message_header::target_nodeid
unsigned int target_nodeid
Definition totem.h:132
totem_message_header::type
char type
Definition totem.h:129
totem_message_header::nodeid
unsigned int nodeid
Definition totem.h:131
totem_message_header::encapsulated
char encapsulated
Definition totem.h:130
totem_message_header::magic
unsigned short magic
Definition totem.h:127
totem_message_header::version
char version
Definition totem.h:128
totem_node_status
Definition totem.h:267
totem_node_status::onwire_max
uint8_t onwire_max
Definition totem.h:274
totem_node_status::reachable
uint8_t reachable
Definition totem.h:270
totem_node_status::remote
uint8_t remote
Definition totem.h:271
totem_node_status::nodeid
unsigned int nodeid
Definition totem.h:269
totem_node_status::onwire_min
uint8_t onwire_min
Definition totem.h:273
totem_node_status::onwire_ver
uint8_t onwire_ver
Definition totem.h:275
totem_node_status::version
uint32_t version
Definition totem.h:268
totem_node_status::external
uint8_t external
Definition totem.h:272
totem_node_status::link_status
struct knet_link_status link_status[KNET_MAX_LINK]
Definition totem.h:276
__attribute__
typedef __attribute__
totem_event_type
totem_event_type
Definition totem.h:292
TOTEM_EVENT_NEW_MSG
@ TOTEM_EVENT_NEW_MSG
Definition totem.h:294
TOTEM_EVENT_DELIVERY_CONGESTED
@ TOTEM_EVENT_DELIVERY_CONGESTED
Definition totem.h:293
nodeid
unsigned int nodeid
Definition totem.h:4
cfg_message_crypto_reconfig_phase_t
cfg_message_crypto_reconfig_phase_t
Definition totem.h:154
CRYPTO_RECONFIG_PHASE_CLEANUP
@ CRYPTO_RECONFIG_PHASE_CLEANUP
Definition totem.h:156
CRYPTO_RECONFIG_PHASE_ACTIVATE
@ CRYPTO_RECONFIG_PHASE_ACTIVATE
Definition totem.h:155
TOTEM_PRIVATE_KEY_LEN_MAX
@ TOTEM_PRIVATE_KEY_LEN_MAX
Definition totem.h:137
TOTEM_PRIVATE_KEY_LEN_MIN
@ TOTEM_PRIVATE_KEY_LEN_MIN
Definition totem.h:136
CONFIG_STRING_LEN_MAX
#define CONFIG_STRING_LEN_MAX
Definition totem.h:54
TOTEM_LINK_MODE_BYTES
@ TOTEM_LINK_MODE_BYTES
Definition totem.h:140
totem_transport_t
totem_transport_t
Definition totem.h:142
TOTEM_TRANSPORT_UDPU
@ TOTEM_TRANSPORT_UDPU
Definition totem.h:144
TOTEM_TRANSPORT_KNET
@ TOTEM_TRANSPORT_KNET
Definition totem.h:145
TOTEM_TRANSPORT_UDP
@ TOTEM_TRANSPORT_UDP
Definition totem.h:143
PROCESSOR_COUNT_MAX
#define PROCESSOR_COUNT_MAX
Definition totem.h:47
totemip.h
totem_ip_version_enum
totem_ip_version_enum
Definition totemip.h:70
totemstats.h