corosync  2.4.3
totemconfig.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2005 MontaVista Software, Inc.
3  * Copyright (c) 2006-2013 Red Hat, Inc.
4  *
5  * All rights reserved.
6  *
7  * Author: Steven Dake (sdake@redhat.com)
8  * Jan Friesse (jfriesse@redhat.com)
9  *
10  * This software licensed under BSD license, the text of which follows:
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are met:
14  *
15  * - Redistributions of source code must retain the above copyright notice,
16  * this list of conditions and the following disclaimer.
17  * - Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  * - Neither the name of the MontaVista Software, Inc. nor the names of its
21  * contributors may be used to endorse or promote products derived from this
22  * software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34  * THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 #include <config.h>
38 
39 #include <stdio.h>
40 #include <string.h>
41 #include <stdlib.h>
42 #include <errno.h>
43 #include <unistd.h>
44 #include <sys/socket.h>
45 #include <sys/types.h>
46 #include <sys/stat.h>
47 #include <fcntl.h>
48 #include <netinet/in.h>
49 #include <arpa/inet.h>
50 #include <sys/param.h>
51 
52 #include <corosync/swab.h>
53 #include <corosync/list.h>
54 #include <qb/qbdefs.h>
55 #include <corosync/totem/totem.h>
56 #include <corosync/config.h>
57 #include <corosync/logsys.h>
58 #include <corosync/icmap.h>
59 
60 #include "util.h"
61 #include "totemconfig.h"
62 
63 #define TOKEN_RETRANSMITS_BEFORE_LOSS_CONST 4
64 #define TOKEN_TIMEOUT 1000
65 #define TOKEN_COEFFICIENT 650
66 #define JOIN_TIMEOUT 50
67 #define MERGE_TIMEOUT 200
68 #define DOWNCHECK_TIMEOUT 1000
69 #define FAIL_TO_RECV_CONST 2500
70 #define SEQNO_UNCHANGED_CONST 30
71 #define MINIMUM_TIMEOUT (int)(1000/HZ)*3
72 #define MAX_NETWORK_DELAY 50
73 #define WINDOW_SIZE 50
74 #define MAX_MESSAGES 17
75 #define MISS_COUNT_CONST 5
76 #define RRP_PROBLEM_COUNT_TIMEOUT 2000
77 #define RRP_PROBLEM_COUNT_THRESHOLD_DEFAULT 10
78 #define RRP_PROBLEM_COUNT_THRESHOLD_MIN 2
79 #define RRP_AUTORECOVERY_CHECK_TIMEOUT 1000
80 
81 #define DEFAULT_PORT 5405
82 
83 static char error_string_response[512];
84 
85 static void add_totem_config_notification(struct totem_config *totem_config);
86 
87 
88 /* All the volatile parameters are uint32s, luckily */
89 static uint32_t *totem_get_param_by_name(struct totem_config *totem_config, const char *param_name)
90 {
91  if (strcmp(param_name, "totem.token") == 0)
92  return &totem_config->token_timeout;
93  if (strcmp(param_name, "totem.token_retransmit") == 0)
94  return &totem_config->token_retransmit_timeout;
95  if (strcmp(param_name, "totem.hold") == 0)
96  return &totem_config->token_hold_timeout;
97  if (strcmp(param_name, "totem.token_retransmits_before_loss_const") == 0)
98  return &totem_config->token_retransmits_before_loss_const;
99  if (strcmp(param_name, "totem.join") == 0)
100  return &totem_config->join_timeout;
101  if (strcmp(param_name, "totem.send_join") == 0)
102  return &totem_config->send_join_timeout;
103  if (strcmp(param_name, "totem.consensus") == 0)
104  return &totem_config->consensus_timeout;
105  if (strcmp(param_name, "totem.merge") == 0)
106  return &totem_config->merge_timeout;
107  if (strcmp(param_name, "totem.downcheck") == 0)
108  return &totem_config->downcheck_timeout;
109  if (strcmp(param_name, "totem.fail_recv_const") == 0)
110  return &totem_config->fail_to_recv_const;
111  if (strcmp(param_name, "totem.seqno_unchanged_const") == 0)
112  return &totem_config->seqno_unchanged_const;
113  if (strcmp(param_name, "totem.rrp_token_expired_timeout") == 0)
114  return &totem_config->rrp_token_expired_timeout;
115  if (strcmp(param_name, "totem.rrp_problem_count_timeout") == 0)
116  return &totem_config->rrp_problem_count_timeout;
117  if (strcmp(param_name, "totem.rrp_problem_count_threshold") == 0)
118  return &totem_config->rrp_problem_count_threshold;
119  if (strcmp(param_name, "totem.rrp_problem_count_mcast_threshold") == 0)
120  return &totem_config->rrp_problem_count_mcast_threshold;
121  if (strcmp(param_name, "totem.rrp_autorecovery_check_timeout") == 0)
122  return &totem_config->rrp_autorecovery_check_timeout;
123  if (strcmp(param_name, "totem.heartbeat_failures_allowed") == 0)
124  return &totem_config->heartbeat_failures_allowed;
125  if (strcmp(param_name, "totem.max_network_delay") == 0)
126  return &totem_config->max_network_delay;
127  if (strcmp(param_name, "totem.window_size") == 0)
128  return &totem_config->window_size;
129  if (strcmp(param_name, "totem.max_messages") == 0)
130  return &totem_config->max_messages;
131  if (strcmp(param_name, "totem.miss_count_const") == 0)
132  return &totem_config->miss_count_const;
133 
134  return NULL;
135 }
136 
137 /*
138  * Read key_name from icmap. If key is not found or key_name == delete_key or if allow_zero is false
139  * and readed value is zero, default value is used and stored into totem_config.
140  */
141 static void totem_volatile_config_set_value (struct totem_config *totem_config,
142  const char *key_name, const char *deleted_key, unsigned int default_value,
143  int allow_zero_value)
144 {
145  char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
146 
147  if (icmap_get_uint32(key_name, totem_get_param_by_name(totem_config, key_name)) != CS_OK ||
148  (deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
149  (!allow_zero_value && *totem_get_param_by_name(totem_config, key_name) == 0)) {
150  *totem_get_param_by_name(totem_config, key_name) = default_value;
151  }
152 
153  /*
154  * Store totem_config value to cmap runtime section
155  */
156  if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
157  /*
158  * This shouldn't happen
159  */
160  return ;
161  }
162 
163  strcpy(runtime_key_name, "runtime.config.");
164  strcat(runtime_key_name, key_name);
165 
166  icmap_set_uint32(runtime_key_name, *totem_get_param_by_name(totem_config, key_name));
167 }
168 
169 
170 /*
171  * Read and validate config values from cmap and store them into totem_config. If key doesn't exists,
172  * default value is stored. deleted_key is name of key beeing processed by delete operation
173  * from cmap. It is considered as non existing even if it can be read. Can be NULL.
174  */
175 static void totem_volatile_config_read (struct totem_config *totem_config, const char *deleted_key)
176 {
177  uint32_t u32;
178 
179  totem_volatile_config_set_value(totem_config, "totem.token_retransmits_before_loss_const", deleted_key,
181 
182  totem_volatile_config_set_value(totem_config, "totem.token", deleted_key, TOKEN_TIMEOUT, 0);
183 
184  if (totem_config->interface_count > 0 && totem_config->interfaces[0].member_count > 2) {
185  u32 = TOKEN_COEFFICIENT;
186  icmap_get_uint32("totem.token_coefficient", &u32);
187  totem_config->token_timeout += (totem_config->interfaces[0].member_count - 2) * u32;
188 
189  /*
190  * Store totem_config value to cmap runtime section
191  */
192  icmap_set_uint32("runtime.config.totem.token", totem_config->token_timeout);
193  }
194 
195  totem_volatile_config_set_value(totem_config, "totem.max_network_delay", deleted_key, MAX_NETWORK_DELAY, 0);
196 
197  totem_volatile_config_set_value(totem_config, "totem.window_size", deleted_key, WINDOW_SIZE, 0);
198 
199  totem_volatile_config_set_value(totem_config, "totem.max_messages", deleted_key, MAX_MESSAGES, 0);
200 
201  totem_volatile_config_set_value(totem_config, "totem.miss_count_const", deleted_key, MISS_COUNT_CONST, 0);
202 
203  totem_volatile_config_set_value(totem_config, "totem.token_retransmit", deleted_key,
204  (int)(totem_config->token_timeout / (totem_config->token_retransmits_before_loss_const + 0.2)), 0);
205 
206  totem_volatile_config_set_value(totem_config, "totem.hold", deleted_key,
207  (int)(totem_config->token_retransmit_timeout * 0.8 - (1000/HZ)), 0);
208 
209  totem_volatile_config_set_value(totem_config, "totem.join", deleted_key, JOIN_TIMEOUT, 0);
210 
211  totem_volatile_config_set_value(totem_config, "totem.consensus", deleted_key,
212  (int)(float)(1.2 * totem_config->token_timeout), 0);
213 
214  totem_volatile_config_set_value(totem_config, "totem.merge", deleted_key, MERGE_TIMEOUT, 0);
215 
216  totem_volatile_config_set_value(totem_config, "totem.downcheck", deleted_key, DOWNCHECK_TIMEOUT, 0);
217 
218  totem_volatile_config_set_value(totem_config, "totem.fail_recv_const", deleted_key, FAIL_TO_RECV_CONST, 0);
219 
220  totem_volatile_config_set_value(totem_config, "totem.seqno_unchanged_const", deleted_key,
222 
223  totem_volatile_config_set_value(totem_config, "totem.send_join", deleted_key, 0, 1);
224 
225  totem_volatile_config_set_value(totem_config, "totem.rrp_problem_count_timeout", deleted_key,
227 
228  totem_volatile_config_set_value(totem_config, "totem.rrp_problem_count_threshold", deleted_key,
230 
231  totem_volatile_config_set_value(totem_config, "totem.rrp_problem_count_mcast_threshold", deleted_key,
232  totem_config->rrp_problem_count_threshold * 10, 0);
233 
234  totem_volatile_config_set_value(totem_config, "totem.rrp_token_expired_timeout", deleted_key,
235  totem_config->token_retransmit_timeout, 0);
236 
237  totem_volatile_config_set_value(totem_config, "totem.rrp_autorecovery_check_timeout", deleted_key,
239 
240  totem_volatile_config_set_value(totem_config, "totem.heartbeat_failures_allowed", deleted_key, 0, 1);
241 }
242 
243 static int totem_volatile_config_validate (
244  struct totem_config *totem_config,
245  const char **error_string)
246 {
247  static char local_error_reason[512];
248  const char *error_reason = local_error_reason;
249 
250  if (totem_config->max_network_delay < MINIMUM_TIMEOUT) {
251  snprintf (local_error_reason, sizeof(local_error_reason),
252  "The max_network_delay parameter (%d ms) may not be less than (%d ms).",
253  totem_config->max_network_delay, MINIMUM_TIMEOUT);
254  goto parse_error;
255  }
256 
257  if (totem_config->token_timeout < MINIMUM_TIMEOUT) {
258  snprintf (local_error_reason, sizeof(local_error_reason),
259  "The token timeout parameter (%d ms) may not be less than (%d ms).",
260  totem_config->token_timeout, MINIMUM_TIMEOUT);
261  goto parse_error;
262  }
263 
264  if (totem_config->token_retransmit_timeout < MINIMUM_TIMEOUT) {
265  snprintf (local_error_reason, sizeof(local_error_reason),
266  "The token retransmit timeout parameter (%d ms) may not be less than (%d ms).",
268  goto parse_error;
269  }
270 
271  if (totem_config->token_hold_timeout < MINIMUM_TIMEOUT) {
272  snprintf (local_error_reason, sizeof(local_error_reason),
273  "The token hold timeout parameter (%d ms) may not be less than (%d ms).",
274  totem_config->token_hold_timeout, MINIMUM_TIMEOUT);
275  goto parse_error;
276  }
277 
278  if (totem_config->join_timeout < MINIMUM_TIMEOUT) {
279  snprintf (local_error_reason, sizeof(local_error_reason),
280  "The join timeout parameter (%d ms) may not be less than (%d ms).",
281  totem_config->join_timeout, MINIMUM_TIMEOUT);
282  goto parse_error;
283  }
284 
285  if (totem_config->consensus_timeout < MINIMUM_TIMEOUT) {
286  snprintf (local_error_reason, sizeof(local_error_reason),
287  "The consensus timeout parameter (%d ms) may not be less than (%d ms).",
288  totem_config->consensus_timeout, MINIMUM_TIMEOUT);
289  goto parse_error;
290  }
291 
292  if (totem_config->consensus_timeout < totem_config->join_timeout) {
293  snprintf (local_error_reason, sizeof(local_error_reason),
294  "The consensus timeout parameter (%d ms) may not be less than join timeout (%d ms).",
295  totem_config->consensus_timeout, totem_config->join_timeout);
296  goto parse_error;
297  }
298 
299  if (totem_config->merge_timeout < MINIMUM_TIMEOUT) {
300  snprintf (local_error_reason, sizeof(local_error_reason),
301  "The merge timeout parameter (%d ms) may not be less than (%d ms).",
302  totem_config->merge_timeout, MINIMUM_TIMEOUT);
303  goto parse_error;
304  }
305 
306  if (totem_config->downcheck_timeout < MINIMUM_TIMEOUT) {
307  snprintf (local_error_reason, sizeof(local_error_reason),
308  "The downcheck timeout parameter (%d ms) may not be less than (%d ms).",
309  totem_config->downcheck_timeout, MINIMUM_TIMEOUT);
310  goto parse_error;
311  }
312 
313  if (totem_config->rrp_problem_count_timeout < MINIMUM_TIMEOUT) {
314  snprintf (local_error_reason, sizeof(local_error_reason),
315  "The RRP problem count timeout parameter (%d ms) may not be less than (%d ms).",
317  goto parse_error;
318  }
319 
321  snprintf (local_error_reason, sizeof(local_error_reason),
322  "The RRP problem count threshold (%d problem count) may not be less than (%d problem count).",
324  goto parse_error;
325  }
327  snprintf (local_error_reason, sizeof(local_error_reason),
328  "The RRP multicast problem count threshold (%d problem count) may not be less than (%d problem count).",
330  goto parse_error;
331  }
332 
333  if (totem_config->rrp_token_expired_timeout < MINIMUM_TIMEOUT) {
334  snprintf (local_error_reason, sizeof(local_error_reason),
335  "The RRP token expired timeout parameter (%d ms) may not be less than (%d ms).",
337  goto parse_error;
338  }
339 
340  return 0;
341 
342 parse_error:
343  snprintf (error_string_response, sizeof(error_string_response),
344  "parse error in config: %s\n", error_reason);
345  *error_string = error_string_response;
346  return (-1);
347 
348 }
349 
350 static int totem_get_crypto(struct totem_config *totem_config)
351 {
352  char *str;
353  const char *tmp_cipher;
354  const char *tmp_hash;
355 
356  tmp_hash = "sha1";
357  tmp_cipher = "aes256";
358 
359  if (icmap_get_string("totem.secauth", &str) == CS_OK) {
360  if (strcmp (str, "off") == 0) {
361  tmp_hash = "none";
362  tmp_cipher = "none";
363  }
364  free(str);
365  }
366 
367  if (icmap_get_string("totem.crypto_cipher", &str) == CS_OK) {
368  if (strcmp(str, "none") == 0) {
369  tmp_cipher = "none";
370  }
371  if (strcmp(str, "aes256") == 0) {
372  tmp_cipher = "aes256";
373  }
374  if (strcmp(str, "aes192") == 0) {
375  tmp_cipher = "aes192";
376  }
377  if (strcmp(str, "aes128") == 0) {
378  tmp_cipher = "aes128";
379  }
380  if (strcmp(str, "3des") == 0) {
381  tmp_cipher = "3des";
382  }
383  free(str);
384  }
385 
386  if (icmap_get_string("totem.crypto_hash", &str) == CS_OK) {
387  if (strcmp(str, "none") == 0) {
388  tmp_hash = "none";
389  }
390  if (strcmp(str, "md5") == 0) {
391  tmp_hash = "md5";
392  }
393  if (strcmp(str, "sha1") == 0) {
394  tmp_hash = "sha1";
395  }
396  if (strcmp(str, "sha256") == 0) {
397  tmp_hash = "sha256";
398  }
399  if (strcmp(str, "sha384") == 0) {
400  tmp_hash = "sha384";
401  }
402  if (strcmp(str, "sha512") == 0) {
403  tmp_hash = "sha512";
404  }
405  free(str);
406  }
407 
408  if ((strcmp(tmp_cipher, "none") != 0) &&
409  (strcmp(tmp_hash, "none") == 0)) {
410  return -1;
411  }
412 
413  free(totem_config->crypto_cipher_type);
414  free(totem_config->crypto_hash_type);
415 
416  totem_config->crypto_cipher_type = strdup(tmp_cipher);
417  totem_config->crypto_hash_type = strdup(tmp_hash);
418 
419  return 0;
420 }
421 
422 static int totem_config_get_ip_version(void)
423 {
424  int res;
425  char *str;
426 
427  res = AF_INET;
428  if (icmap_get_string("totem.ip_version", &str) == CS_OK) {
429  if (strcmp(str, "ipv4") == 0) {
430  res = AF_INET;
431  }
432  if (strcmp(str, "ipv6") == 0) {
433  res = AF_INET6;
434  }
435  free(str);
436  }
437 
438  return (res);
439 }
440 
441 static uint16_t generate_cluster_id (const char *cluster_name)
442 {
443  int i;
444  int value = 0;
445 
446  for (i = 0; i < strlen(cluster_name); i++) {
447  value <<= 1;
448  value += cluster_name[i];
449  }
450 
451  return (value & 0xFFFF);
452 }
453 
454 static int get_cluster_mcast_addr (
455  const char *cluster_name,
456  unsigned int ringnumber,
457  int ip_version,
458  struct totem_ip_address *res)
459 {
460  uint16_t clusterid;
461  char addr[INET6_ADDRSTRLEN + 1];
462  int err;
463 
464  if (cluster_name == NULL) {
465  return (-1);
466  }
467 
468  clusterid = generate_cluster_id(cluster_name) + ringnumber;
469  memset (res, 0, sizeof(*res));
470 
471  switch (ip_version) {
472  case AF_INET:
473  snprintf(addr, sizeof(addr), "239.192.%d.%d", clusterid >> 8, clusterid % 0xFF);
474  break;
475  case AF_INET6:
476  snprintf(addr, sizeof(addr), "ff15::%x", clusterid);
477  break;
478  default:
479  /*
480  * Unknown family
481  */
482  return (-1);
483  }
484 
485  err = totemip_parse (res, addr, ip_version);
486 
487  return (err);
488 }
489 
490 static unsigned int generate_nodeid_for_duplicate_test(
491  struct totem_config *totem_config,
492  char *addr)
493 {
494  unsigned int nodeid;
495  struct totem_ip_address totemip;
496 
497  /* AF_INET hard-coded here because auto-generated nodeids
498  are only for IPv4 */
499  if (totemip_parse(&totemip, addr, AF_INET) != 0)
500  return -1;
501 
502  memcpy (&nodeid, &totemip.addr, sizeof (unsigned int));
503 
504 #if __BYTE_ORDER == __LITTLE_ENDIAN
505  nodeid = swab32 (nodeid);
506 #endif
507 
508  if (totem_config->clear_node_high_bit) {
509  nodeid &= 0x7FFFFFFF;
510  }
511  return nodeid;
512 }
513 
514 static int check_for_duplicate_nodeids(
515  struct totem_config *totem_config,
516  const char **error_string)
517 {
518  icmap_iter_t iter;
519  icmap_iter_t subiter;
520  const char *iter_key;
521  int res = 0;
522  int retval = 0;
523  char tmp_key[ICMAP_KEYNAME_MAXLEN];
524  char *ring0_addr=NULL;
525  char *ring0_addr1=NULL;
526  unsigned int node_pos;
527  unsigned int node_pos1;
528  unsigned int nodeid;
529  unsigned int nodeid1;
530  int autogenerated;
531 
532  iter = icmap_iter_init("nodelist.node.");
533  while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
534  res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, tmp_key);
535  if (res != 2) {
536  continue;
537  }
538 
539  if (strcmp(tmp_key, "ring0_addr") != 0) {
540  continue;
541  }
542 
543  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
544  autogenerated = 0;
545  if (icmap_get_uint32(tmp_key, &nodeid) != CS_OK) {
546 
547  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos);
548  if (icmap_get_string(tmp_key, &ring0_addr) != CS_OK) {
549  continue;
550  }
551 
552  /* Generate nodeid so we can check that auto-generated nodeids don't clash either */
553  nodeid = generate_nodeid_for_duplicate_test(totem_config, ring0_addr);
554  if (nodeid == -1) {
555  continue;
556  }
557  autogenerated = 1;
558  }
559 
560  node_pos1 = 0;
561  subiter = icmap_iter_init("nodelist.node.");
562  while (((iter_key = icmap_iter_next(subiter, NULL, NULL)) != NULL) && (node_pos1 < node_pos)) {
563  res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos1, tmp_key);
564  if ((res != 2) || (node_pos1 >= node_pos)) {
565  continue;
566  }
567 
568  if (strcmp(tmp_key, "ring0_addr") != 0) {
569  continue;
570  }
571 
572  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos1);
573  if (icmap_get_uint32(tmp_key, &nodeid1) != CS_OK) {
574 
575  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos1);
576  if (icmap_get_string(tmp_key, &ring0_addr1) != CS_OK) {
577  continue;
578  }
579  nodeid1 = generate_nodeid_for_duplicate_test(totem_config, ring0_addr1);
580  if (nodeid1 == -1) {
581  continue;
582  }
583  }
584 
585  if (nodeid == nodeid1) {
586  retval = -1;
587  snprintf (error_string_response, sizeof(error_string_response),
588  "Nodeid %u%s%s%s appears twice in corosync.conf", nodeid,
589  autogenerated?"(autogenerated from ":"",
590  autogenerated?ring0_addr:"",
591  autogenerated?")":"");
592  log_printf (LOGSYS_LEVEL_ERROR, error_string_response);
593  *error_string = error_string_response;
594  break;
595  }
596  }
597  icmap_iter_finalize(subiter);
598  }
599  icmap_iter_finalize(iter);
600  return retval;
601 }
602 
603 
604 static int find_local_node_in_nodelist(struct totem_config *totem_config)
605 {
606  icmap_iter_t iter;
607  const char *iter_key;
608  int res = 0;
609  unsigned int node_pos;
610  int local_node_pos = -1;
611  struct totem_ip_address bind_addr;
612  int interface_up, interface_num;
613  char tmp_key[ICMAP_KEYNAME_MAXLEN];
614  char *node_addr_str;
615  struct totem_ip_address node_addr;
616 
617  res = totemip_iface_check(&totem_config->interfaces[0].bindnet,
618  &bind_addr, &interface_up, &interface_num,
619  totem_config->clear_node_high_bit);
620  if (res == -1) {
621  return (-1);
622  }
623 
624  iter = icmap_iter_init("nodelist.node.");
625  while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
626  res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, tmp_key);
627  if (res != 2) {
628  continue;
629  }
630 
631  if (strcmp(tmp_key, "ring0_addr") != 0) {
632  continue;
633  }
634 
635  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos);
636  if (icmap_get_string(tmp_key, &node_addr_str) != CS_OK) {
637  continue;
638  }
639 
640  res = totemip_parse (&node_addr, node_addr_str, totem_config->ip_version);
641  free(node_addr_str);
642  if (res == -1) {
643  continue ;
644  }
645 
646  if (totemip_equal(&bind_addr, &node_addr)) {
647  local_node_pos = node_pos;
648  }
649  }
650  icmap_iter_finalize(iter);
651 
652  return (local_node_pos);
653 }
654 
655 /*
656  * Compute difference between two set of totem interface arrays. set1 and set2
657  * are changed so for same ring, ip existing in both set1 and set2 are cleared
658  * (set to 0), and ips which are only in set1 or set2 remains untouched.
659  * totempg_node_add/remove is called.
660  */
661 static void compute_interfaces_diff(int interface_count,
662  struct totem_interface *set1,
663  struct totem_interface *set2)
664 {
665  int ring_no, set1_pos, set2_pos;
666  struct totem_ip_address empty_ip_address;
667 
668  memset(&empty_ip_address, 0, sizeof(empty_ip_address));
669 
670  for (ring_no = 0; ring_no < interface_count; ring_no++) {
671  for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
672  for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
673  /*
674  * For current ring_no remove all set1 items existing
675  * in set2
676  */
677  if (memcmp(&set1[ring_no].member_list[set1_pos],
678  &set2[ring_no].member_list[set2_pos],
679  sizeof(struct totem_ip_address)) == 0) {
680  memset(&set1[ring_no].member_list[set1_pos], 0,
681  sizeof(struct totem_ip_address));
682  memset(&set2[ring_no].member_list[set2_pos], 0,
683  sizeof(struct totem_ip_address));
684  }
685  }
686  }
687  }
688 
689  for (ring_no = 0; ring_no < interface_count; ring_no++) {
690  for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
691  /*
692  * All items which remained in set1 doesn't exists in set2 any longer so
693  * node has to be removed.
694  */
695  if (memcmp(&set1[ring_no].member_list[set1_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
697  "removing dynamic member %s for ring %u",
698  totemip_print(&set1[ring_no].member_list[set1_pos]),
699  ring_no);
700 
701  totempg_member_remove(&set1[ring_no].member_list[set1_pos], ring_no);
702  }
703  }
704  for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
705  /*
706  * All items which remained in set2 doesn't existed in set1 so this is no node
707  * and has to be added.
708  */
709  if (memcmp(&set2[ring_no].member_list[set2_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
711  "adding dynamic member %s for ring %u",
712  totemip_print(&set2[ring_no].member_list[set2_pos]),
713  ring_no);
714 
715  totempg_member_add(&set2[ring_no].member_list[set2_pos], ring_no);
716  }
717  }
718  }
719 }
720 
721 static void put_nodelist_members_to_config(struct totem_config *totem_config, int reload)
722 {
723  icmap_iter_t iter, iter2;
724  const char *iter_key, *iter_key2;
725  int res = 0;
726  unsigned int node_pos;
727  char tmp_key[ICMAP_KEYNAME_MAXLEN];
728  char tmp_key2[ICMAP_KEYNAME_MAXLEN];
729  char *node_addr_str;
730  int member_count;
731  unsigned int ringnumber = 0;
732  int i, j;
733  struct totem_interface *orig_interfaces = NULL;
734  struct totem_interface *new_interfaces = NULL;
735 
736  if (reload) {
737  /*
738  * We need to compute diff only for reload. Also for initial configuration
739  * not all totem structures are initialized so corosync will crash during
740  * member_add/remove
741  */
742  orig_interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
743  assert(orig_interfaces != NULL);
744  new_interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
745  assert(new_interfaces != NULL);
746 
747  memcpy(orig_interfaces, totem_config->interfaces, sizeof (struct totem_interface) * INTERFACE_MAX);
748  }
749 
750  /* Clear out nodelist so we can put the new one in if needed */
751  for (i = 0; i < totem_config->interface_count; i++) {
752  for (j = 0; j < PROCESSOR_COUNT_MAX; j++) {
753  memset(&totem_config->interfaces[i].member_list[j], 0, sizeof(struct totem_ip_address));
754  }
755  totem_config->interfaces[i].member_count = 0;
756  }
757 
758  iter = icmap_iter_init("nodelist.node.");
759  while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
760  res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, tmp_key);
761  if (res != 2) {
762  continue;
763  }
764 
765  if (strcmp(tmp_key, "ring0_addr") != 0) {
766  continue;
767  }
768 
769  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
770  iter2 = icmap_iter_init(tmp_key);
771  while ((iter_key2 = icmap_iter_next(iter2, NULL, NULL)) != NULL) {
772  res = sscanf(iter_key2, "nodelist.node.%u.ring%u%s", &node_pos, &ringnumber, tmp_key2);
773  if (res != 3 || strcmp(tmp_key2, "_addr") != 0) {
774  continue;
775  }
776 
777  if (icmap_get_string(iter_key2, &node_addr_str) != CS_OK) {
778  continue;
779  }
780 
781  member_count = totem_config->interfaces[ringnumber].member_count;
782 
783  res = totemip_parse(&totem_config->interfaces[ringnumber].member_list[member_count],
784  node_addr_str, totem_config->ip_version);
785  if (res != -1) {
786  totem_config->interfaces[ringnumber].member_count++;
787  }
788  free(node_addr_str);
789  }
790 
791  icmap_iter_finalize(iter2);
792  }
793 
794  icmap_iter_finalize(iter);
795 
796  if (reload) {
797  memcpy(new_interfaces, totem_config->interfaces, sizeof (struct totem_interface) * INTERFACE_MAX);
798 
799  compute_interfaces_diff(totem_config->interface_count, orig_interfaces, new_interfaces);
800 
801  free(new_interfaces);
802  free(orig_interfaces);
803  }
804 }
805 
806 static void nodelist_dynamic_notify(
807  int32_t event,
808  const char *key_name,
809  struct icmap_notify_value new_val,
810  struct icmap_notify_value old_val,
811  void *user_data)
812 {
813  int res;
814  unsigned int ring_no;
815  unsigned int member_no;
816  char tmp_str[ICMAP_KEYNAME_MAXLEN];
817  uint8_t reloading;
818  struct totem_config *totem_config = (struct totem_config *)user_data;
819 
820  /*
821  * If a full reload is in progress then don't do anything until it's done and
822  * can reconfigure it all atomically
823  */
824  if (icmap_get_uint8("config.totemconfig_reload_in_progress", &reloading) == CS_OK && reloading) {
825  return ;
826  }
827 
828  res = sscanf(key_name, "nodelist.node.%u.ring%u%s", &member_no, &ring_no, tmp_str);
829  if (res != 3)
830  return ;
831 
832  if (strcmp(tmp_str, "_addr") != 0) {
833  return;
834  }
835 
836  put_nodelist_members_to_config(totem_config, 1);
837 }
838 
839 
840 /*
841  * Tries to find node (node_pos) in config nodelist which address matches any
842  * local interface. Address can be stored in ring0_addr or if ipaddr_key_prefix is not NULL
843  * key with prefix ipaddr_key is used (there can be multiuple of them)
844  * This function differs * from find_local_node_in_nodelist because it doesn't need bindnetaddr,
845  * but doesn't work when bind addr is network address (so IP must be exact
846  * match).
847  *
848  * Returns 1 on success (address was found, node_pos is then correctly set) or 0 on failure.
849  */
850 int totem_config_find_local_addr_in_nodelist(const char *ipaddr_key_prefix, unsigned int *node_pos)
851 {
852  struct list_head addrs;
853  struct totem_ip_if_address *if_addr;
854  icmap_iter_t iter, iter2;
855  const char *iter_key, *iter_key2;
856  struct list_head *list;
857  const char *ipaddr_key;
858  int ip_version;
859  struct totem_ip_address node_addr;
860  char *node_addr_str;
861  int node_found = 0;
862  int res = 0;
863  char tmp_key[ICMAP_KEYNAME_MAXLEN];
864 
865  if (totemip_getifaddrs(&addrs) == -1) {
866  return 0;
867  }
868 
869  ip_version = totem_config_get_ip_version();
870 
871  iter = icmap_iter_init("nodelist.node.");
872 
873  while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
874  res = sscanf(iter_key, "nodelist.node.%u.%s", node_pos, tmp_key);
875  if (res != 2) {
876  continue;
877  }
878 
879  if (strcmp(tmp_key, "ring0_addr") != 0) {
880  continue;
881  }
882 
883  if (icmap_get_string(iter_key, &node_addr_str) != CS_OK) {
884  continue ;
885  }
886 
887  free(node_addr_str);
888 
889  /*
890  * ring0_addr found -> let's iterate thru ipaddr_key_prefix
891  */
892  snprintf(tmp_key, sizeof(tmp_key), "nodelist.node.%u.%s", *node_pos,
893  (ipaddr_key_prefix != NULL ? ipaddr_key_prefix : "ring0_addr"));
894 
895  iter2 = icmap_iter_init(tmp_key);
896  while ((iter_key2 = icmap_iter_next(iter2, NULL, NULL)) != NULL) {
897  /*
898  * ring0_addr must be exact match, not prefix
899  */
900  ipaddr_key = (ipaddr_key_prefix != NULL ? iter_key2 : tmp_key);
901  if (icmap_get_string(ipaddr_key, &node_addr_str) != CS_OK) {
902  continue ;
903  }
904 
905  if (totemip_parse(&node_addr, node_addr_str, ip_version) == -1) {
906  free(node_addr_str);
907  continue ;
908  }
909  free(node_addr_str);
910 
911  /*
912  * Try to match ip with if_addrs
913  */
914  node_found = 0;
915  for (list = addrs.next; list != &addrs; list = list->next) {
916  if_addr = list_entry(list, struct totem_ip_if_address, list);
917 
918  if (totemip_equal(&node_addr, &if_addr->ip_addr)) {
919  node_found = 1;
920  break;
921  }
922  }
923 
924  if (node_found) {
925  break ;
926  }
927  }
928 
929  icmap_iter_finalize(iter2);
930 
931  if (node_found) {
932  break ;
933  }
934  }
935 
936  icmap_iter_finalize(iter);
937  totemip_freeifaddrs(&addrs);
938 
939  return (node_found);
940 }
941 
942 static void config_convert_nodelist_to_interface(struct totem_config *totem_config)
943 {
944  int res = 0;
945  unsigned int node_pos;
946  char tmp_key[ICMAP_KEYNAME_MAXLEN];
947  char tmp_key2[ICMAP_KEYNAME_MAXLEN];
948  char *node_addr_str;
949  unsigned int ringnumber = 0;
950  icmap_iter_t iter;
951  const char *iter_key;
952 
953  if (totem_config_find_local_addr_in_nodelist(NULL, &node_pos)) {
954  /*
955  * We found node, so create interface section
956  */
957  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
958  iter = icmap_iter_init(tmp_key);
959  while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
960  res = sscanf(iter_key, "nodelist.node.%u.ring%u%s", &node_pos, &ringnumber, tmp_key2);
961  if (res != 3 || strcmp(tmp_key2, "_addr") != 0) {
962  continue ;
963  }
964 
965  if (icmap_get_string(iter_key, &node_addr_str) != CS_OK) {
966  continue;
967  }
968 
969  snprintf(tmp_key2, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.bindnetaddr", ringnumber);
970  icmap_set_string(tmp_key2, node_addr_str);
971  free(node_addr_str);
972  }
973  icmap_iter_finalize(iter);
974  }
975 }
976 
977 
978 extern int totem_config_read (
979  struct totem_config *totem_config,
980  const char **error_string,
981  uint64_t *warnings)
982 {
983  int res = 0;
984  char *str, *ring0_addr_str;
985  unsigned int ringnumber = 0;
986  int member_count = 0;
987  icmap_iter_t iter, member_iter;
988  const char *iter_key;
989  const char *member_iter_key;
990  char ringnumber_key[ICMAP_KEYNAME_MAXLEN];
991  char tmp_key[ICMAP_KEYNAME_MAXLEN];
992  uint8_t u8;
993  uint16_t u16;
994  char *cluster_name = NULL;
995  int i;
996  int local_node_pos;
997  int nodeid_set;
998 
999  *warnings = 0;
1000 
1001  memset (totem_config, 0, sizeof (struct totem_config));
1002  totem_config->interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
1003  if (totem_config->interfaces == 0) {
1004  *error_string = "Out of memory trying to allocate ethernet interface storage area";
1005  return -1;
1006  }
1007 
1008  memset (totem_config->interfaces, 0,
1009  sizeof (struct totem_interface) * INTERFACE_MAX);
1010 
1011  strcpy (totem_config->rrp_mode, "none");
1012 
1013  icmap_get_uint32("totem.version", (uint32_t *)&totem_config->version);
1014 
1015  if (totem_get_crypto(totem_config) != 0) {
1016  *error_string = "crypto_cipher requires crypto_hash with value other than none";
1017  return -1;
1018  }
1019 
1020  if (icmap_get_string("totem.rrp_mode", &str) == CS_OK) {
1021  if (strlen(str) >= TOTEM_RRP_MODE_BYTES) {
1022  *error_string = "totem.rrp_mode is too long";
1023  free(str);
1024 
1025  return -1;
1026  }
1027  strcpy (totem_config->rrp_mode, str);
1028  free(str);
1029  }
1030 
1031  icmap_get_uint32("totem.nodeid", &totem_config->node_id);
1032 
1033  totem_config->clear_node_high_bit = 0;
1034  if (icmap_get_string("totem.clear_node_high_bit", &str) == CS_OK) {
1035  if (strcmp (str, "yes") == 0) {
1036  totem_config->clear_node_high_bit = 1;
1037  }
1038  free(str);
1039  }
1040 
1041  icmap_get_uint32("totem.threads", &totem_config->threads);
1042 
1043  icmap_get_uint32("totem.netmtu", &totem_config->net_mtu);
1044 
1045  if (icmap_get_string("totem.cluster_name", &cluster_name) != CS_OK) {
1046  cluster_name = NULL;
1047  }
1048 
1049  totem_config->ip_version = totem_config_get_ip_version();
1050 
1051  if (icmap_get_string("totem.interface.0.bindnetaddr", &str) != CS_OK) {
1052  /*
1053  * We were not able to find ring 0 bindnet addr. Try to use nodelist informations
1054  */
1055  config_convert_nodelist_to_interface(totem_config);
1056  } else {
1057  if (icmap_get_string("nodelist.node.0.ring0_addr", &ring0_addr_str) == CS_OK) {
1058  /*
1059  * Both bindnetaddr and ring0_addr are set.
1060  * Log warning information, and use nodelist instead
1061  */
1063 
1064  config_convert_nodelist_to_interface(totem_config);
1065 
1066  free(ring0_addr_str);
1067  }
1068 
1069  free(str);
1070  }
1071 
1072  /*
1073  * Broadcast option is global but set in interface section,
1074  * so reset before processing interfaces.
1075  */
1076  totem_config->broadcast_use = 0;
1077 
1078  iter = icmap_iter_init("totem.interface.");
1079  while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
1080  res = sscanf(iter_key, "totem.interface.%[^.].%s", ringnumber_key, tmp_key);
1081  if (res != 2) {
1082  continue;
1083  }
1084 
1085  if (strcmp(tmp_key, "bindnetaddr") != 0) {
1086  continue;
1087  }
1088 
1089  member_count = 0;
1090 
1091  ringnumber = atoi(ringnumber_key);
1092 
1093  if (ringnumber >= INTERFACE_MAX) {
1094  free(cluster_name);
1095 
1096  snprintf (error_string_response, sizeof(error_string_response),
1097  "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
1098  ringnumber, INTERFACE_MAX - 1);
1099 
1100  *error_string = error_string_response;
1101  return -1;
1102  }
1103 
1104  /*
1105  * Get the bind net address
1106  */
1107  if (icmap_get_string(iter_key, &str) == CS_OK) {
1108  res = totemip_parse (&totem_config->interfaces[ringnumber].bindnet, str,
1109  totem_config->ip_version);
1110  free(str);
1111  }
1112 
1113  /*
1114  * Get interface multicast address
1115  */
1116  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastaddr", ringnumber);
1117  if (icmap_get_string(tmp_key, &str) == CS_OK) {
1118  res = totemip_parse (&totem_config->interfaces[ringnumber].mcast_addr, str, totem_config->ip_version);
1119  free(str);
1120  } else {
1121  /*
1122  * User not specified address -> autogenerate one from cluster_name key
1123  * (if available). Return code is intentionally ignored, because
1124  * udpu doesn't need mcastaddr and validity of mcastaddr for udp is
1125  * checked later anyway.
1126  */
1127  (void)get_cluster_mcast_addr (cluster_name,
1128  ringnumber,
1129  totem_config->ip_version,
1130  &totem_config->interfaces[ringnumber].mcast_addr);
1131  }
1132 
1133  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.broadcast", ringnumber);
1134  if (icmap_get_string(tmp_key, &str) == CS_OK) {
1135  if (strcmp (str, "yes") == 0) {
1136  totem_config->broadcast_use = 1;
1137  }
1138  free(str);
1139  }
1140 
1141  /*
1142  * Get mcast port
1143  */
1144  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastport", ringnumber);
1145  if (icmap_get_uint16(tmp_key, &totem_config->interfaces[ringnumber].ip_port) != CS_OK) {
1146  if (totem_config->broadcast_use) {
1147  totem_config->interfaces[ringnumber].ip_port = DEFAULT_PORT + (2 * ringnumber);
1148  } else {
1149  totem_config->interfaces[ringnumber].ip_port = DEFAULT_PORT;
1150  }
1151  }
1152 
1153  /*
1154  * Get the TTL
1155  */
1156  totem_config->interfaces[ringnumber].ttl = 1;
1157 
1158  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.ttl", ringnumber);
1159 
1160  if (icmap_get_uint8(tmp_key, &u8) == CS_OK) {
1161  totem_config->interfaces[ringnumber].ttl = u8;
1162  }
1163 
1164  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.member.", ringnumber);
1165  member_iter = icmap_iter_init(tmp_key);
1166  while ((member_iter_key = icmap_iter_next(member_iter, NULL, NULL)) != NULL) {
1167  if (member_count == 0) {
1168  if (icmap_get_string("nodelist.node.0.ring0_addr", &str) == CS_OK) {
1169  free(str);
1171  break;
1172  } else {
1174  }
1175  }
1176 
1177  if (icmap_get_string(member_iter_key, &str) == CS_OK) {
1178  res = totemip_parse (&totem_config->interfaces[ringnumber].member_list[member_count++],
1179  str, totem_config->ip_version);
1180  }
1181  }
1182  icmap_iter_finalize(member_iter);
1183 
1184  totem_config->interfaces[ringnumber].member_count = member_count;
1185  totem_config->interface_count++;
1186  }
1187  icmap_iter_finalize(iter);
1188 
1189  /*
1190  * Use broadcast is global, so if set, make sure to fill mcast addr correctly
1191  */
1192  if (totem_config->broadcast_use) {
1193  for (ringnumber = 0; ringnumber < totem_config->interface_count; ringnumber++) {
1194  totemip_parse (&totem_config->interfaces[ringnumber].mcast_addr,
1195  "255.255.255.255", 0);
1196  }
1197  }
1198 
1199  /*
1200  * Store automatically generated items back to icmap
1201  */
1202  for (i = 0; i < totem_config->interface_count; i++) {
1203  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastaddr", i);
1204  if (icmap_get_string(tmp_key, &str) == CS_OK) {
1205  free(str);
1206  } else {
1207  str = (char *)totemip_print(&totem_config->interfaces[i].mcast_addr);
1208  icmap_set_string(tmp_key, str);
1209  }
1210 
1211  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastport", i);
1212  if (icmap_get_uint16(tmp_key, &u16) != CS_OK) {
1213  icmap_set_uint16(tmp_key, totem_config->interfaces[i].ip_port);
1214  }
1215  }
1216 
1217  totem_config->transport_number = TOTEM_TRANSPORT_UDP;
1218  if (icmap_get_string("totem.transport", &str) == CS_OK) {
1219  if (strcmp (str, "udpu") == 0) {
1220  totem_config->transport_number = TOTEM_TRANSPORT_UDPU;
1221  }
1222 
1223  if (strcmp (str, "iba") == 0) {
1224  totem_config->transport_number = TOTEM_TRANSPORT_RDMA;
1225  }
1226  free(str);
1227  }
1228 
1229  free(cluster_name);
1230 
1231  /*
1232  * Check existence of nodelist
1233  */
1234  if (icmap_get_string("nodelist.node.0.ring0_addr", &str) == CS_OK) {
1235  free(str);
1236  /*
1237  * find local node
1238  */
1239  local_node_pos = find_local_node_in_nodelist(totem_config);
1240  if (local_node_pos != -1) {
1241  icmap_set_uint32("nodelist.local_node_pos", local_node_pos);
1242 
1243  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", local_node_pos);
1244 
1245  nodeid_set = (totem_config->node_id != 0);
1246  if (icmap_get_uint32(tmp_key, &totem_config->node_id) == CS_OK && nodeid_set) {
1248  }
1249 
1250  /*
1251  * Make localnode ring0_addr read only, so we can be sure that local
1252  * node never changes. If rebinding to other IP would be in future
1253  * supported, this must be changed and handled properly!
1254  */
1255  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", local_node_pos);
1256  icmap_set_ro_access(tmp_key, 0, 1);
1257  icmap_set_ro_access("nodelist.local_node_pos", 0, 1);
1258  }
1259 
1260  put_nodelist_members_to_config(totem_config, 0);
1261  }
1262 
1263  /*
1264  * Get things that might change in the future (and can depend on totem_config->interfaces);
1265  */
1266  totem_volatile_config_read(totem_config, NULL);
1267 
1268  icmap_set_uint8("config.totemconfig_reload_in_progress", 0);
1269 
1270  add_totem_config_notification(totem_config);
1271 
1272  return 0;
1273 }
1274 
1275 
1277  struct totem_config *totem_config,
1278  const char **error_string)
1279 {
1280  static char local_error_reason[512];
1281  char parse_error[512];
1282  const char *error_reason = local_error_reason;
1283  int i, j;
1284  unsigned int interface_max = INTERFACE_MAX;
1285  unsigned int port1, port2;
1286 
1287  if (totem_config->interface_count == 0) {
1288  error_reason = "No interfaces defined";
1289  goto parse_error;
1290  }
1291 
1292  for (i = 0; i < totem_config->interface_count; i++) {
1293  /*
1294  * Some error checking of parsed data to make sure its valid
1295  */
1296 
1297  struct totem_ip_address null_addr;
1298  memset (&null_addr, 0, sizeof (struct totem_ip_address));
1299 
1300  if ((totem_config->transport_number == 0) &&
1301  memcmp (&totem_config->interfaces[i].mcast_addr, &null_addr,
1302  sizeof (struct totem_ip_address)) == 0) {
1303  error_reason = "No multicast address specified";
1304  goto parse_error;
1305  }
1306 
1307  if (totem_config->interfaces[i].ip_port == 0) {
1308  error_reason = "No multicast port specified";
1309  goto parse_error;
1310  }
1311 
1312  if (totem_config->interfaces[i].ttl > 255) {
1313  error_reason = "Invalid TTL (should be 0..255)";
1314  goto parse_error;
1315  }
1316  if (totem_config->transport_number != TOTEM_TRANSPORT_UDP &&
1317  totem_config->interfaces[i].ttl != 1) {
1318  error_reason = "Can only set ttl on multicast transport types";
1319  goto parse_error;
1320  }
1321 
1322  if (totem_config->interfaces[i].mcast_addr.family == AF_INET6 &&
1323  totem_config->node_id == 0) {
1324 
1325  error_reason = "An IPV6 network requires that a node ID be specified.";
1326  goto parse_error;
1327  }
1328 
1329  if (totem_config->broadcast_use == 0 && totem_config->transport_number == TOTEM_TRANSPORT_UDP) {
1330  if (totem_config->interfaces[i].mcast_addr.family != totem_config->interfaces[i].bindnet.family) {
1331  error_reason = "Multicast address family does not match bind address family";
1332  goto parse_error;
1333  }
1334 
1335  if (totemip_is_mcast (&totem_config->interfaces[i].mcast_addr) != 0) {
1336  error_reason = "mcastaddr is not a correct multicast address.";
1337  goto parse_error;
1338  }
1339  }
1340 
1341  if (totem_config->interfaces[0].bindnet.family != totem_config->interfaces[i].bindnet.family) {
1342  error_reason = "Not all bind address belong to the same IP family";
1343  goto parse_error;
1344  }
1345 
1346  /*
1347  * Ensure mcast address/port differs
1348  */
1349  if (totem_config->transport_number == TOTEM_TRANSPORT_UDP) {
1350  for (j = i + 1; j < totem_config->interface_count; j++) {
1351  port1 = totem_config->interfaces[i].ip_port;
1352  port2 = totem_config->interfaces[j].ip_port;
1353  if (totemip_equal(&totem_config->interfaces[i].mcast_addr,
1354  &totem_config->interfaces[j].mcast_addr) &&
1355  (((port1 > port2 ? port1 : port2) - (port1 < port2 ? port1 : port2)) <= 1)) {
1356  error_reason = "Interfaces multicast address/port pair must differ";
1357  goto parse_error;
1358  }
1359  }
1360  }
1361  }
1362 
1363  if (totem_config->version != 2) {
1364  error_reason = "This totem parser can only parse version 2 configurations.";
1365  goto parse_error;
1366  }
1367 
1368  if (totem_volatile_config_validate(totem_config, error_string) == -1) {
1369  return (-1);
1370  }
1371 
1372  if (check_for_duplicate_nodeids(totem_config, error_string) == -1) {
1373  return (-1);
1374  }
1375 
1376  /*
1377  * RRP values validation
1378  */
1379  if (strcmp (totem_config->rrp_mode, "none") &&
1380  strcmp (totem_config->rrp_mode, "active") &&
1381  strcmp (totem_config->rrp_mode, "passive")) {
1382  snprintf (local_error_reason, sizeof(local_error_reason),
1383  "The RRP mode \"%s\" specified is invalid. It must be none, active, or passive.\n", totem_config->rrp_mode);
1384  goto parse_error;
1385  }
1386 
1387  if (strcmp (totem_config->rrp_mode, "none") == 0) {
1388  interface_max = 1;
1389  }
1390  if (interface_max < totem_config->interface_count) {
1391  snprintf (parse_error, sizeof(parse_error),
1392  "%d is too many configured interfaces for the rrp_mode setting %s.",
1393  totem_config->interface_count,
1394  totem_config->rrp_mode);
1395  error_reason = parse_error;
1396  goto parse_error;
1397  }
1398 
1399  if (totem_config->net_mtu == 0) {
1400  totem_config->net_mtu = 1500;
1401  }
1402 
1403  return 0;
1404 
1405 parse_error:
1406  snprintf (error_string_response, sizeof(error_string_response),
1407  "parse error in config: %s\n", error_reason);
1408  *error_string = error_string_response;
1409  return (-1);
1410 
1411 }
1412 
1413 static int read_keyfile (
1414  const char *key_location,
1415  struct totem_config *totem_config,
1416  const char **error_string)
1417 {
1418  int fd;
1419  int res;
1420  ssize_t expected_key_len = sizeof (totem_config->private_key);
1421  int saved_errno;
1422  char error_str[100];
1423  const char *error_ptr;
1424 
1425  fd = open (key_location, O_RDONLY);
1426  if (fd == -1) {
1427  error_ptr = qb_strerror_r(errno, error_str, sizeof(error_str));
1428  snprintf (error_string_response, sizeof(error_string_response),
1429  "Could not open %s: %s\n",
1430  key_location, error_ptr);
1431  goto parse_error;
1432  }
1433 
1434  res = read (fd, totem_config->private_key, expected_key_len);
1435  saved_errno = errno;
1436  close (fd);
1437 
1438  if (res == -1) {
1439  error_ptr = qb_strerror_r (saved_errno, error_str, sizeof(error_str));
1440  snprintf (error_string_response, sizeof(error_string_response),
1441  "Could not read %s: %s\n",
1442  key_location, error_ptr);
1443  goto parse_error;
1444  }
1445 
1446  totem_config->private_key_len = expected_key_len;
1447 
1448  if (res != expected_key_len) {
1449  snprintf (error_string_response, sizeof(error_string_response),
1450  "Could only read %d bits of 1024 bits from %s.\n",
1451  res * 8, key_location);
1452  goto parse_error;
1453  }
1454 
1455  return 0;
1456 
1457 parse_error:
1458  *error_string = error_string_response;
1459  return (-1);
1460 }
1461 
1463  struct totem_config *totem_config,
1464  const char **error_string)
1465 {
1466  int got_key = 0;
1467  char *key_location = NULL;
1468  int res;
1469  size_t key_len;
1470 
1471  memset (totem_config->private_key, 0, 128);
1472  totem_config->private_key_len = 128;
1473 
1474  if (strcmp(totem_config->crypto_cipher_type, "none") == 0 &&
1475  strcmp(totem_config->crypto_hash_type, "none") == 0) {
1476  return (0);
1477  }
1478 
1479  /* cmap may store the location of the key file */
1480  if (icmap_get_string("totem.keyfile", &key_location) == CS_OK) {
1481  res = read_keyfile(key_location, totem_config, error_string);
1482  free(key_location);
1483  if (res) {
1484  goto key_error;
1485  }
1486  got_key = 1;
1487  } else { /* Or the key itself may be in the cmap */
1488  if (icmap_get("totem.key", NULL, &key_len, NULL) == CS_OK) {
1489  if (key_len > sizeof (totem_config->private_key)) {
1490  sprintf(error_string_response, "key is too long");
1491  goto key_error;
1492  }
1493  if (icmap_get("totem.key", totem_config->private_key, &key_len, NULL) == CS_OK) {
1494  totem_config->private_key_len = key_len;
1495  got_key = 1;
1496  } else {
1497  sprintf(error_string_response, "can't store private key");
1498  goto key_error;
1499  }
1500  }
1501  }
1502 
1503  /* In desperation we read the default filename */
1504  if (!got_key) {
1505  const char *filename = getenv("COROSYNC_TOTEM_AUTHKEY_FILE");
1506  if (!filename)
1507  filename = COROSYSCONFDIR "/authkey";
1508  res = read_keyfile(filename, totem_config, error_string);
1509  if (res)
1510  goto key_error;
1511 
1512  }
1513 
1514  return (0);
1515 
1516 key_error:
1517  *error_string = error_string_response;
1518  return (-1);
1519 
1520 }
1521 
1522 static void debug_dump_totem_config(const struct totem_config *totem_config)
1523 {
1524 
1525  log_printf(LOGSYS_LEVEL_DEBUG, "Token Timeout (%d ms) retransmit timeout (%d ms)",
1526  totem_config->token_timeout, totem_config->token_retransmit_timeout);
1527  log_printf(LOGSYS_LEVEL_DEBUG, "token hold (%d ms) retransmits before loss (%d retrans)",
1528  totem_config->token_hold_timeout, totem_config->token_retransmits_before_loss_const);
1529  log_printf(LOGSYS_LEVEL_DEBUG, "join (%d ms) send_join (%d ms) consensus (%d ms) merge (%d ms)",
1530  totem_config->join_timeout, totem_config->send_join_timeout, totem_config->consensus_timeout,
1531  totem_config->merge_timeout);
1532  log_printf(LOGSYS_LEVEL_DEBUG, "downcheck (%d ms) fail to recv const (%d msgs)",
1533  totem_config->downcheck_timeout, totem_config->fail_to_recv_const);
1535  "seqno unchanged const (%d rotations) Maximum network MTU %d",
1536  totem_config->seqno_unchanged_const, totem_config->net_mtu);
1538  "window size per rotation (%d messages) maximum messages per rotation (%d messages)",
1539  totem_config->window_size, totem_config->max_messages);
1540  log_printf(LOGSYS_LEVEL_DEBUG, "missed count const (%d messages)", totem_config->miss_count_const);
1541  log_printf(LOGSYS_LEVEL_DEBUG, "RRP token expired timeout (%d ms)",
1542  totem_config->rrp_token_expired_timeout);
1543  log_printf(LOGSYS_LEVEL_DEBUG, "RRP token problem counter (%d ms)",
1544  totem_config->rrp_problem_count_timeout);
1545  log_printf(LOGSYS_LEVEL_DEBUG, "RRP threshold (%d problem count)",
1546  totem_config->rrp_problem_count_threshold);
1547  log_printf(LOGSYS_LEVEL_DEBUG, "RRP multicast threshold (%d problem count)",
1548  totem_config->rrp_problem_count_mcast_threshold);
1549  log_printf(LOGSYS_LEVEL_DEBUG, "RRP automatic recovery check timeout (%d ms)",
1550  totem_config->rrp_autorecovery_check_timeout);
1551  log_printf(LOGSYS_LEVEL_DEBUG, "RRP mode set to %s.",
1552  totem_config->rrp_mode);
1553  log_printf(LOGSYS_LEVEL_DEBUG, "heartbeat_failures_allowed (%d)",
1554  totem_config->heartbeat_failures_allowed);
1555  log_printf(LOGSYS_LEVEL_DEBUG, "max_network_delay (%d ms)", totem_config->max_network_delay);
1556 }
1557 
1558 static void totem_change_notify(
1559  int32_t event,
1560  const char *key_name,
1561  struct icmap_notify_value new_val,
1562  struct icmap_notify_value old_val,
1563  void *user_data)
1564 {
1565  struct totem_config *totem_config = (struct totem_config *)user_data;
1566  uint32_t *param;
1567  uint8_t reloading;
1568  const char *deleted_key = NULL;
1569  const char *error_string;
1570 
1571  /*
1572  * If a full reload is in progress then don't do anything until it's done and
1573  * can reconfigure it all atomically
1574  */
1575  if (icmap_get_uint8("config.reload_in_progress", &reloading) == CS_OK && reloading)
1576  return;
1577 
1578  param = totem_get_param_by_name((struct totem_config *)user_data, key_name);
1579  /*
1580  * Process change only if changed key is found in totem_config (-> param is not NULL)
1581  * or for special key token_coefficient. token_coefficient key is not stored in
1582  * totem_config, but it is used for computation of token timeout.
1583  */
1584  if (!param && strcmp(key_name, "totem.token_coefficient") != 0)
1585  return;
1586 
1587  /*
1588  * Values other than UINT32 are not supported, or needed (yet)
1589  */
1590  switch (event) {
1591  case ICMAP_TRACK_DELETE:
1592  deleted_key = key_name;
1593  break;
1594  case ICMAP_TRACK_ADD:
1595  case ICMAP_TRACK_MODIFY:
1596  deleted_key = NULL;
1597  break;
1598  default:
1599  break;
1600  }
1601 
1602  totem_volatile_config_read (totem_config, deleted_key);
1603  log_printf(LOGSYS_LEVEL_DEBUG, "Totem related config key changed. Dumping actual totem config.");
1604  debug_dump_totem_config(totem_config);
1605  if (totem_volatile_config_validate(totem_config, &error_string) == -1) {
1606  log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
1607  /*
1608  * TODO: Consider corosync exit and/or load defaults for volatile
1609  * values. For now, log error seems to be enough
1610  */
1611  }
1612 }
1613 
1614 static void totem_reload_notify(
1615  int32_t event,
1616  const char *key_name,
1617  struct icmap_notify_value new_val,
1618  struct icmap_notify_value old_val,
1619  void *user_data)
1620 {
1621  struct totem_config *totem_config = (struct totem_config *)user_data;
1622  uint32_t local_node_pos;
1623  const char *error_string;
1624 
1625  /* Reload has completed */
1626  if (*(uint8_t *)new_val.data == 0) {
1627  put_nodelist_members_to_config (totem_config, 1);
1628  totem_volatile_config_read (totem_config, NULL);
1629  log_printf(LOGSYS_LEVEL_DEBUG, "Configuration reloaded. Dumping actual totem config.");
1630  debug_dump_totem_config(totem_config);
1631  if (totem_volatile_config_validate(totem_config, &error_string) == -1) {
1632  log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
1633  /*
1634  * TODO: Consider corosync exit and/or load defaults for volatile
1635  * values. For now, log error seems to be enough
1636  */
1637  }
1638 
1639  /* Reinstate the local_node_pos */
1640  local_node_pos = find_local_node_in_nodelist(totem_config);
1641  if (local_node_pos != -1) {
1642  icmap_set_uint32("nodelist.local_node_pos", local_node_pos);
1643  }
1644 
1645  icmap_set_uint8("config.totemconfig_reload_in_progress", 0);
1646  } else {
1647  icmap_set_uint8("config.totemconfig_reload_in_progress", 1);
1648  }
1649 }
1650 
1651 static void add_totem_config_notification(struct totem_config *totem_config)
1652 {
1654 
1655  icmap_track_add("totem.",
1657  totem_change_notify,
1658  totem_config,
1659  &icmap_track);
1660 
1661  icmap_track_add("config.reload_in_progress",
1663  totem_reload_notify,
1664  totem_config,
1665  &icmap_track);
1666 
1667  icmap_track_add("nodelist.node.",
1669  nodelist_dynamic_notify,
1670  (void *)totem_config,
1671  &icmap_track);
1672 }
unsigned int clear_node_high_bit
Definition: totem.h:120
unsigned short family
Definition: coroapi.h:113
const char * icmap_iter_next(icmap_iter_t iter, size_t *value_len, icmap_value_types_t *type)
Return next item in iterator iter.
Definition: icmap.c:1103
#define RRP_PROBLEM_COUNT_TIMEOUT
Definition: totemconfig.c:76
uint32_t value
struct totem_interface * interfaces
Definition: totem.h:117
unsigned int interface_count
Definition: totem.h:118
struct list_head * next
Definition: list.h:47
The totem_ip_address struct.
Definition: coroapi.h:111
#define DEFAULT_PORT
Definition: totemconfig.c:81
const char * totemip_print(const struct totem_ip_address *addr)
Definition: totemip.c:214
void icmap_iter_finalize(icmap_iter_t iter)
Finalize iterator.
Definition: icmap.c:1124
totem_transport_t transport_number
Definition: totem.h:188
int totemip_parse(struct totem_ip_address *totemip, const char *addr, int family)
Definition: totemip.c:263
#define DOWNCHECK_TIMEOUT
Definition: totemconfig.c:68
unsigned int token_hold_timeout
Definition: totem.h:136
int member_count
Definition: totem.h:73
struct totem_ip_address member_list[PROCESSOR_COUNT_MAX]
Definition: totem.h:74
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN]
Definition: totem.h:125
char rrp_mode[TOTEM_RRP_MODE_BYTES]
Definition: totem.h:164
unsigned char addr[TOTEMIP_ADDRLEN]
Definition: coroapi.h:77
#define COROSYSCONFDIR
Definition: config.h:11
unsigned int rrp_problem_count_timeout
Definition: totem.h:156
cs_error_t icmap_set_string(const char *key_name, const char *value)
Definition: icmap.c:641
int totemip_is_mcast(struct totem_ip_address *addr)
Definition: totemip.c:114
#define RRP_AUTORECOVERY_CHECK_TIMEOUT
Definition: totemconfig.c:79
unsigned int downcheck_timeout
Definition: totem.h:148
unsigned int private_key_len
Definition: totem.h:127
Definition: list.h:46
#define SEQNO_UNCHANGED_CONST
Definition: totemconfig.c:70
unsigned int max_network_delay
Definition: totem.h:174
#define log_printf(level, format, args...)
Definition: logsys.h:319
unsigned int heartbeat_failures_allowed
Definition: totem.h:172
unsigned int send_join_timeout
Definition: totem.h:142
unsigned int window_size
Definition: totem.h:176
unsigned int rrp_problem_count_threshold
Definition: totem.h:158
#define ICMAP_TRACK_DELETE
Definition: icmap.h:77
#define INTERFACE_MAX
Definition: coroapi.h:88
#define RRP_PROBLEM_COUNT_THRESHOLD_MIN
Definition: totemconfig.c:78
#define ICMAP_KEYNAME_MAXLEN
Maximum length of key in icmap.
Definition: icmap.h:48
#define MINIMUM_TIMEOUT
Definition: totemconfig.c:71
cs_error_t icmap_get_uint8(const char *key_name, uint8_t *u8)
Definition: icmap.c:842
uint16_t ttl
Definition: totem.h:72
unsigned int node_id
Definition: totem.h:119
int totem_config_keyread(struct totem_config *totem_config, const char **error_string)
Definition: totemconfig.c:1462
#define ICMAP_TRACK_MODIFY
Definition: icmap.h:78
unsigned int token_retransmits_before_loss_const
Definition: totem.h:138
int totemip_iface_check(struct totem_ip_address *bindnet, struct totem_ip_address *boundto, int *interface_up, int *interface_num, int mask_high_bit)
Definition: totemip.c:405
#define FAIL_TO_RECV_CONST
Definition: totemconfig.c:69
cs_error_t icmap_set_uint32(const char *key_name, uint32_t value)
Definition: icmap.c:611
unsigned int seqno_unchanged_const
Definition: totem.h:152
void * user_data
Definition: sam.c:127
unsigned int miss_count_const
Definition: totem.h:190
unsigned int join_timeout
Definition: totem.h:140
int totem_config_validate(struct totem_config *totem_config, const char **error_string)
Definition: totemconfig.c:1276
const void * data
Definition: icmap.h:94
#define TOTEM_CONFIG_BINDNETADDR_NODELIST_SET
Definition: totemconfig.h:49
#define ICMAP_TRACK_ADD
Definition: icmap.h:76
int totem_config_find_local_addr_in_nodelist(const char *ipaddr_key_prefix, unsigned int *node_pos)
Definition: totemconfig.c:850
char * crypto_hash_type
Definition: totem.h:186
struct totem_ip_address mcast_addr
Definition: totem.h:70
#define LOGSYS_LEVEL_ERROR
Definition: logsys.h:70
Linked list API.
unsigned int rrp_autorecovery_check_timeout
Definition: totem.h:162
cs_error_t icmap_get(const char *key_name, void *value, size_t *value_len, icmap_value_types_t *type)
Retrieve value of key key_name and store it in user preallocated value pointer.
Definition: icmap.c:739
#define LOGSYS_LEVEL_DEBUG
Definition: logsys.h:74
cs_error_t icmap_set_uint16(const char *key_name, uint16_t value)
Definition: icmap.c:599
unsigned int fail_to_recv_const
Definition: totem.h:150
#define TOKEN_COEFFICIENT
Definition: totemconfig.c:65
int totempg_member_remove(const struct totem_ip_address *member, int ring_no)
Definition: totempg.c:1520
#define TOTEM_CONFIG_WARNING_MEMBERS_DEPRECATED
Definition: totemconfig.h:47
cs_error_t icmap_get_uint32(const char *key_name, uint32_t *u32)
Definition: icmap.c:866
uint8_t param
#define TOTEM_CONFIG_WARNING_MEMBERS_IGNORED
Definition: totemconfig.h:46
uint16_t ip_port
Definition: totem.h:71
void totemip_freeifaddrs(struct list_head *addrs)
Definition: totemip.c:389
#define swab32(x)
The swab32 macro.
Definition: swab.h:51
#define WINDOW_SIZE
Definition: totemconfig.c:73
int version
Definition: totem.h:112
unsigned int net_mtu
Definition: totem.h:168
#define MAX_NETWORK_DELAY
Definition: totemconfig.c:72
#define TOKEN_TIMEOUT
Definition: totemconfig.c:64
int ip_version
Definition: totem.h:192
#define MERGE_TIMEOUT
Definition: totemconfig.c:67
unsigned int token_timeout
Definition: totem.h:132
#define JOIN_TIMEOUT
Definition: totemconfig.c:66
unsigned int consensus_timeout
Definition: totem.h:144
int totemip_getifaddrs(struct list_head *addrs)
Definition: totemip.c:321
#define PROCESSOR_COUNT_MAX
Definition: coroapi.h:96
#define TOKEN_RETRANSMITS_BEFORE_LOSS_CONST
Definition: totemconfig.c:63
#define MISS_COUNT_CONST
Definition: totemconfig.c:75
unsigned int broadcast_use
Definition: totem.h:182
unsigned int rrp_problem_count_mcast_threshold
Definition: totem.h:160
cs_error_t icmap_get_string(const char *key_name, char **str)
Shortcut for icmap_get for string type.
Definition: icmap.c:896
#define list_entry(ptr, type, member)
Definition: list.h:84
cs_error_t icmap_set_uint8(const char *key_name, uint8_t value)
Definition: icmap.c:587
unsigned int max_messages
Definition: totem.h:178
char * crypto_cipher_type
Definition: totem.h:184
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.
Definition: icmap.c:1233
unsigned int merge_timeout
Definition: totem.h:146
unsigned int token_retransmit_timeout
Definition: totem.h:134
struct totem_ip_address bindnet
Definition: totem.h:68
unsigned int nodeid
Definition: coroapi.h:75
icmap_iter_t icmap_iter_init(const char *prefix)
Initialize iterator with given prefix.
Definition: icmap.c:1097
int totemip_equal(const struct totem_ip_address *addr1, const struct totem_ip_address *addr2)
Definition: totemip.c:71
struct totem_ip_address ip_addr
Definition: totemip.h:72
cs_error_t icmap_get_uint16(const char *key_name, uint16_t *u16)
Definition: icmap.c:854
#define TOTEM_CONFIG_WARNING_TOTEM_NODEID_IGNORED
Definition: totemconfig.h:48
#define MAX_MESSAGES
Definition: totemconfig.c:74
unsigned int rrp_token_expired_timeout
Definition: totem.h:154
unsigned int threads
Definition: totem.h:170
qb_map_iter_t * icmap_iter_t
Itterator type.
Definition: icmap.h:123
Structure passed as new_value and old_value in change callback.
Definition: icmap.h:91
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.
Definition: icmap.c:1167
int totem_config_read(struct totem_config *totem_config, const char **error_string, uint64_t *warnings)
Definition: totemconfig.c:978
#define ICMAP_TRACK_PREFIX
Whole prefix is tracked, instead of key only (so "totem." tracking means that "totem.nodeid", "totem.version", ...
Definition: icmap.h:85
#define RRP_PROBLEM_COUNT_THRESHOLD_DEFAULT
Definition: totemconfig.c:77
int totempg_member_add(const struct totem_ip_address *member, int ring_no)
Definition: totempg.c:1513