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).",
411 "The token warning parameter (%d%%) must be between 0 (disabled) and 100.",
419 "The token retransmit timeout parameter (%d ms) may not be less than (%d ms).",
424 "Not appropriate token or token_retransmits_before_loss_const value set");
431 "The token hold timeout parameter (%d ms) may not be less than (%d ms).",
438 "The join timeout parameter (%d ms) may not be less than (%d ms).",
445 "The consensus timeout parameter (%d ms) may not be less than (%d ms).",
452 "The consensus timeout parameter (%d ms) may not be less than join timeout (%d ms).",
459 "The merge timeout parameter (%d ms) may not be less than (%d ms).",
466 "The downcheck timeout parameter (%d ms) may not be less than (%d ms).",
493 "for a multi-link configuration, all nodes must have a 'name' attribute");
506 "Not all nodes have the same number of links");
523 "Nodes for link %d have different IP families "
524 "(compared %s with %s)",
i,
536 snprintf (error_string_response,
sizeof(error_string_response),
552#ifdef ENABLE_UNENCRYPTED
617#ifdef ENABLE_UNENCRYPTED
620 *
error_string =
"crypto_cipher requires crypto_hash with value other than none";
627 *
error_string =
"corosync is compiled to require enabled encryption";
716 switch (
addr1->sa_family) {
911 ipaddr_equal(
rp->ai_addr,
ifa->ifa_addr)) {
976 return (
value & 0xFFFF);
979static int get_cluster_mcast_addr (
981 unsigned int linknumber,
996 switch (ip_version) {
1018static unsigned int generate_nodeid(
1032#if __BYTE_ORDER == __LITTLE_ENDIAN
1042static int check_for_duplicate_nodeids(
1124 snprintf (error_string_response,
sizeof(error_string_response),
1125 "Nodeid %u%s%s%s appears twice in corosync.conf",
nodeid,
1161 "runtime.config.totem.interface.%d.knet_ping_timeout",
interface);
1169 "runtime.config.totem.interface.%d.knet_ping_interval",
interface);
1222 "removing dynamic member %s for ring %u",
1239 "adding dynamic member %s for ring %u",
1327 "New config has different knet transport for link %d. Internal value was NOT changed.\n",
i);
1350 "new config has different address for link %d (addr changed from %s to %s). Internal value was NOT changed.\n",
1362 snprintf (error_string_response,
sizeof(error_string_response),
1363 "To reconfigure an interface it must be deleted and recreated. A working interface needs to be available to corosync at all times");
1382 unsigned int linknumber = 0;
1421 snprintf (error_string_response,
sizeof(error_string_response),
1422 "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
1446 sprintf(error_string_response,
1447 "An IPV6 network requires that a node ID be specified "
1472 sprintf(error_string_response,
1473 "Knet requires an explicit nodeid to be specified "
1481 sprintf(error_string_response,
1482 "Knet requires nodeid to be less than %u "
1535 unsigned int linknumber = 0;
1569 unsigned int linknumber = 0;
1570 int member_count = 0;
1618 snprintf (error_string_response,
sizeof(error_string_response),
1619 "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
1639 sprintf(error_string_response,
"failed to parse bindnet address '%s'\n",
str);
1659 sprintf(error_string_response,
"failed to parse mcast address '%s'\n",
str);
1730#ifdef KNET_TRANSPORT_SCTP
1740#ifdef KNET_TRANSPORT_SCTP
1741 *
error_string =
"Unrecognised knet_transport. expected 'udp' or 'sctp'";
1743 *
error_string =
"Unrecognised knet_transport. only 'udp' is supported";
1786 if (member_count == 0) {
1800 sprintf(error_string_response,
"failed to parse node address '%s'\n",
str);
1842 *
error_string =
"Out of memory trying to allocate ethernet interface storage area";
1859 *
error_string =
"Invalid transport type. Should be udpu, udp or knet";
1861 *
error_string =
"Invalid transport type. Should be knet";
2019 *
error_string =
"Knet requires an explicit nodeid for the local node";
2032 *
error_string =
"An IPV6 network requires that a node ID be specified";
2115 "No multicast address specified for interface %u",
i);
2122 "No multicast port specified for interface %u",
i);
2128 "Invalid TTL (should be 0..255) for interface %u",
i);
2138 "Can only set ttl on multicast transport types for interface %u",
i);
2143 "Invalid link priority (should be 0..255) for interface %u",
i);
2149 "Can only set link priority on knet transport type for interface %u",
i);
2156 "An IPV6 network requires that a node ID be specified for interface %u",
i);
2164 "Multicast address family does not match bind address family for interface %u",
i);
2170 "mcastaddr is not a correct multicast address for interface %u",
i);
2178 error_reason =
"This totem parser can only parse version 2 configurations.";
2197 "The Knet link mode \"%s\" specified is invalid. It must be active, passive or rr.\n",
totem_config->
link_mode);
2208 "%d is too many configured interfaces for non-Knet transport.",
2220 "crypto_cipher & crypto_hash are only valid for the Knet transport.");
2238 snprintf (error_string_response,
sizeof(error_string_response),
2245static int read_keyfile (
2259 snprintf (error_string_response,
sizeof(error_string_response),
2260 "Could not open %s: %s\n",
2271 snprintf (error_string_response,
sizeof(error_string_response),
2272 "Could not read %s: %s\n",
2278 snprintf (error_string_response,
sizeof(error_string_response),
2279 "Could only read %d bits of minimum %u bits from %s.\n",
2328 sprintf(error_string_response,
"key is too long");
2332 sprintf(error_string_response,
"key is too short");
2339 sprintf(error_string_response,
"can't load private key");
2387 "The token warning interval (%d ms) is less than the token retransmit timeout (%d ms) "
2388 "which can lead to spurious token warnings. Consider increasing the token_warning parameter.",
2401 "seqno unchanged const (%d rotations) Maximum network MTU %d",
2404 "window size per rotation (%d messages) maximum messages per rotation (%d messages)",
2413static void totem_change_notify(
2415 const char *key_name,
2439 if (!
param &&
strcmp(key_name,
"totem.token_coefficient") != 0)
2486 (
void)find_local_node(
map, 0);
2527 totem_change_notify,
unsigned int nodeid
the ID of the node whose info needs updating
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_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_WARNING
#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
void totem_calc_knet_ping_timers(struct totem_config *totem_config, icmap_map_t temp_map)
#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)