45#include <sys/socket.h>
51#include <netinet/in.h>
54#include <sys/utsname.h>
68#define TOKEN_RETRANSMITS_BEFORE_LOSS_CONST 4
69#define TOKEN_TIMEOUT 3000
70#define TOKEN_WARNING 75
71#define TOKEN_COEFFICIENT 650
72#define JOIN_TIMEOUT 50
73#define MERGE_TIMEOUT 200
74#define DOWNCHECK_TIMEOUT 1000
75#define FAIL_TO_RECV_CONST 2500
76#define SEQNO_UNCHANGED_CONST 30
77#define MINIMUM_TIMEOUT (int)(1000/HZ)*3
78#define MINIMUM_TIMEOUT_HOLD (int)(MINIMUM_TIMEOUT * 0.8 - (1000/HZ))
79#define MAX_NETWORK_DELAY 50
81#define MAX_MESSAGES 17
82#define MISS_COUNT_CONST 5
83#define BLOCK_UNLISTED_IPS 1
84#define CANCEL_TOKEN_HOLD_ON_RETRANSMIT 0
86#define UDP_NETMTU 1500
89#define KNET_PING_INTERVAL 1000
90#define KNET_PING_TIMEOUT 2000
91#define KNET_PING_PRECISION 2048
92#define KNET_PONG_COUNT 2
93#define KNET_PMTUD_INTERVAL 30
95#define KNET_DEFAULT_TRANSPORT KNET_TRANSPORT_UDP
97#define DEFAULT_PORT 5405
99static char error_string_response[768];
376 totem_volatile_config_set_boolean_value(
totem_config,
temp_map,
"totem.cancel_token_hold_on_retransmit",
396 "The max_network_delay parameter (%d ms) may not be less than (%d ms).",
403 "The token timeout parameter (%d ms) may not be less than (%d ms).",
410 "The token warning parameter (%d%%) must be between 0 (disabled) and 100.",
418 "The token retransmit timeout parameter (%d ms) may not be less than (%d ms).",
423 "Not appropriate token or token_retransmits_before_loss_const value set");
430 "The token hold timeout parameter (%d ms) may not be less than (%d ms).",
437 "The join timeout parameter (%d ms) may not be less than (%d ms).",
444 "The consensus timeout parameter (%d ms) may not be less than (%d ms).",
451 "The consensus timeout parameter (%d ms) may not be less than join timeout (%d ms).",
458 "The merge timeout parameter (%d ms) may not be less than (%d ms).",
465 "The downcheck timeout parameter (%d ms) may not be less than (%d ms).",
492 "for a multi-link configuration, all nodes must have a 'name' attribute");
505 "Not all nodes have the same number of links");
522 "Nodes for link %d have different IP families "
523 "(compared %s with %s)",
i,
535 snprintf (error_string_response,
sizeof(error_string_response),
610 *
error_string =
"crypto_cipher requires crypto_hash with value other than none";
698 switch (
addr1->sa_family) {
893 ipaddr_equal(
rp->ai_addr,
ifa->ifa_addr)) {
955 return (
value & 0xFFFF);
958static int get_cluster_mcast_addr (
960 unsigned int linknumber,
975 switch (ip_version) {
996static unsigned int generate_nodeid(
1010#if __BYTE_ORDER == __LITTLE_ENDIAN
1020static int check_for_duplicate_nodeids(
1102 snprintf (error_string_response,
sizeof(error_string_response),
1103 "Nodeid %u%s%s%s appears twice in corosync.conf",
nodeid,
1139 "runtime.config.totem.interface.%d.knet_ping_timeout",
interface);
1147 "runtime.config.totem.interface.%d.knet_ping_interval",
interface);
1200 "removing dynamic member %s for ring %u",
1217 "adding dynamic member %s for ring %u",
1305 "New config has different knet transport for link %d. Internal value was NOT changed.\n",
i);
1328 "new config has different address for link %d (addr changed from %s to %s). Internal value was NOT changed.\n",
1340 snprintf (error_string_response,
sizeof(error_string_response),
1341 "To reconfigure an interface it must be deleted and recreated. A working interface needs to be available to corosync at all times");
1360 unsigned int linknumber = 0;
1400 snprintf (error_string_response,
sizeof(error_string_response),
1401 "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
1422 sprintf(error_string_response,
1423 "An IPV6 network requires that a node ID be specified "
1447 sprintf(error_string_response,
1448 "Knet requires an explicit nodeid to be specified "
1456 sprintf(error_string_response,
1457 "Knet requires nodeid to be less than %u "
1510 unsigned int linknumber = 0;
1544 unsigned int linknumber = 0;
1545 int member_count = 0;
1592 snprintf (error_string_response,
sizeof(error_string_response),
1593 "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
1613 sprintf(error_string_response,
"failed to parse bindnet address '%s'\n",
str);
1633 sprintf(error_string_response,
"failed to parse mcast address '%s'\n",
str);
1707 *
error_string =
"Unrecognised knet_transport. expected 'udp' or 'sctp'";
1749 if (member_count == 0) {
1763 sprintf(error_string_response,
"failed to parse node address '%s'\n",
str);
1806 *
error_string =
"Out of memory trying to allocate ethernet interface storage area";
1819 *
error_string =
"Invalid transport type. Should be udpu, udp or knet";
1957 *
error_string =
"Knet requires an explicit nodeid for the local node";
1969 *
error_string =
"An IPV6 network requires that a node ID be specified";
2050 "No multicast address specified for interface %u",
i);
2056 "No multicast port specified for interface %u",
i);
2062 "Invalid TTL (should be 0..255) for interface %u",
i);
2068 "Can only set ttl on multicast transport types for interface %u",
i);
2073 "Invalid link priority (should be 0..255) for interface %u",
i);
2079 "Can only set link priority on knet transport type for interface %u",
i);
2086 "An IPV6 network requires that a node ID be specified for interface %u",
i);
2093 "Multicast address family does not match bind address family for interface %u",
i);
2099 "mcastaddr is not a correct multicast address for interface %u",
i);
2106 error_reason =
"This totem parser can only parse version 2 configurations.";
2125 "The Knet link mode \"%s\" specified is invalid. It must be active, passive or rr.\n",
totem_config->
link_mode);
2136 "%d is too many configured interfaces for non-Knet transport.",
2148 "crypto_cipher & crypto_hash are only valid for the Knet transport.");
2166 snprintf (error_string_response,
sizeof(error_string_response),
2173static int read_keyfile (
2187 snprintf (error_string_response,
sizeof(error_string_response),
2188 "Could not open %s: %s\n",
2199 snprintf (error_string_response,
sizeof(error_string_response),
2200 "Could not read %s: %s\n",
2206 snprintf (error_string_response,
sizeof(error_string_response),
2207 "Could only read %d bits of minimum %u bits from %s.\n",
2256 sprintf(error_string_response,
"key is too long");
2260 sprintf(error_string_response,
"key is too short");
2267 sprintf(error_string_response,
"can't load private key");
2315 "The token warning interval (%d ms) is less than the token retransmit timeout (%d ms) "
2316 "which can lead to spurious token warnings. Consider increasing the token_warning parameter.",
2329 "seqno unchanged const (%d rotations) Maximum network MTU %d",
2332 "window size per rotation (%d messages) maximum messages per rotation (%d messages)",
2341static void totem_change_notify(
2343 const char *key_name,
2367 if (!
param &&
strcmp(key_name,
"totem.token_coefficient") != 0)
2416 (
void)find_local_node(
map, 0);
2457 totem_change_notify,
unsigned char addr[TOTEMIP_ADDRLEN]
#define PROCESSOR_COUNT_MAX
icmap_iter_t icmap_iter_init_r(const icmap_map_t map, const char *prefix)
icmap_iter_init_r
cs_error_t icmap_get_uint8(const char *key_name, uint8_t *u8)
#define ICMAP_TRACK_MODIFY
cs_error_t icmap_get_string_r(const icmap_map_t map, const char *key_name, char **str)
cs_error_t icmap_get_uint16(const char *key_name, uint16_t *u16)
cs_error_t icmap_get_uint32(const char *key_name, uint32_t *u32)
cs_error_t icmap_set_ro_access(const char *key_name, int prefix, int ro_access)
Set read-only access for given key (key_name) or prefix, If prefix is set.
cs_error_t icmap_set_uint32_r(const icmap_map_t map, const char *key_name, uint32_t value)
cs_error_t icmap_get_uint8_r(const icmap_map_t map, const char *key_name, uint8_t *u8)
#define ICMAP_TRACK_DELETE
cs_error_t icmap_set_uint16(const char *key_name, uint16_t value)
cs_error_t icmap_track_add(const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track)
Add tracking function for given key_name.
cs_error_t icmap_set_string(const char *key_name, const char *value)
#define ICMAP_TRACK_PREFIX
Whole prefix is tracked, instead of key only (so "totem." tracking means that "totem....
icmap_iter_t icmap_iter_init(const char *prefix)
Initialize iterator with given prefix.
cs_error_t icmap_get_uint16_r(const icmap_map_t map, const char *key_name, uint16_t *u16)
cs_error_t icmap_set_int32_r(const icmap_map_t map, const char *key_name, int32_t value)
const char * icmap_iter_next(icmap_iter_t iter, size_t *value_len, icmap_value_types_t *type)
Return next item in iterator iter.
icmap_map_t icmap_get_global_map(void)
Return global icmap.
qb_map_iter_t * icmap_iter_t
Itterator type.
cs_error_t icmap_set_string_r(const icmap_map_t map, const char *key_name, const char *value)
void icmap_iter_finalize(icmap_iter_t iter)
Finalize iterator.
cs_error_t icmap_get_int32_r(const icmap_map_t map, const char *key_name, int32_t *i32)
cs_error_t icmap_get_r(const icmap_map_t map, const char *key_name, void *value, size_t *value_len, icmap_value_types_t *type)
Same as icmap_get but it's reentrant and operates on given icmap_map.
#define ICMAP_KEYNAME_MAXLEN
Maximum length of key in icmap.
cs_error_t icmap_get_uint32_r(const icmap_map_t map, const char *key_name, uint32_t *u32)
cs_error_t icmap_set_uint32(const char *key_name, uint32_t value)
cs_error_t icmap_get_string(const char *key_name, char **str)
Shortcut for icmap_get for string type.
#define LOGSYS_LEVEL_ERROR
#define log_printf(level, format, args...)
#define LOGSYS_LEVEL_INFO
#define LOGSYS_LEVEL_DEBUG
Structure passed as new_value and old_value in change callback.
char crypto_model[CONFIG_STRING_LEN_MAX]
unsigned int max_messages
unsigned int heartbeat_failures_allowed
unsigned int token_timeout
unsigned int private_key_len
unsigned int broadcast_use
uint32_t knet_compression_threshold
unsigned int downcheck_timeout
unsigned int miss_count_const
totem_transport_t transport_number
struct totem_interface * interfaces
unsigned int cancel_token_hold_on_retransmit
unsigned int fail_to_recv_const
unsigned int clear_node_high_bit
unsigned int merge_timeout
struct totem_interface * orig_interfaces
int knet_compression_level
char knet_compression_model[CONFIG_STRING_LEN_MAX]
unsigned int block_unlisted_ips
unsigned int token_retransmits_before_loss_const
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN_MAX]
unsigned int max_network_delay
unsigned int seqno_unchanged_const
unsigned int consensus_timeout
unsigned int knet_pmtud_interval
char crypto_cipher_type[CONFIG_STRING_LEN_MAX]
unsigned int send_join_timeout
char link_mode[TOTEM_LINK_MODE_BYTES]
enum totem_ip_version_enum ip_version
unsigned int token_retransmit_timeout
char crypto_hash_type[CONFIG_STRING_LEN_MAX]
unsigned int token_warning
unsigned int join_timeout
unsigned int token_hold_timeout
struct totem_ip_address local_ip
struct totem_ip_address bindnet
struct totem_ip_address member_list[PROCESSOR_COUNT_MAX]
struct totem_ip_address mcast_addr
The totem_ip_address struct.
#define swab32(x)
The swab32 macro.
@ TOTEM_PRIVATE_KEY_LEN_MAX
@ TOTEM_PRIVATE_KEY_LEN_MIN
#define CONFIG_STRING_LEN_MAX
#define TOKEN_RETRANSMITS_BEFORE_LOSS_CONST
#define MAX_NETWORK_DELAY
#define KNET_PMTUD_INTERVAL
#define MINIMUM_TIMEOUT_HOLD
#define TOKEN_COEFFICIENT
#define SEQNO_UNCHANGED_CONST
void totem_volatile_config_read(struct totem_config *totem_config, icmap_map_t temp_map, const char *deleted_key)
int totem_config_read(struct totem_config *totem_config, const char **error_string, uint64_t *warnings)
int totemconfig_commit_new_params(struct totem_config *totem_config, icmap_map_t map)
int totem_volatile_config_validate(struct totem_config *totem_config, icmap_map_t temp_map, const char **error_string)
int totem_reread_crypto_config(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
#define KNET_PING_PRECISION
int totem_config_validate(struct totem_config *totem_config, const char **error_string)
#define BLOCK_UNLISTED_IPS
#define KNET_DEFAULT_TRANSPORT
#define CANCEL_TOKEN_HOLD_ON_RETRANSMIT
#define FAIL_TO_RECV_CONST
#define DOWNCHECK_TIMEOUT
int totemconfig_configure_new_params(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
int totem_config_keyread(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
#define TOTEM_CONFIG_BINDNETADDR_NODELIST_SET
#define TOTEM_CONFIG_WARNING_TOTEM_NODEID_SET
#define TOTEM_CONFIG_WARNING_MEMBERS_IGNORED
#define TOTEM_CONFIG_WARNING_MEMBERS_DEPRECATED
int totemip_parse(struct totem_ip_address *totemip, const char *addr, enum totem_ip_version_enum ip_version)
const char * totemip_print(const struct totem_ip_address *addr)
int totemip_is_mcast(struct totem_ip_address *addr)
int totempg_iface_set(struct totem_ip_address *interface_addr, unsigned short ip_port, unsigned int iface_no)
int totempg_reconfigure(void)
int totempg_member_remove(const struct totem_ip_address *member, int ring_no)
int totempg_member_add(const struct totem_ip_address *member, int ring_no)