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];
105 if (strcmp(param_name,
"totem.token") == 0)
107 if (strcmp(param_name,
"totem.token_warning") == 0)
109 if (strcmp(param_name,
"totem.token_retransmit") == 0)
111 if (strcmp(param_name,
"totem.hold") == 0)
113 if (strcmp(param_name,
"totem.token_retransmits_before_loss_const") == 0)
115 if (strcmp(param_name,
"totem.join") == 0)
117 if (strcmp(param_name,
"totem.send_join") == 0)
119 if (strcmp(param_name,
"totem.consensus") == 0)
121 if (strcmp(param_name,
"totem.merge") == 0)
123 if (strcmp(param_name,
"totem.downcheck") == 0)
125 if (strcmp(param_name,
"totem.fail_recv_const") == 0)
127 if (strcmp(param_name,
"totem.seqno_unchanged_const") == 0)
129 if (strcmp(param_name,
"totem.heartbeat_failures_allowed") == 0)
131 if (strcmp(param_name,
"totem.max_network_delay") == 0)
133 if (strcmp(param_name,
"totem.window_size") == 0)
135 if (strcmp(param_name,
"totem.max_messages") == 0)
137 if (strcmp(param_name,
"totem.miss_count_const") == 0)
139 if (strcmp(param_name,
"totem.knet_pmtud_interval") == 0)
141 if (strcmp(param_name,
"totem.knet_mtu") == 0)
143 if (strcmp(param_name,
"totem.knet_compression_threshold") == 0)
145 if (strcmp(param_name,
"totem.knet_compression_level") == 0)
147 if (strcmp(param_name,
"totem.knet_compression_model") == 0)
149 if (strcmp(param_name,
"totem.block_unlisted_ips") == 0)
151 if (strcmp(param_name,
"totem.cancel_token_hold_on_retransmit") == 0)
162 const char *key_name,
const char *deleted_key,
unsigned int default_value,
163 int allow_zero_value)
168 (deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
169 (!allow_zero_value && *(uint32_t *)totem_get_param_by_name(
totem_config, key_name) == 0)) {
170 *(uint32_t *)totem_get_param_by_name(
totem_config, key_name) = default_value;
183 strcpy(runtime_key_name,
"runtime.config.");
184 strcat(runtime_key_name, key_name);
190 const char *key_name,
const char *deleted_key,
int default_value,
191 int allow_zero_value)
196 (deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
197 (!allow_zero_value && *(int32_t *)totem_get_param_by_name(
totem_config, key_name) == 0)) {
198 *(int32_t *)totem_get_param_by_name(
totem_config, key_name) = default_value;
211 strcpy(runtime_key_name,
"runtime.config.");
212 strcat(runtime_key_name, key_name);
218 const char *key_name,
const char *deleted_key,
const char *default_value)
222 char *new_config_value;
223 const void *config_value;
225 config_value = totem_get_param_by_name(
totem_config, key_name);
229 (deleted_key != NULL && strcmp(deleted_key, key_name) == 0)) {
237 free(new_config_value);
250 strcpy(runtime_key_name,
"runtime.config.");
251 strcat(runtime_key_name, key_name);
264 const char *key_name,
const char *deleted_key,
unsigned int default_value)
273 if ((deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
280 if (strcmp(str,
"yes") == 0) {
282 }
else if (strcmp(str,
"no") == 0) {
298 strcpy(runtime_key_name,
"runtime.config.");
299 strcat(runtime_key_name, key_name);
301 *(uint32_t *)totem_get_param_by_name(
totem_config, key_name) = val;
315 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.token_retransmits_before_loss_const", deleted_key,
335 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.window_size", deleted_key,
WINDOW_SIZE, 0);
341 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.knet_mtu", deleted_key,
KNET_MTU, 0);
343 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.token_retransmit", deleted_key,
346 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.hold", deleted_key,
351 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.consensus", deleted_key,
360 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.seqno_unchanged_const", deleted_key,
363 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.send_join", deleted_key, 0, 1);
365 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.heartbeat_failures_allowed", deleted_key, 0, 1);
367 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.knet_compression_threshold", deleted_key, 0, 1);
369 totem_volatile_config_set_int32_value(
totem_config, temp_map,
"totem.knet_compression_level", deleted_key, 0, 1);
371 totem_volatile_config_set_string_value(
totem_config, temp_map,
"totem.knet_compression_model", deleted_key,
"none");
373 totem_volatile_config_set_boolean_value(
totem_config, temp_map,
"totem.block_unlisted_ips", deleted_key,
376 totem_volatile_config_set_boolean_value(
totem_config, temp_map,
"totem.cancel_token_hold_on_retransmit",
383 const char **error_string)
386 static char local_error_reason[512];
387 static char addr_str_buf[INET6_ADDRSTRLEN];
388 const char *error_reason = local_error_reason;
391 int i, j, num_configured, members;
392 uint32_t tmp_config_value;
395 snprintf (local_error_reason,
sizeof(local_error_reason),
396 "The max_network_delay parameter (%d ms) may not be less than (%d ms).",
402 snprintf (local_error_reason,
sizeof(local_error_reason),
403 "The token timeout parameter (%d ms) may not be less than (%d ms).",
410 snprintf (local_error_reason,
sizeof(local_error_reason),
411 "The token warning parameter (%d%%) must be between 0 (disabled) and 100.",
418 snprintf (local_error_reason,
sizeof(local_error_reason),
419 "The token retransmit timeout parameter (%d ms) may not be less than (%d ms).",
423 snprintf (local_error_reason,
sizeof(local_error_reason),
424 "Not appropriate token or token_retransmits_before_loss_const value set");
430 snprintf (local_error_reason,
sizeof(local_error_reason),
431 "The token hold timeout parameter (%d ms) may not be less than (%d ms).",
437 snprintf (local_error_reason,
sizeof(local_error_reason),
438 "The join timeout parameter (%d ms) may not be less than (%d ms).",
444 snprintf (local_error_reason,
sizeof(local_error_reason),
445 "The consensus timeout parameter (%d ms) may not be less than (%d ms).",
451 snprintf (local_error_reason,
sizeof(local_error_reason),
452 "The consensus timeout parameter (%d ms) may not be less than join timeout (%d ms).",
458 snprintf (local_error_reason,
sizeof(local_error_reason),
459 "The merge timeout parameter (%d ms) may not be less than (%d ms).",
465 snprintf (local_error_reason,
sizeof(local_error_reason),
466 "The downcheck timeout parameter (%d ms) may not be less than (%d ms).",
476 if (num_configured == 0) {
483 if (num_configured > 1) {
487 assert(members != -1);
488 for (i=0; i < members; i++) {
489 snprintf(name_key,
sizeof(name_key),
"nodelist.node.%d.name", i);
492 snprintf (local_error_reason,
sizeof(local_error_reason),
493 "for a multi-link configuration, all nodes must have a 'name' attribute");
505 snprintf (local_error_reason,
sizeof(local_error_reason),
506 "Not all nodes have the same number of links");
520 sizeof(addr_str_buf));
522 snprintf (local_error_reason,
sizeof(local_error_reason),
523 "Nodes for link %d have different IP families "
524 "(compared %s with %s)", i,
536 snprintf (error_string_response,
sizeof(error_string_response),
537 "parse error in config: %s\n", error_reason);
538 *error_string = error_string_response;
546 const char *tmp_cipher;
547 const char *tmp_hash;
548 const char *tmp_model;
549 char *crypto_model_str;
552#ifdef ENABLE_UNENCRYPTED
557 tmp_cipher =
"aes256";
561 crypto_model_str = NULL;
563 tmp_model = crypto_model_str;
572 if (strcmp(str,
"on") == 0) {
573 tmp_cipher =
"aes256";
580 if (strcmp(str,
"none") == 0) {
583 if (strcmp(str,
"aes256") == 0) {
584 tmp_cipher =
"aes256";
586 if (strcmp(str,
"aes192") == 0) {
587 tmp_cipher =
"aes192";
589 if (strcmp(str,
"aes128") == 0) {
590 tmp_cipher =
"aes128";
596 if (strcmp(str,
"none") == 0) {
599 if (strcmp(str,
"md5") == 0) {
602 if (strcmp(str,
"sha1") == 0) {
605 if (strcmp(str,
"sha256") == 0) {
608 if (strcmp(str,
"sha384") == 0) {
611 if (strcmp(str,
"sha512") == 0) {
617#ifdef ENABLE_UNENCRYPTED
618 if ((strcmp(tmp_cipher,
"none") != 0) &&
619 (strcmp(tmp_hash,
"none") == 0)) {
620 *error_string =
"crypto_cipher requires crypto_hash with value other than none";
623 goto out_free_crypto_model_str;
626 if (strcmp(tmp_cipher,
"none") == 0 || strcmp(tmp_hash,
"none") == 0) {
627 *error_string =
"corosync is compiled to require enabled encryption";
630 goto out_free_crypto_model_str;
634 if (strcmp(tmp_model,
"none") == 0) {
638 *error_string =
"invalid crypto_model";
641 goto out_free_crypto_model_str;
659out_free_crypto_model_str:
660 free(crypto_model_str);
665static int nodelist_byname(
icmap_map_t map,
const char *find_name,
int strip_domain)
668 const char *iter_key;
671 unsigned int node_pos;
673 unsigned int namelen;
677 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos, name_str);
682 if (strcmp(name_str,
"name") && strcmp(name_str,
"ring0_addr")) {
688 namelen = strlen(name);
692 dot = strchr(name,
'.');
694 namelen = dot - name;
697 if (strncmp(find_name, name, namelen) == 0 &&
698 strlen(find_name) == namelen) {
708static int ipaddr_equal(
const struct sockaddr *addr1,
const struct sockaddr *addr2)
711 const void *addr1p, *addr2p;
713 if (addr1->sa_family != addr2->sa_family)
716 switch (addr1->sa_family) {
718 addrlen =
sizeof(
struct in_addr);
719 addr1p = &((
struct sockaddr_in *)addr1)->sin_addr;
720 addr2p = &((
struct sockaddr_in *)addr2)->sin_addr;
723 addrlen =
sizeof(
struct in6_addr);
724 addr1p = &((
struct sockaddr_in6 *)addr1)->sin6_addr;
725 addr2p = &((
struct sockaddr_in6 *)addr2)->sin6_addr;
731 return (memcmp(addr1p, addr2p, addrlen) == 0);
738static int find_local_node(
icmap_map_t map,
int use_cache)
740 char nodename2[PATH_MAX];
743 const char *iter_key;
744 unsigned int cached_pos;
747 struct ifaddrs *ifa, *ifa_list;
752 struct utsname utsname;
761 res = uname(&utsname);
765 node = utsname.nodename;
768 node_pos = nodelist_byname(map, node, 0);
777 strcpy(nodename2, node);
778 dot = strrchr(nodename2,
'.');
782 node_pos = nodelist_byname(map, nodename2, 0);
787 dot = strrchr(nodename2,
'.');
790 node_pos = nodelist_byname(map, nodename2, 1);
800 if (getifaddrs(&ifa_list))
803 for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
807 strcpy(nodename2, node);
812 if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6) {
816 if (sa->sa_family == AF_INET) {
817 salen =
sizeof(
struct sockaddr_in);
819 if (sa->sa_family == AF_INET6) {
820 salen =
sizeof(
struct sockaddr_in6);
823 if (getnameinfo(sa, salen,
824 nodename2,
sizeof(nodename2),
827 node_pos = nodelist_byname(map, nodename2, 0);
834 dot = strchr(nodename2,
'.');
838 node_pos = nodelist_byname(map, nodename2, 0);
847 if (getnameinfo(sa,
sizeof(*sa),
848 nodename2,
sizeof(nodename2),
849 NULL, 0, NI_NUMERICHOST))
852 node_pos = nodelist_byname(map, nodename2, 0);
861 freeifaddrs(ifa_list);
880 char *dbnodename = NULL;
881 struct addrinfo hints;
882 struct addrinfo *result = NULL, *rp = NULL;
884 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos, name_str);
891 if (strcmp(name_str,
"name") && strcmp(name_str,
"ring0_addr")) {
898 memset(&hints, 0,
sizeof(
struct addrinfo));
899 hints.ai_family = AF_UNSPEC;
900 hints.ai_socktype = SOCK_DGRAM;
902 hints.ai_protocol = IPPROTO_UDP;
904 if (getaddrinfo(dbnodename, NULL, &hints, &result)) {
908 for (rp = result; rp != NULL; rp = rp->ai_next) {
909 for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
911 ipaddr_equal(rp->ai_addr, ifa->ifa_addr)) {
912 freeaddrinfo(result);
919 freeaddrinfo(result);
923 freeifaddrs(ifa_list);
947 if (strcmp(str,
"ipv4") == 0) {
950 if (strcmp(str,
"ipv6") == 0) {
953 if (strcmp(str,
"ipv6-4") == 0) {
956 if (strcmp(str,
"ipv4-6") == 0) {
966static uint16_t generate_cluster_id (
const char *cluster_name)
971 for (i = 0; i < strlen(cluster_name); i++) {
973 value += cluster_name[i];
976 return (
value & 0xFFFF);
979static int get_cluster_mcast_addr (
980 const char *cluster_name,
981 unsigned int linknumber,
986 char addr[INET6_ADDRSTRLEN + 1];
989 if (cluster_name == NULL) {
993 clusterid = generate_cluster_id(cluster_name) + linknumber;
994 memset (res, 0,
sizeof(*res));
996 switch (ip_version) {
999 snprintf(
addr,
sizeof(
addr),
"239.192.%d.%d", clusterid >> 8, clusterid % 0xFF);
1003 snprintf(
addr,
sizeof(
addr),
"ff15::%x", clusterid);
1018static unsigned int generate_nodeid(
1030 memcpy (&
nodeid, &totemip.addr, sizeof (
unsigned int));
1032#if __BYTE_ORDER == __LITTLE_ENDIAN
1042static int check_for_duplicate_nodeids(
1044 const char **error_string)
1048 const char *iter_key;
1052 char *ring0_addr=NULL;
1053 char *ring0_addr1=NULL;
1054 unsigned int node_pos;
1055 unsigned int node_pos1;
1056 unsigned int last_node_pos = -1;
1058 unsigned int nodeid1;
1063 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos, tmp_key);
1073 if (last_node_pos == node_pos) {
1076 last_node_pos = node_pos;
1099 while (((iter_key =
icmap_iter_next(subiter, NULL, NULL)) != NULL) && (node_pos1 < node_pos)) {
1100 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos1, tmp_key);
1101 if ((res != 2) || (node_pos1 >= node_pos)) {
1105 if (strcmp(tmp_key,
"nodeid") != 0) {
1117 if (nodeid1 == -1) {
1124 snprintf (error_string_response,
sizeof(error_string_response),
1125 "Nodeid %u%s%s%s appears twice in corosync.conf",
nodeid,
1126 autogenerated?
"(autogenerated from ":
"",
1127 autogenerated?ring0_addr:
"",
1128 autogenerated?
")":
"");
1129 *error_string = error_string_response;
1150 for (interface = 0;
interface <
INTERFACE_MAX; interface++) {
1160 snprintf(runtime_key_name,
sizeof(runtime_key_name),
1161 "runtime.config.totem.interface.%d.knet_ping_timeout", interface);
1168 snprintf(runtime_key_name,
sizeof(runtime_key_name),
1169 "runtime.config.totem.interface.%d.knet_ping_interval", interface);
1182static int compute_and_set_totempg_interfaces(
struct totem_interface *set1,
1185 int ring_no, set1_pos, set2_pos;
1189 memset(&empty_ip_address, 0,
sizeof(empty_ip_address));
1192 if (!set1[ring_no].configured && !set2[ring_no].configured) {
1196 for (set1_pos = 0; set1_pos < set1[ring_no].
member_count; set1_pos++) {
1197 for (set2_pos = 0; set2_pos < set2[ring_no].
member_count; set2_pos++) {
1202 if (memcmp(&set1[ring_no].member_list[set1_pos],
1203 &set2[ring_no].member_list[set2_pos],
1205 memset(&set1[ring_no].member_list[set1_pos], 0,
1207 memset(&set2[ring_no].member_list[set2_pos], 0,
1215 for (set1_pos = 0; set1_pos < set1[ring_no].
member_count; set1_pos++) {
1220 if (memcmp(&set1[ring_no].member_list[set1_pos], &empty_ip_address,
sizeof(empty_ip_address)) != 0) {
1222 "removing dynamic member %s for ring %u",
1229 if (!set2[ring_no].configured) {
1232 for (set2_pos = 0; set2_pos < set2[ring_no].
member_count; set2_pos++) {
1237 if (memcmp(&set2[ring_no].member_list[set2_pos], &empty_ip_address,
sizeof(empty_ip_address)) != 0) {
1239 "adding dynamic member %s for ring %u",
1261 int local_node_pos = find_local_node(map, 0);
1318 char addr_buf[INET6_ADDRSTRLEN];
1327 "New config has different knet transport for link %d. Internal value was NOT changed.\n", i);
1347 strncpy(addr_buf, ip_str,
sizeof(addr_buf));
1348 addr_buf[
sizeof(addr_buf) - 1] =
'\0';
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");
1364 *error_string = error_string_response;
1372 int reload,
const char **error_string)
1375 const char *iter_key, *iter_key2;
1377 unsigned int node_pos;
1380 char *node_addr_str;
1382 unsigned int linknumber = 0;
1384 int last_node_pos = -1;
1396 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos, tmp_key);
1401 if (node_pos == last_node_pos) {
1404 last_node_pos = node_pos;
1416 res = sscanf(iter_key2,
"nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
1417 if (res != 3 || strcmp(tmp_key2,
"_addr") != 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",
1424 *error_string = error_string_response;
1446 sprintf(error_string_response,
1447 "An IPV6 network requires that a node ID be specified "
1448 "for address '%s'.", node_addr_str);
1449 *error_string = error_string_response;
1472 sprintf(error_string_response,
1473 "Knet requires an explicit nodeid to be specified "
1474 "for address '%s'.", node_addr_str);
1475 *error_string = error_string_response;
1481 sprintf(error_string_response,
1482 "Knet requires nodeid to be less than %u "
1483 "for address '%s'.", KNET_MAX_HOST, node_addr_str);
1484 *error_string = error_string_response;
1497 sprintf(error_string_response,
"failed to parse node address '%s'\n", node_addr_str);
1498 *error_string = error_string_response;
1503 free(node_addr_str);
1509 free(node_addr_str);
1521 if (check_things_have_not_changed(
totem_config, error_string) == -1) {
1534 char *node_addr_str;
1535 unsigned int linknumber = 0;
1537 const char *iter_key;
1539 node_pos = find_local_node(map, 1);
1540 if (node_pos > -1) {
1547 res = sscanf(iter_key,
"nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
1548 if (res != 3 || strcmp(tmp_key2,
"_addr") != 0) {
1558 free(node_addr_str);
1565 const char **error_string, uint64_t *warnings,
1569 unsigned int linknumber = 0;
1570 int member_count = 0;
1573 const char *iter_key;
1574 const char *member_iter_key;
1580 char *cluster_name = NULL;
1598 cluster_name = NULL;
1603 res = sscanf(iter_key,
"totem.interface.%[^.].%s", linknumber_key, tmp_key);
1615 linknumber = atoi(linknumber_key);
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",
1622 *error_string = error_string_response;
1639 sprintf(error_string_response,
"failed to parse bindnet address '%s'\n", str);
1640 *error_string = error_string_response;
1659 sprintf(error_string_response,
"failed to parse mcast address '%s'\n", str);
1660 *error_string = error_string_response;
1685 (void)get_cluster_mcast_addr (cluster_name,
1694 if (strcmp (str,
"yes") == 0) {
1730#ifdef KNET_TRANSPORT_SCTP
1731 if (strcmp(str,
"sctp") == 0) {
1736 if (strcmp(str,
"udp") == 0) {
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";
1785 while ((member_iter_key =
icmap_iter_next(member_iter, NULL, NULL)) != NULL) {
1786 if (member_count == 0) {
1800 sprintf(error_string_response,
"failed to parse node address '%s'\n", str);
1801 *error_string = error_string_response;
1827 const char **error_string,
1831 char *str, *ring0_addr_str;
1842 *error_string =
"Out of memory trying to allocate ethernet interface storage area";
1849 if (strcmp (str,
"udpu") == 0) {
1851 }
else if (strcmp (str,
"udp") == 0) {
1855 if (strcmp (str,
"knet") == 0) {
1859 *error_string =
"Invalid transport type. Should be udpu, udp or knet";
1861 *error_string =
"Invalid transport type. Should be knet";
1889 *error_string =
"totem.link_mode is too long";
1904 if (strcmp (str,
"yes") == 0) {
1931 free(ring0_addr_str);
2010 if (local_node_pos != -1) {
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";
2071 const char **error_string)
2073 static char local_error_reason[512];
2074 char parse_error[512];
2075 const char *error_reason = local_error_reason;
2078 int num_configured = 0;
2086 if (num_configured == 0) {
2087 error_reason =
"No interfaces defined";
2093 error_reason =
"No valid name found for local host";
2114 snprintf (local_error_reason,
sizeof(local_error_reason),
2115 "No multicast address specified for interface %u", i);
2121 snprintf (local_error_reason,
sizeof(local_error_reason),
2122 "No multicast port specified for interface %u", i);
2127 snprintf (local_error_reason,
sizeof(local_error_reason),
2128 "Invalid TTL (should be 0..255) for interface %u", i);
2137 snprintf (local_error_reason,
sizeof(local_error_reason),
2138 "Can only set ttl on multicast transport types for interface %u", i);
2142 snprintf (local_error_reason,
sizeof(local_error_reason),
2143 "Invalid link priority (should be 0..255) for interface %u", i);
2148 snprintf (local_error_reason,
sizeof(local_error_reason),
2149 "Can only set link priority on knet transport type for interface %u", i);
2155 snprintf (local_error_reason,
sizeof(local_error_reason),
2156 "An IPV6 network requires that a node ID be specified for interface %u", i);
2163 snprintf (local_error_reason,
sizeof(local_error_reason),
2164 "Multicast address family does not match bind address family for interface %u", i);
2169 snprintf (local_error_reason,
sizeof(local_error_reason),
2170 "mcastaddr is not a correct multicast address for interface %u", i);
2178 error_reason =
"This totem parser can only parse version 2 configurations.";
2186 if (check_for_duplicate_nodeids(
totem_config, error_string) == -1) {
2196 snprintf (local_error_reason,
sizeof(local_error_reason),
2197 "The Knet link mode \"%s\" specified is invalid. It must be active, passive or rr.\n",
totem_config->
link_mode);
2206 if (interface_max < num_configured) {
2207 snprintf (parse_error,
sizeof(parse_error),
2208 "%d is too many configured interfaces for non-Knet transport.",
2210 error_reason = parse_error;
2219 snprintf (parse_error,
sizeof(parse_error),
2220 "crypto_cipher & crypto_hash are only valid for the Knet transport.");
2221 error_reason = parse_error;
2238 snprintf (error_string_response,
sizeof(error_string_response),
2239 "parse error in config: %s\n", error_reason);
2240 *error_string = error_string_response;
2245static int read_keyfile (
2246 const char *key_location,
2248 const char **error_string)
2253 char error_str[100];
2254 const char *error_ptr;
2256 fd = open (key_location, O_RDONLY);
2258 error_ptr = qb_strerror_r(errno, error_str,
sizeof(error_str));
2259 snprintf (error_string_response,
sizeof(error_string_response),
2260 "Could not open %s: %s\n",
2261 key_location, error_ptr);
2266 saved_errno = errno;
2270 error_ptr = qb_strerror_r (saved_errno, error_str,
sizeof(error_str));
2271 snprintf (error_string_response,
sizeof(error_string_response),
2272 "Could not read %s: %s\n",
2273 key_location, error_ptr);
2278 snprintf (error_string_response,
sizeof(error_string_response),
2279 "Could only read %d bits of minimum %u bits from %s.\n",
2289 *error_string = error_string_response;
2296 const char **error_string)
2299 char *key_location = NULL;
2319 res = read_keyfile(key_location,
totem_config, error_string);
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");
2360 *error_string = error_string_response;
2367 if (totem_get_crypto(
totem_config, map, error_string) != 0) {
2385 if (token_warning_ms < totem_config->token_retransmit_timeout)
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,
2423 const char *deleted_key = NULL;
2424 const char *error_string;
2439 if (!
param && strcmp(key_name,
"totem.token_coefficient") != 0)
2447 deleted_key = key_name;
2473 const char **error_string)
2475 uint64_t warnings = 0LL;
2477 get_interface_params(
totem_config, map, error_string, &warnings, 1);
2478 if (put_nodelist_members_to_config (
totem_config, map, 1, error_string)) {
2486 (void)find_local_node(map, 0);
2499 assert(new_interfaces != NULL);
2511 free(new_interfaces);
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)
struct icmap_map * icmap_map_t
icmap type.
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.
struct icmap_track * icmap_track_t
Track type.
#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)