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