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