45 #include <sys/socket.h>
46 #include <sys/types.h>
51 #include <netinet/in.h>
52 #include <arpa/inet.h>
53 #include <sys/param.h>
54 #include <sys/utsname.h>
57 #include <qb/qblist.h>
58 #include <qb/qbdefs.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
80 #define WINDOW_SIZE 50
81 #define MAX_MESSAGES 17
82 #define MISS_COUNT_CONST 5
83 #define BLOCK_UNLISTED_IPS 1
86 #define KNET_PING_INTERVAL 1000
87 #define KNET_PING_TIMEOUT 2000
88 #define KNET_PING_PRECISION 2048
89 #define KNET_PONG_COUNT 2
90 #define KNET_PMTUD_INTERVAL 30
91 #define KNET_DEFAULT_TRANSPORT KNET_TRANSPORT_UDP
93 #define DEFAULT_PORT 5405
95 static char error_string_response[768];
101 if (strcmp(param_name,
"totem.token") == 0)
103 if (strcmp(param_name,
"totem.token_warning") == 0)
105 if (strcmp(param_name,
"totem.token_retransmit") == 0)
107 if (strcmp(param_name,
"totem.hold") == 0)
109 if (strcmp(param_name,
"totem.token_retransmits_before_loss_const") == 0)
111 if (strcmp(param_name,
"totem.join") == 0)
113 if (strcmp(param_name,
"totem.send_join") == 0)
115 if (strcmp(param_name,
"totem.consensus") == 0)
117 if (strcmp(param_name,
"totem.merge") == 0)
119 if (strcmp(param_name,
"totem.downcheck") == 0)
121 if (strcmp(param_name,
"totem.fail_recv_const") == 0)
123 if (strcmp(param_name,
"totem.seqno_unchanged_const") == 0)
125 if (strcmp(param_name,
"totem.heartbeat_failures_allowed") == 0)
127 if (strcmp(param_name,
"totem.max_network_delay") == 0)
129 if (strcmp(param_name,
"totem.window_size") == 0)
131 if (strcmp(param_name,
"totem.max_messages") == 0)
133 if (strcmp(param_name,
"totem.miss_count_const") == 0)
135 if (strcmp(param_name,
"totem.knet_pmtud_interval") == 0)
137 if (strcmp(param_name,
"totem.knet_compression_threshold") == 0)
139 if (strcmp(param_name,
"totem.knet_compression_level") == 0)
141 if (strcmp(param_name,
"totem.knet_compression_model") == 0)
143 if (strcmp(param_name,
"totem.block_unlisted_ips") == 0)
154 const char *key_name,
const char *deleted_key,
unsigned int default_value,
155 int allow_zero_value)
160 (deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
161 (!allow_zero_value && *(uint32_t *)totem_get_param_by_name(
totem_config, key_name) == 0)) {
162 *(uint32_t *)totem_get_param_by_name(
totem_config, key_name) = default_value;
175 strcpy(runtime_key_name,
"runtime.config.");
176 strcat(runtime_key_name, key_name);
182 const char *key_name,
const char *deleted_key,
int default_value,
183 int allow_zero_value)
188 (deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
189 (!allow_zero_value && *(int32_t *)totem_get_param_by_name(
totem_config, key_name) == 0)) {
190 *(int32_t *)totem_get_param_by_name(
totem_config, key_name) = default_value;
203 strcpy(runtime_key_name,
"runtime.config.");
204 strcat(runtime_key_name, key_name);
210 const char *key_name,
const char *deleted_key,
const char *default_value)
214 char *new_config_value;
215 const void *config_value;
217 config_value = totem_get_param_by_name(
totem_config, key_name);
221 (deleted_key != NULL && strcmp(deleted_key, key_name) == 0)) {
229 free(new_config_value);
242 strcpy(runtime_key_name,
"runtime.config.");
243 strcat(runtime_key_name, key_name);
256 const char *key_name,
const char *deleted_key,
unsigned int default_value)
265 if ((deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
272 if (strcmp(str,
"yes") == 0) {
274 }
else if (strcmp(str,
"no") == 0) {
290 strcpy(runtime_key_name,
"runtime.config.");
291 strcat(runtime_key_name, key_name);
293 *(uint32_t *)totem_get_param_by_name(
totem_config, key_name) = val;
307 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.token_retransmits_before_loss_const", deleted_key,
327 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.window_size", deleted_key,
WINDOW_SIZE, 0);
334 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.token_retransmit", deleted_key,
337 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.hold", deleted_key,
342 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.consensus", deleted_key,
351 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.seqno_unchanged_const", deleted_key,
354 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.send_join", deleted_key, 0, 1);
356 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.heartbeat_failures_allowed", deleted_key, 0, 1);
358 totem_volatile_config_set_uint32_value(
totem_config, temp_map,
"totem.knet_compression_threshold", deleted_key, 0, 1);
360 totem_volatile_config_set_int32_value(
totem_config, temp_map,
"totem.knet_compression_level", deleted_key, 0, 1);
362 totem_volatile_config_set_string_value(
totem_config, temp_map,
"totem.knet_compression_model", deleted_key,
"none");
364 totem_volatile_config_set_boolean_value(
totem_config, temp_map,
"totem.block_unlisted_ips", deleted_key,
371 const char **error_string)
374 static char local_error_reason[512];
375 static char addr_str_buf[INET6_ADDRSTRLEN];
376 const char *error_reason = local_error_reason;
379 int i, j, num_configured, members;
380 uint32_t tmp_config_value;
383 snprintf (local_error_reason,
sizeof(local_error_reason),
384 "The max_network_delay parameter (%d ms) may not be less than (%d ms).",
390 snprintf (local_error_reason,
sizeof(local_error_reason),
391 "The token timeout parameter (%d ms) may not be less than (%d ms).",
397 snprintf (local_error_reason,
sizeof(local_error_reason),
398 "The token warning parameter (%d%%) must be between 0 (disabled) and 100.",
405 snprintf (local_error_reason,
sizeof(local_error_reason),
406 "The token retransmit timeout parameter (%d ms) may not be less than (%d ms).",
410 snprintf (local_error_reason,
sizeof(local_error_reason),
411 "Not appropriate token or token_retransmits_before_loss_const value set");
417 snprintf (local_error_reason,
sizeof(local_error_reason),
418 "The token hold timeout parameter (%d ms) may not be less than (%d ms).",
424 snprintf (local_error_reason,
sizeof(local_error_reason),
425 "The join timeout parameter (%d ms) may not be less than (%d ms).",
431 snprintf (local_error_reason,
sizeof(local_error_reason),
432 "The consensus timeout parameter (%d ms) may not be less than (%d ms).",
438 snprintf (local_error_reason,
sizeof(local_error_reason),
439 "The consensus timeout parameter (%d ms) may not be less than join timeout (%d ms).",
445 snprintf (local_error_reason,
sizeof(local_error_reason),
446 "The merge timeout parameter (%d ms) may not be less than (%d ms).",
452 snprintf (local_error_reason,
sizeof(local_error_reason),
453 "The downcheck timeout parameter (%d ms) may not be less than (%d ms).",
463 if (num_configured == 0) {
470 if (num_configured > 1) {
474 assert(members != -1);
475 for (i=0; i < members; i++) {
476 snprintf(name_key,
sizeof(name_key),
"nodelist.node.%d.name", i);
479 snprintf (local_error_reason,
sizeof(local_error_reason),
480 "for a multi-link configuration, all nodes must have a 'name' attribute");
492 snprintf (local_error_reason,
sizeof(local_error_reason),
493 "Not all nodes have the same number of links");
507 sizeof(addr_str_buf));
509 snprintf (local_error_reason,
sizeof(local_error_reason),
510 "Nodes for link %d have different IP families "
511 "(compared %s with %s)", i,
523 snprintf (error_string_response,
sizeof(error_string_response),
524 "parse error in config: %s\n", error_reason);
525 *error_string = error_string_response;
533 const char *tmp_cipher;
534 const char *tmp_hash;
535 const char *tmp_model;
542 if (strcmp(str,
"nss") == 0) {
545 if (strcmp(str,
"openssl") == 0) {
546 tmp_model =
"openssl";
554 if (strcmp(str,
"on") == 0) {
555 tmp_cipher =
"aes256";
562 if (strcmp(str,
"none") == 0) {
565 if (strcmp(str,
"aes256") == 0) {
566 tmp_cipher =
"aes256";
568 if (strcmp(str,
"aes192") == 0) {
569 tmp_cipher =
"aes192";
571 if (strcmp(str,
"aes128") == 0) {
572 tmp_cipher =
"aes128";
578 if (strcmp(str,
"none") == 0) {
581 if (strcmp(str,
"md5") == 0) {
584 if (strcmp(str,
"sha1") == 0) {
587 if (strcmp(str,
"sha256") == 0) {
590 if (strcmp(str,
"sha384") == 0) {
593 if (strcmp(str,
"sha512") == 0) {
599 if ((strcmp(tmp_cipher,
"none") != 0) &&
600 (strcmp(tmp_hash,
"none") == 0)) {
601 *error_string =
"crypto_cipher requires crypto_hash with value other than none";
605 if (strcmp(tmp_model,
"none") == 0) {
606 *error_string =
"crypto_model should be 'nss' or 'openssl'";
623 static int nodelist_byname(
icmap_map_t map,
const char *find_name,
int strip_domain)
626 const char *iter_key;
629 unsigned int node_pos;
631 unsigned int namelen;
635 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos, name_str);
640 if (strcmp(name_str,
"name") && strcmp(name_str,
"ring0_addr")) {
646 namelen = strlen(name);
650 dot = strchr(name,
'.');
652 namelen = name - dot - 1;
655 if (strncmp(find_name, name, namelen) == 0 &&
656 strlen(find_name) == strlen(name)) {
666 static int ipaddr_equal(
const struct sockaddr *addr1,
const struct sockaddr *addr2)
669 const void *addr1p, *addr2p;
671 if (addr1->sa_family != addr2->sa_family)
674 switch (addr1->sa_family) {
676 addrlen =
sizeof(
struct in_addr);
677 addr1p = &((
struct sockaddr_in *)addr1)->sin_addr;
678 addr2p = &((
struct sockaddr_in *)addr2)->sin_addr;
681 addrlen =
sizeof(
struct in6_addr);
682 addr1p = &((
struct sockaddr_in6 *)addr1)->sin6_addr;
683 addr2p = &((
struct sockaddr_in6 *)addr2)->sin6_addr;
689 return (memcmp(addr1p, addr2p, addrlen) == 0);
696 static int find_local_node(
icmap_map_t map,
int use_cache)
698 char nodename2[PATH_MAX];
701 const char *iter_key;
702 unsigned int cached_pos;
705 struct ifaddrs *ifa, *ifa_list;
710 struct utsname utsname;
719 res = uname(&utsname);
723 node = utsname.nodename;
726 node_pos = nodelist_byname(map, node, 0);
735 strcpy(nodename2, node);
736 dot = strrchr(nodename2,
'.');
740 node_pos = nodelist_byname(map, nodename2, 0);
745 dot = strrchr(nodename2,
'.');
748 node_pos = nodelist_byname(map, nodename2, 1);
758 if (getifaddrs(&ifa_list))
761 for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
765 strcpy(nodename2, node);
770 if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6) {
774 if (sa->sa_family == AF_INET) {
775 salen =
sizeof(
struct sockaddr_in);
777 if (sa->sa_family == AF_INET6) {
778 salen =
sizeof(
struct sockaddr_in6);
781 if (getnameinfo(sa, salen,
782 nodename2,
sizeof(nodename2),
785 node_pos = nodelist_byname(map, nodename2, 0);
792 dot = strchr(nodename2,
'.');
796 node_pos = nodelist_byname(map, nodename2, 0);
805 if (getnameinfo(sa,
sizeof(*sa),
806 nodename2,
sizeof(nodename2),
807 NULL, 0, NI_NUMERICHOST))
810 node_pos = nodelist_byname(map, nodename2, 0);
819 freeifaddrs(ifa_list);
838 char *dbnodename = NULL;
839 struct addrinfo hints;
840 struct addrinfo *result = NULL, *rp = NULL;
842 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos, name_str);
849 if (strcmp(name_str,
"name") && strcmp(name_str,
"ring0_addr")) {
856 memset(&hints, 0,
sizeof(
struct addrinfo));
857 hints.ai_family = AF_UNSPEC;
858 hints.ai_socktype = SOCK_DGRAM;
860 hints.ai_protocol = IPPROTO_UDP;
862 if (getaddrinfo(dbnodename, NULL, &hints, &result)) {
866 for (rp = result; rp != NULL; rp = rp->ai_next) {
867 for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
869 ipaddr_equal(rp->ai_addr, ifa->ifa_addr)) {
870 freeaddrinfo(result);
877 freeaddrinfo(result);
881 freeifaddrs(ifa_list);
903 if (strcmp(str,
"ipv4") == 0) {
906 if (strcmp(str,
"ipv6") == 0) {
909 if (strcmp(str,
"ipv6-4") == 0) {
912 if (strcmp(str,
"ipv4-6") == 0) {
921 static uint16_t generate_cluster_id (
const char *cluster_name)
926 for (i = 0; i < strlen(cluster_name); i++) {
928 value += cluster_name[i];
931 return (
value & 0xFFFF);
934 static int get_cluster_mcast_addr (
935 const char *cluster_name,
936 unsigned int linknumber,
941 char addr[INET6_ADDRSTRLEN + 1];
944 if (cluster_name == NULL) {
948 clusterid = generate_cluster_id(cluster_name) + linknumber;
949 memset (res, 0,
sizeof(*res));
951 switch (ip_version) {
954 snprintf(
addr,
sizeof(
addr),
"239.192.%d.%d", clusterid >> 8, clusterid % 0xFF);
958 snprintf(
addr,
sizeof(
addr),
"ff15::%x", clusterid);
972 static unsigned int generate_nodeid(
984 memcpy (&
nodeid, &totemip.addr, sizeof (
unsigned int));
986 #if __BYTE_ORDER == __LITTLE_ENDIAN
996 static int check_for_duplicate_nodeids(
998 const char **error_string)
1002 const char *iter_key;
1006 char *ring0_addr=NULL;
1007 char *ring0_addr1=NULL;
1008 unsigned int node_pos;
1009 unsigned int node_pos1;
1010 unsigned int last_node_pos = -1;
1012 unsigned int nodeid1;
1017 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos, tmp_key);
1027 if (last_node_pos == node_pos) {
1030 last_node_pos = node_pos;
1053 while (((iter_key =
icmap_iter_next(subiter, NULL, NULL)) != NULL) && (node_pos1 < node_pos)) {
1054 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos1, tmp_key);
1055 if ((res != 2) || (node_pos1 >= node_pos)) {
1059 if (strcmp(tmp_key,
"nodeid") != 0) {
1071 if (nodeid1 == -1) {
1078 snprintf (error_string_response,
sizeof(error_string_response),
1079 "Nodeid %u%s%s%s appears twice in corosync.conf",
nodeid,
1080 autogenerated?
"(autogenerated from ":
"",
1081 autogenerated?ring0_addr:
"",
1082 autogenerated?
")":
"");
1083 *error_string = error_string_response;
1104 for (interface = 0;
interface <
INTERFACE_MAX; interface++) {
1114 snprintf(runtime_key_name,
sizeof(runtime_key_name),
1115 "runtime.config.totem.interface.%d.knet_ping_timeout", interface);
1122 snprintf(runtime_key_name,
sizeof(runtime_key_name),
1123 "runtime.config.totem.interface.%d.knet_ping_interval", interface);
1136 static void compute_and_set_totempg_interfaces(
struct totem_interface *set1,
1139 int ring_no, set1_pos, set2_pos;
1142 memset(&empty_ip_address, 0,
sizeof(empty_ip_address));
1145 if (!set1[ring_no].configured && !set2[ring_no].configured) {
1149 for (set1_pos = 0; set1_pos < set1[ring_no].
member_count; set1_pos++) {
1150 for (set2_pos = 0; set2_pos < set2[ring_no].
member_count; set2_pos++) {
1155 if (memcmp(&set1[ring_no].member_list[set1_pos],
1156 &set2[ring_no].member_list[set2_pos],
1158 memset(&set1[ring_no].member_list[set1_pos], 0,
1160 memset(&set2[ring_no].member_list[set2_pos], 0,
1168 for (set1_pos = 0; set1_pos < set1[ring_no].
member_count; set1_pos++) {
1173 if (memcmp(&set1[ring_no].member_list[set1_pos], &empty_ip_address,
sizeof(empty_ip_address)) != 0) {
1175 "removing dynamic member %s for ring %u",
1182 if (!set2[ring_no].configured) {
1185 for (set2_pos = 0; set2_pos < set2[ring_no].
member_count; set2_pos++) {
1190 if (memcmp(&set2[ring_no].member_list[set2_pos], &empty_ip_address,
sizeof(empty_ip_address)) != 0) {
1192 "adding dynamic member %s for ring %u",
1211 int local_node_pos = find_local_node(map, 0);
1268 char addr_buf[INET6_ADDRSTRLEN];
1277 "New config has different knet transport for link %d. Internal value was NOT changed.\n", i);
1297 strncpy(addr_buf, ip_str,
sizeof(addr_buf));
1298 addr_buf[
sizeof(addr_buf) - 1] =
'\0';
1300 "new config has different address for link %d (addr changed from %s to %s). Internal value was NOT changed.\n",
1312 snprintf (error_string_response,
sizeof(error_string_response),
1313 "To reconfigure an interface it must be deleted and recreated. A working interface needs to be available to corosync at all times");
1314 *error_string = error_string_response;
1322 int reload,
const char **error_string)
1325 const char *iter_key, *iter_key2;
1327 unsigned int node_pos;
1330 char *node_addr_str;
1332 unsigned int linknumber = 0;
1334 int last_node_pos = -1;
1346 res = sscanf(iter_key,
"nodelist.node.%u.%s", &node_pos, tmp_key);
1351 if (node_pos == last_node_pos) {
1354 last_node_pos = node_pos;
1367 res = sscanf(iter_key2,
"nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
1368 if (res != 3 || strcmp(tmp_key2,
"_addr") != 0) {
1372 snprintf (error_string_response,
sizeof(error_string_response),
1373 "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
1375 *error_string = error_string_response;
1394 sprintf(error_string_response,
1395 "An IPV6 network requires that a node ID be specified "
1396 "for address '%s'.", node_addr_str);
1397 *error_string = error_string_response;
1417 sprintf(error_string_response,
"failed to parse node address '%s'\n", node_addr_str);
1418 *error_string = error_string_response;
1423 free(node_addr_str);
1429 free(node_addr_str);
1441 if (check_things_have_not_changed(
totem_config, error_string) == -1) {
1454 char *node_addr_str;
1455 unsigned int linknumber = 0;
1457 const char *iter_key;
1459 node_pos = find_local_node(map, 1);
1460 if (node_pos > -1) {
1467 res = sscanf(iter_key,
"nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
1468 if (res != 3 || strcmp(tmp_key2,
"_addr") != 0) {
1478 free(node_addr_str);
1485 const char **error_string, uint64_t *warnings,
1489 unsigned int linknumber = 0;
1490 int member_count = 0;
1493 const char *iter_key;
1494 const char *member_iter_key;
1500 char *cluster_name = NULL;
1519 cluster_name = NULL;
1524 res = sscanf(iter_key,
"totem.interface.%[^.].%s", linknumber_key, tmp_key);
1534 linknumber = atoi(linknumber_key);
1537 snprintf (error_string_response,
sizeof(error_string_response),
1538 "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
1541 *error_string = error_string_response;
1558 sprintf(error_string_response,
"failed to parse bindnet address '%s'\n", str);
1559 *error_string = error_string_response;
1578 sprintf(error_string_response,
"failed to parse mcast address '%s'\n", str);
1579 *error_string = error_string_response;
1601 (void)get_cluster_mcast_addr (cluster_name,
1609 if (strcmp (str,
"yes") == 0) {
1645 if (strcmp(str,
"sctp") == 0) {
1648 else if (strcmp(str,
"udp") == 0) {
1652 *error_string =
"Unrecognised knet_transport. expected 'udp' or 'sctp'";
1693 while ((member_iter_key =
icmap_iter_next(member_iter, NULL, NULL)) != NULL) {
1694 if (member_count == 0) {
1708 sprintf(error_string_response,
"failed to parse node address '%s'\n", str);
1709 *error_string = error_string_response;
1735 const char **error_string,
1739 char *str, *ring0_addr_str;
1751 *error_string =
"Out of memory trying to allocate ethernet interface storage area";
1757 if (strcmp (str,
"udpu") == 0) {
1759 }
else if (strcmp (str,
"udp") == 0) {
1761 }
else if (strcmp (str,
"knet") == 0) {
1764 *error_string =
"Invalid transport type. Should be udpu, udp or knet";
1791 *error_string =
"totem.link_mode is too long";
1804 if (strcmp (str,
"yes") == 0) {
1831 free(ring0_addr_str);
1891 if (local_node_pos != -1) {
1900 *error_string =
"Knet requires an explicit nodeid for the local node";
1912 *error_string =
"An IPV6 network requires that a node ID be specified";
1950 const char **error_string)
1952 static char local_error_reason[512];
1953 char parse_error[512];
1954 const char *error_reason = local_error_reason;
1957 int num_configured = 0;
1965 if (num_configured == 0) {
1966 error_reason =
"No interfaces defined";
1972 error_reason =
"No valid name found for local host";
1992 snprintf (local_error_reason,
sizeof(local_error_reason),
1993 "No multicast address specified for interface %u", i);
1998 snprintf (local_error_reason,
sizeof(local_error_reason),
1999 "No multicast port specified for interface %u", i);
2004 snprintf (local_error_reason,
sizeof(local_error_reason),
2005 "Invalid TTL (should be 0..255) for interface %u", i);
2010 snprintf (local_error_reason,
sizeof(local_error_reason),
2011 "Can only set ttl on multicast transport types for interface %u", i);
2015 snprintf (local_error_reason,
sizeof(local_error_reason),
2016 "Invalid link priority (should be 0..255) for interface %u", i);
2021 snprintf (local_error_reason,
sizeof(local_error_reason),
2022 "Can only set link priority on knet transport type for interface %u", i);
2028 snprintf (local_error_reason,
sizeof(local_error_reason),
2029 "An IPV6 network requires that a node ID be specified for interface %u", i);
2035 snprintf (local_error_reason,
sizeof(local_error_reason),
2036 "Multicast address family does not match bind address family for interface %u", i);
2041 snprintf (local_error_reason,
sizeof(local_error_reason),
2042 "mcastaddr is not a correct multicast address for interface %u", i);
2049 error_reason =
"This totem parser can only parse version 2 configurations.";
2057 if (check_for_duplicate_nodeids(
totem_config, error_string) == -1) {
2067 snprintf (local_error_reason,
sizeof(local_error_reason),
2068 "The Knet link mode \"%s\" specified is invalid. It must be active, passive or rr.\n",
totem_config->
link_mode);
2077 if (interface_max < num_configured) {
2078 snprintf (parse_error,
sizeof(parse_error),
2079 "%d is too many configured interfaces for non-Knet transport.",
2081 error_reason = parse_error;
2090 snprintf (parse_error,
sizeof(parse_error),
2091 "crypto_cipher & crypto_hash are only valid for the Knet transport.");
2092 error_reason = parse_error;
2109 snprintf (error_string_response,
sizeof(error_string_response),
2110 "parse error in config: %s\n", error_reason);
2111 *error_string = error_string_response;
2116 static int read_keyfile (
2117 const char *key_location,
2119 const char **error_string)
2124 char error_str[100];
2125 const char *error_ptr;
2127 fd = open (key_location, O_RDONLY);
2129 error_ptr = qb_strerror_r(errno, error_str,
sizeof(error_str));
2130 snprintf (error_string_response,
sizeof(error_string_response),
2131 "Could not open %s: %s\n",
2132 key_location, error_ptr);
2137 saved_errno = errno;
2141 error_ptr = qb_strerror_r (saved_errno, error_str,
sizeof(error_str));
2142 snprintf (error_string_response,
sizeof(error_string_response),
2143 "Could not read %s: %s\n",
2144 key_location, error_ptr);
2149 snprintf (error_string_response,
sizeof(error_string_response),
2150 "Could only read %d bits of minimum %u bits from %s.\n",
2160 *error_string = error_string_response;
2167 const char **error_string)
2170 char *key_location = NULL;
2190 res = read_keyfile(key_location,
totem_config, error_string);
2199 sprintf(error_string_response,
"key is too long");
2203 sprintf(error_string_response,
"key is too short");
2210 sprintf(error_string_response,
"can't load private key");
2231 *error_string = error_string_response;
2238 if (totem_get_crypto(
totem_config, map, error_string) != 0) {
2256 if (token_warning_ms < totem_config->token_retransmit_timeout)
2258 "The token warning interval (%d ms) is less than the token retransmit timeout (%d ms) "
2259 "which can lead to spurious token warnings. Consider increasing the token_warning parameter.",
2272 "seqno unchanged const (%d rotations) Maximum network MTU %d",
2275 "window size per rotation (%d messages) maximum messages per rotation (%d messages)",
2284 static void totem_change_notify(
2286 const char *key_name,
2294 const char *deleted_key = NULL;
2295 const char *error_string;
2310 if (!
param && strcmp(key_name,
"totem.token_coefficient") != 0)
2318 deleted_key = key_name;
2344 const char **error_string)
2346 uint64_t warnings = 0LL;
2348 get_interface_params(
totem_config, map, error_string, &warnings, 1);
2349 if (put_nodelist_members_to_config (
totem_config, map, 1, error_string)) {
2359 (void)find_local_node(map, 0);
2371 assert(new_interfaces != NULL);
2383 free(new_interfaces);
2392 totem_change_notify,