corosync 3.1.10
totemconfig.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2002-2005 MontaVista Software, Inc.
3 * Copyright (c) 2006-2022 Red Hat, Inc.
4 *
5 * All rights reserved.
6 *
7 * Author: Steven Dake (sdake@redhat.com)
8 * Jan Friesse (jfriesse@redhat.com)
9 * Chrissie Caulfield (ccaulfie@redhat.com)
10 *
11 * This software licensed under BSD license, the text of which follows:
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 *
16 * - Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 * - Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 * - Neither the name of the MontaVista Software, Inc. nor the names of its
22 * contributors may be used to endorse or promote products derived from this
23 * software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35 * THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include <config.h>
39
40#include <stdio.h>
41#include <string.h>
42#include <stdlib.h>
43#include <errno.h>
44#include <unistd.h>
45#include <sys/socket.h>
46#include <sys/types.h>
47#include <sys/stat.h>
48#include <fcntl.h>
49#include <ifaddrs.h>
50#include <netdb.h>
51#include <netinet/in.h>
52#include <arpa/inet.h>
53#include <sys/param.h>
54#include <sys/utsname.h>
55
56#include <corosync/swab.h>
57#include <qb/qblist.h>
58#include <qb/qbdefs.h>
59#include <libknet.h>
61#include <corosync/config.h>
62#include <corosync/logsys.h>
63#include <corosync/icmap.h>
64
65#include "util.h"
66#include "totemconfig.h"
67
68#define TOKEN_RETRANSMITS_BEFORE_LOSS_CONST 4
69#define TOKEN_TIMEOUT 3000
70#define TOKEN_WARNING 75
71#define TOKEN_COEFFICIENT 650
72#define JOIN_TIMEOUT 50
73#define MERGE_TIMEOUT 200
74#define DOWNCHECK_TIMEOUT 1000
75#define FAIL_TO_RECV_CONST 2500
76#define SEQNO_UNCHANGED_CONST 30
77#define MINIMUM_TIMEOUT (int)(1000/HZ)*3
78#define MINIMUM_TIMEOUT_HOLD (int)(MINIMUM_TIMEOUT * 0.8 - (1000/HZ))
79#define MAX_NETWORK_DELAY 50
80#define WINDOW_SIZE 50
81#define MAX_MESSAGES 17
82#define MISS_COUNT_CONST 5
83#define BLOCK_UNLISTED_IPS 1
84#define CANCEL_TOKEN_HOLD_ON_RETRANSMIT 0
85/* This constant is not used for knet */
86#define UDP_NETMTU 1500
87
88/* Currently all but PONG_COUNT match the defaults in libknet.h */
89#define KNET_PING_INTERVAL 1000
90#define KNET_PING_TIMEOUT 2000
91#define KNET_PING_PRECISION 2048
92#define KNET_PONG_COUNT 2
93#define KNET_PMTUD_INTERVAL 30
94#define KNET_MTU 0
95#define KNET_DEFAULT_TRANSPORT KNET_TRANSPORT_UDP
96
97#define DEFAULT_PORT 5405
98
99static char error_string_response[768];
100
101static void add_totem_config_notification(struct totem_config *totem_config);
102
103static void *totem_get_param_by_name(struct totem_config *totem_config, const char *param_name)
104{
105 if (strcmp(param_name, "totem.token") == 0)
107 if (strcmp(param_name, "totem.token_warning") == 0)
109 if (strcmp(param_name, "totem.token_retransmit") == 0)
111 if (strcmp(param_name, "totem.hold") == 0)
113 if (strcmp(param_name, "totem.token_retransmits_before_loss_const") == 0)
115 if (strcmp(param_name, "totem.join") == 0)
116 return &totem_config->join_timeout;
117 if (strcmp(param_name, "totem.send_join") == 0)
119 if (strcmp(param_name, "totem.consensus") == 0)
121 if (strcmp(param_name, "totem.merge") == 0)
123 if (strcmp(param_name, "totem.downcheck") == 0)
125 if (strcmp(param_name, "totem.fail_recv_const") == 0)
127 if (strcmp(param_name, "totem.seqno_unchanged_const") == 0)
129 if (strcmp(param_name, "totem.heartbeat_failures_allowed") == 0)
131 if (strcmp(param_name, "totem.max_network_delay") == 0)
133 if (strcmp(param_name, "totem.window_size") == 0)
134 return &totem_config->window_size;
135 if (strcmp(param_name, "totem.max_messages") == 0)
136 return &totem_config->max_messages;
137 if (strcmp(param_name, "totem.miss_count_const") == 0)
139 if (strcmp(param_name, "totem.knet_pmtud_interval") == 0)
141 if (strcmp(param_name, "totem.knet_mtu") == 0)
142 return &totem_config->knet_mtu;
143 if (strcmp(param_name, "totem.knet_compression_threshold") == 0)
145 if (strcmp(param_name, "totem.knet_compression_level") == 0)
147 if (strcmp(param_name, "totem.knet_compression_model") == 0)
149 if (strcmp(param_name, "totem.block_unlisted_ips") == 0)
151 if (strcmp(param_name, "totem.cancel_token_hold_on_retransmit") == 0)
153
154 return NULL;
155}
156
157/*
158 * Read key_name from icmap. If key is not found or key_name == delete_key or if allow_zero is false
159 * and readed value is zero, default value is used and stored into totem_config.
160 */
161static void totem_volatile_config_set_uint32_value (struct totem_config *totem_config, icmap_map_t map,
162 const char *key_name, const char *deleted_key, unsigned int default_value,
163 int allow_zero_value)
164{
165 char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
166
167 if (icmap_get_uint32_r(map, key_name, totem_get_param_by_name(totem_config, key_name)) != CS_OK ||
168 (deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
169 (!allow_zero_value && *(uint32_t *)totem_get_param_by_name(totem_config, key_name) == 0)) {
170 *(uint32_t *)totem_get_param_by_name(totem_config, key_name) = default_value;
171 }
172
173 /*
174 * Store totem_config value to cmap runtime section
175 */
176 if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
177 /*
178 * This shouldn't happen
179 */
180 return ;
181 }
182
183 strcpy(runtime_key_name, "runtime.config.");
184 strcat(runtime_key_name, key_name);
185
186 icmap_set_uint32_r(map, runtime_key_name, *(uint32_t *)totem_get_param_by_name(totem_config, key_name));
187}
188
189static void totem_volatile_config_set_int32_value (struct totem_config *totem_config, icmap_map_t map,
190 const char *key_name, const char *deleted_key, int default_value,
191 int allow_zero_value)
192{
193 char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
194
195 if (icmap_get_int32_r(map, key_name, totem_get_param_by_name(totem_config, key_name)) != CS_OK ||
196 (deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
197 (!allow_zero_value && *(int32_t *)totem_get_param_by_name(totem_config, key_name) == 0)) {
198 *(int32_t *)totem_get_param_by_name(totem_config, key_name) = default_value;
199 }
200
201 /*
202 * Store totem_config value to cmap runtime section
203 */
204 if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
205 /*
206 * This shouldn't happen
207 */
208 return ;
209 }
210
211 strcpy(runtime_key_name, "runtime.config.");
212 strcat(runtime_key_name, key_name);
213
214 icmap_set_int32_r(map, runtime_key_name, *(int32_t *)totem_get_param_by_name(totem_config, key_name));
215}
216
217static void totem_volatile_config_set_string_value (struct totem_config *totem_config, icmap_map_t map,
218 const char *key_name, const char *deleted_key, const char *default_value)
219{
220 char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
221 int res;
222 char *new_config_value;
223 const void *config_value;
224
225 config_value = totem_get_param_by_name(totem_config, key_name);
226
227 res = icmap_get_string_r(map, key_name, (char **)&new_config_value);
228 if (res != CS_OK ||
229 (deleted_key != NULL && strcmp(deleted_key, key_name) == 0)) {
230
231 /* Slightly pointless use of strncpy but it keeps coverity happy */
232 strncpy((char *)config_value, default_value, CONFIG_STRING_LEN_MAX);
233 } else {
234 strncpy((char *)config_value, new_config_value, CONFIG_STRING_LEN_MAX);
235 }
236 if (res == CS_OK) {
237 free(new_config_value);
238 }
239
240 /*
241 * Store totem_config value to cmap runtime section
242 */
243 if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
244 /*
245 * This shouldn't happen
246 */
247 return ;
248 }
249
250 strcpy(runtime_key_name, "runtime.config.");
251 strcat(runtime_key_name, key_name);
252
253 (void)icmap_set_string_r(map, runtime_key_name, (char *)config_value);
254}
255
256/*
257 * Read string value stored in key_name from icmap, use it as a boolean (yes/no) type, convert it
258 * to integer value (1/0) and store into totem_config.
259 *
260 * If key is not found or key_name == delete_key default value is used
261 * and stored into totem_config.
262 */
263static void totem_volatile_config_set_boolean_value (struct totem_config *totem_config, icmap_map_t map,
264 const char *key_name, const char *deleted_key, unsigned int default_value)
265{
266 char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
267 char *str;
268 int val;
269
270 str = NULL;
271 val = default_value;
272
273 if ((deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
274 (icmap_get_string_r(map, key_name, &str) != CS_OK)) {
275 /*
276 * Do nothing. str is NULL (icmap_get_string ether not called or
277 * not changed str).
278 */
279 } else {
280 if (strcmp(str, "yes") == 0) {
281 val = 1;
282 } else if (strcmp(str, "no") == 0) {
283 val = 0;
284 }
285 free(str);
286 }
287
288 /*
289 * Store totem_config value to cmap runtime section
290 */
291 if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
292 /*
293 * This shouldn't happen
294 */
295 return ;
296 }
297
298 strcpy(runtime_key_name, "runtime.config.");
299 strcat(runtime_key_name, key_name);
300
301 *(uint32_t *)totem_get_param_by_name(totem_config, key_name) = val;
302
303 icmap_set_uint32_r(map, runtime_key_name, val);
304}
305
306/*
307 * Read and validate config values from cmap and store them into totem_config. If key doesn't exists,
308 * default value is stored. deleted_key is name of key beeing processed by delete operation
309 * from cmap. It is considered as non existing even if it can be read. Can be NULL.
310 */
311void totem_volatile_config_read (struct totem_config *totem_config, icmap_map_t temp_map, const char *deleted_key)
312{
313 uint32_t u32;
314
315 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token_retransmits_before_loss_const", deleted_key,
317
318 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token", deleted_key, TOKEN_TIMEOUT, 0);
319
320 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token_warning", deleted_key, TOKEN_WARNING, 1);
321
323 u32 = TOKEN_COEFFICIENT;
324 icmap_get_uint32_r(temp_map, "totem.token_coefficient", &u32);
326
327 /*
328 * Store totem_config value to cmap runtime section
329 */
330 icmap_set_uint32_r(temp_map, "runtime.config.totem.token", totem_config->token_timeout);
331 }
332
333 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.max_network_delay", deleted_key, MAX_NETWORK_DELAY, 0);
334
335 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.window_size", deleted_key, WINDOW_SIZE, 0);
336
337 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.max_messages", deleted_key, MAX_MESSAGES, 0);
338
339 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.miss_count_const", deleted_key, MISS_COUNT_CONST, 0);
340 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.knet_pmtud_interval", deleted_key, KNET_PMTUD_INTERVAL, 0);
341 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.knet_mtu", deleted_key, KNET_MTU, 0);
342
343 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.token_retransmit", deleted_key,
345
346 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.hold", deleted_key,
347 (int)(totem_config->token_retransmit_timeout * 0.8 - (1000/HZ)), 0);
348
349 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.join", deleted_key, JOIN_TIMEOUT, 0);
350
351 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.consensus", deleted_key,
352 (int)(float)(1.2 * totem_config->token_timeout), 0);
353
354 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.merge", deleted_key, MERGE_TIMEOUT, 0);
355
356 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.downcheck", deleted_key, DOWNCHECK_TIMEOUT, 0);
357
358 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.fail_recv_const", deleted_key, FAIL_TO_RECV_CONST, 0);
359
360 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.seqno_unchanged_const", deleted_key,
362
363 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.send_join", deleted_key, 0, 1);
364
365 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.heartbeat_failures_allowed", deleted_key, 0, 1);
366
367 totem_volatile_config_set_uint32_value(totem_config, temp_map, "totem.knet_compression_threshold", deleted_key, 0, 1);
368
369 totem_volatile_config_set_int32_value(totem_config, temp_map, "totem.knet_compression_level", deleted_key, 0, 1);
370
371 totem_volatile_config_set_string_value(totem_config, temp_map, "totem.knet_compression_model", deleted_key, "none");
372
373 totem_volatile_config_set_boolean_value(totem_config, temp_map, "totem.block_unlisted_ips", deleted_key,
375
376 totem_volatile_config_set_boolean_value(totem_config, temp_map, "totem.cancel_token_hold_on_retransmit",
378}
379
382 icmap_map_t temp_map,
383 const char **error_string)
384{
385 /* Static just to keep them off the stack */
386 static char local_error_reason[512];
387 static char addr_str_buf[INET6_ADDRSTRLEN];
388 const char *error_reason = local_error_reason;
389 char name_key[ICMAP_KEYNAME_MAXLEN];
390 char *name_str;
391 int i, j, num_configured, members;
392 uint32_t tmp_config_value;
393
395 snprintf (local_error_reason, sizeof(local_error_reason),
396 "The max_network_delay parameter (%d ms) may not be less than (%d ms).",
398 goto parse_error;
399 }
400
402 snprintf (local_error_reason, sizeof(local_error_reason),
403 "The token timeout parameter (%d ms) may not be less than (%d ms).",
405 goto parse_error;
406 }
407
408 // coverity[NO_EFFECT:SUPPRESS] clarify bounds of token_warning values and defensive programming
410 snprintf (local_error_reason, sizeof(local_error_reason),
411 "The token warning parameter (%d%%) must be between 0 (disabled) and 100.",
413 goto parse_error;
414 }
415
417 if (icmap_get_uint32_r(temp_map, "totem.token_retransmit", &tmp_config_value) == CS_OK) {
418 snprintf (local_error_reason, sizeof(local_error_reason),
419 "The token retransmit timeout parameter (%d ms) may not be less than (%d ms).",
421 goto parse_error;
422 } else {
423 snprintf (local_error_reason, sizeof(local_error_reason),
424 "Not appropriate token or token_retransmits_before_loss_const value set");
425 goto parse_error;
426 }
427 }
428
430 snprintf (local_error_reason, sizeof(local_error_reason),
431 "The token hold timeout parameter (%d ms) may not be less than (%d ms).",
433 goto parse_error;
434 }
435
437 snprintf (local_error_reason, sizeof(local_error_reason),
438 "The join timeout parameter (%d ms) may not be less than (%d ms).",
440 goto parse_error;
441 }
442
444 snprintf (local_error_reason, sizeof(local_error_reason),
445 "The consensus timeout parameter (%d ms) may not be less than (%d ms).",
447 goto parse_error;
448 }
449
451 snprintf (local_error_reason, sizeof(local_error_reason),
452 "The consensus timeout parameter (%d ms) may not be less than join timeout (%d ms).",
454 goto parse_error;
455 }
456
458 snprintf (local_error_reason, sizeof(local_error_reason),
459 "The merge timeout parameter (%d ms) may not be less than (%d ms).",
461 goto parse_error;
462 }
463
465 snprintf (local_error_reason, sizeof(local_error_reason),
466 "The downcheck timeout parameter (%d ms) may not be less than (%d ms).",
468 goto parse_error;
469 }
470
471 /* Check that we have nodelist 'name' if there is more than one link */
472 num_configured = 0;
473 members = -1;
474 for (i = 0; i < INTERFACE_MAX; i++) {
476 if (num_configured == 0) {
478 }
479 num_configured++;
480 }
481 }
482
483 if (num_configured > 1) {
484 /*
485 * This assert is here just to make compiler happy
486 */
487 assert(members != -1);
488 for (i=0; i < members; i++) {
489 snprintf(name_key, sizeof(name_key), "nodelist.node.%d.name", i);
490
491 if (icmap_get_string_r(temp_map, name_key, &name_str) != CS_OK) {
492 snprintf (local_error_reason, sizeof(local_error_reason),
493 "for a multi-link configuration, all nodes must have a 'name' attribute");
494 goto parse_error;
495 }
496
497 free(name_str);
498 }
499
500 for (i=0; i < INTERFACE_MAX; i++) {
502 continue;
503 }
504 if (totem_config->interfaces[i].member_count != members) {
505 snprintf (local_error_reason, sizeof(local_error_reason),
506 "Not all nodes have the same number of links");
507 goto parse_error;
508 }
509 }
510 }
511
512 /* Verify that all nodes on the same link have the same IP family */
513 for (i=0; i < INTERFACE_MAX; i++) {
514 for (j=1; j<totem_config->interfaces[i].member_count; j++) {
518 memcpy(addr_str_buf,
520 sizeof(addr_str_buf));
521
522 snprintf (local_error_reason, sizeof(local_error_reason),
523 "Nodes for link %d have different IP families "
524 "(compared %s with %s)", i,
525 addr_str_buf,
527 goto parse_error;
528 }
529 }
530 }
531 }
532
533 return 0;
534
535parse_error:
536 snprintf (error_string_response, sizeof(error_string_response),
537 "parse error in config: %s\n", error_reason);
538 *error_string = error_string_response;
539 return (-1);
540
541}
542
543static int totem_get_crypto(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
544{
545 char *str;
546 const char *tmp_cipher;
547 const char *tmp_hash;
548 const char *tmp_model;
549 char *crypto_model_str;
550 int res = 0;
551
552 tmp_hash = "none";
553 tmp_cipher = "none";
554 tmp_model = "none";
555
556 crypto_model_str = NULL;
557 if (icmap_get_string_r(map, "totem.crypto_model", &crypto_model_str) == CS_OK) {
558 tmp_model = crypto_model_str;
559 } else {
560 tmp_model = "nss";
561 }
562
563 if (icmap_get_string_r(map, "totem.secauth", &str) == CS_OK) {
564 if (strcmp(str, "on") == 0) {
565 tmp_cipher = "aes256";
566 tmp_hash = "sha256";
567 }
568 free(str);
569 }
570
571 if (icmap_get_string_r(map, "totem.crypto_cipher", &str) == CS_OK) {
572 if (strcmp(str, "none") == 0) {
573 tmp_cipher = "none";
574 }
575 if (strcmp(str, "aes256") == 0) {
576 tmp_cipher = "aes256";
577 }
578 if (strcmp(str, "aes192") == 0) {
579 tmp_cipher = "aes192";
580 }
581 if (strcmp(str, "aes128") == 0) {
582 tmp_cipher = "aes128";
583 }
584 free(str);
585 }
586
587 if (icmap_get_string_r(map, "totem.crypto_hash", &str) == CS_OK) {
588 if (strcmp(str, "none") == 0) {
589 tmp_hash = "none";
590 }
591 if (strcmp(str, "md5") == 0) {
592 tmp_hash = "md5";
593 }
594 if (strcmp(str, "sha1") == 0) {
595 tmp_hash = "sha1";
596 }
597 if (strcmp(str, "sha256") == 0) {
598 tmp_hash = "sha256";
599 }
600 if (strcmp(str, "sha384") == 0) {
601 tmp_hash = "sha384";
602 }
603 if (strcmp(str, "sha512") == 0) {
604 tmp_hash = "sha512";
605 }
606 free(str);
607 }
608
609 if ((strcmp(tmp_cipher, "none") != 0) &&
610 (strcmp(tmp_hash, "none") == 0)) {
611 *error_string = "crypto_cipher requires crypto_hash with value other than none";
612 res = -1;
613
614 goto out_free_crypto_model_str;
615 }
616
617 if (strcmp(tmp_model, "none") == 0) {
618 /*
619 * Shouldn't happen because it is handled by coroparse
620 */
621 *error_string = "invalid crypto_model";
622 res = -1;
623
624 goto out_free_crypto_model_str;
625 }
626
627 if (strcmp(tmp_cipher, totem_config->crypto_cipher_type) ||
628 strcmp(tmp_hash, totem_config->crypto_hash_type) ||
629 strcmp(tmp_model, totem_config->crypto_model)) {
631 }
632
633 strncpy(totem_config->crypto_cipher_type, tmp_cipher, CONFIG_STRING_LEN_MAX - 1);
635
636 strncpy(totem_config->crypto_hash_type, tmp_hash, CONFIG_STRING_LEN_MAX - 1);
638
639 strncpy(totem_config->crypto_model, tmp_model, CONFIG_STRING_LEN_MAX - 1);
641
642out_free_crypto_model_str:
643 free(crypto_model_str);
644
645 return (res);
646}
647
648static int nodelist_byname(icmap_map_t map, const char *find_name, int strip_domain)
649{
650 icmap_iter_t iter;
651 const char *iter_key;
652 char name_str[ICMAP_KEYNAME_MAXLEN];
653 int res = 0;
654 unsigned int node_pos;
655 char *name;
656 unsigned int namelen;
657
658 iter = icmap_iter_init_r(map, "nodelist.node.");
659 while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
660 res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, name_str);
661 if (res != 2) {
662 continue;
663 }
664 /* ring0_addr is allowed as a fallback */
665 if (strcmp(name_str, "name") && strcmp(name_str, "ring0_addr")) {
666 continue;
667 }
668 if (icmap_get_string_r(map, iter_key, &name) != CS_OK) {
669 continue;
670 }
671 namelen = strlen(name);
672
673 if (strip_domain) {
674 char *dot;
675 dot = strchr(name, '.');
676 if (dot) {
677 namelen = dot - name;
678 }
679 }
680 if (strncmp(find_name, name, namelen) == 0 &&
681 strlen(find_name) == namelen) {
683 return node_pos;
684 }
685 }
687 return -1;
688}
689
690/* Compare two addresses - only address part (sin_addr/sin6_addr) is checked */
691static int ipaddr_equal(const struct sockaddr *addr1, const struct sockaddr *addr2)
692{
693 int addrlen = 0;
694 const void *addr1p, *addr2p;
695
696 if (addr1->sa_family != addr2->sa_family)
697 return 0;
698
699 switch (addr1->sa_family) {
700 case AF_INET:
701 addrlen = sizeof(struct in_addr);
702 addr1p = &((struct sockaddr_in *)addr1)->sin_addr;
703 addr2p = &((struct sockaddr_in *)addr2)->sin_addr;
704 break;
705 case AF_INET6:
706 addrlen = sizeof(struct in6_addr);
707 addr1p = &((struct sockaddr_in6 *)addr1)->sin6_addr;
708 addr2p = &((struct sockaddr_in6 *)addr2)->sin6_addr;
709 break;
710 default:
711 assert(0);
712 }
713
714 return (memcmp(addr1p, addr2p, addrlen) == 0);
715}
716
717
718/* Finds the local node and returns its position in the nodelist.
719 * Uses nodelist.local_node_pos as a cache to save effort
720 */
721static int find_local_node(icmap_map_t map, int use_cache)
722{
723 char nodename2[PATH_MAX];
724 char name_str[ICMAP_KEYNAME_MAXLEN];
725 icmap_iter_t iter;
726 const char *iter_key;
727 unsigned int cached_pos;
728 char *dot = NULL;
729 const char *node;
730 struct ifaddrs *ifa, *ifa_list;
731 struct sockaddr *sa;
732 int found = 0;
733 int node_pos = -1;
734 int res;
735 struct utsname utsname;
736
737 /* Check for cached value first */
738 if (use_cache) {
739 if (icmap_get_uint32("nodelist.local_node_pos", &cached_pos) == CS_OK) {
740 return cached_pos;
741 }
742 }
743
744 res = uname(&utsname);
745 if (res < 0) {
746 return -1;
747 }
748 node = utsname.nodename;
749
750 /* 1. Exact match */
751 node_pos = nodelist_byname(map, node, 0);
752 if (node_pos > -1) {
753 found = 1;
754 goto ret_found;
755 }
756
757 /* 2. Try to match with increasingly more
758 * specific versions of it
759 */
760 strcpy(nodename2, node);
761 dot = strrchr(nodename2, '.');
762 while (dot) {
763 *dot = '\0';
764
765 node_pos = nodelist_byname(map, nodename2, 0);
766 if (node_pos > -1) {
767 found = 1;
768 goto ret_found;
769 }
770 dot = strrchr(nodename2, '.');
771 }
772
773 node_pos = nodelist_byname(map, nodename2, 1);
774 if (node_pos > -1) {
775 found = 1;
776 goto ret_found;
777 }
778
779 /*
780 * The corosync.conf name may not be related to uname at all,
781 * they may match a hostname on some network interface.
782 */
783 if (getifaddrs(&ifa_list))
784 return -1;
785
786 for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
787 socklen_t salen = 0;
788
789 /* Restore this */
790 strcpy(nodename2, node);
791 sa = ifa->ifa_addr;
792 if (!sa) {
793 continue;
794 }
795 if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6) {
796 continue;
797 }
798
799 if (sa->sa_family == AF_INET) {
800 salen = sizeof(struct sockaddr_in);
801 }
802 if (sa->sa_family == AF_INET6) {
803 salen = sizeof(struct sockaddr_in6);
804 }
805
806 if (getnameinfo(sa, salen,
807 nodename2, sizeof(nodename2),
808 NULL, 0, 0) == 0) {
809
810 node_pos = nodelist_byname(map, nodename2, 0);
811 if (node_pos > -1) {
812 found = 1;
813 goto out;
814 }
815
816 /* Truncate this name and try again */
817 dot = strchr(nodename2, '.');
818 if (dot) {
819 *dot = '\0';
820
821 node_pos = nodelist_byname(map, nodename2, 0);
822 if (node_pos > -1) {
823 found = 1;
824 goto out;
825 }
826 }
827 }
828
829 /* See if it's the IP address that's in corosync.conf */
830 if (getnameinfo(sa, sizeof(*sa),
831 nodename2, sizeof(nodename2),
832 NULL, 0, NI_NUMERICHOST))
833 continue;
834
835 node_pos = nodelist_byname(map, nodename2, 0);
836 if (node_pos > -1) {
837 found = 1;
838 goto out;
839 }
840 }
841
842 out:
843 if (found) {
844 freeifaddrs(ifa_list);
845 goto ret_found;
846 }
847
848 /*
849 * This section covers the usecase where the nodename specified in cluster.conf
850 * is an alias specified in /etc/hosts. For example:
851 * <ipaddr> hostname alias1 alias2
852 * and <clusternode name="alias2">
853 * the above calls use uname and getnameinfo does not return aliases.
854 * here we take the name specified in cluster.conf, resolve it to an address
855 * and then compare against all known local ip addresses.
856 * if we have a match, we found our nodename. In theory this chunk of code
857 * could replace all the checks above, but let's avoid any possible regressions
858 * and use it as last.
859 */
860
861 iter = icmap_iter_init_r(map, "nodelist.node.");
862 while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
863 char *dbnodename = NULL;
864 struct addrinfo hints;
865 struct addrinfo *result = NULL, *rp = NULL;
866
867 res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, name_str);
868 if (res != 2) {
869 continue;
870 }
871 /* 'ring0_addr' is allowed as a fallback, but 'name' will be found first
872 * because the names are in alpha order.
873 */
874 if (strcmp(name_str, "name") && strcmp(name_str, "ring0_addr")) {
875 continue;
876 }
877 if (icmap_get_string_r(map, iter_key, &dbnodename) != CS_OK) {
878 continue;
879 }
880
881 memset(&hints, 0, sizeof(struct addrinfo));
882 hints.ai_family = AF_UNSPEC;
883 hints.ai_socktype = SOCK_DGRAM;
884 hints.ai_flags = 0;
885 hints.ai_protocol = IPPROTO_UDP;
886
887 if (getaddrinfo(dbnodename, NULL, &hints, &result)) {
888 continue;
889 }
890
891 for (rp = result; rp != NULL; rp = rp->ai_next) {
892 for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
893 if (ifa->ifa_addr &&
894 ipaddr_equal(rp->ai_addr, ifa->ifa_addr)) {
895 freeaddrinfo(result);
896 found = 1;
897 goto out2;
898 }
899 }
900 }
901
902 freeaddrinfo(result);
903 }
904out2:
906 freeifaddrs(ifa_list);
907
908ret_found:
909 if (found) {
910 res = icmap_set_uint32_r(map, "nodelist.local_node_pos", node_pos);
911 }
912
913 return node_pos;
914}
915
916static enum totem_ip_version_enum totem_config_get_ip_version(struct totem_config *totem_config)
917{
918 enum totem_ip_version_enum res;
919 char *str;
920
922
924 res = TOTEM_IP_VERSION_4;
925 }
926
927 if (icmap_get_string("totem.ip_version", &str) == CS_OK) {
928 if (strcmp(str, "ipv4") == 0) {
929 res = TOTEM_IP_VERSION_4;
930 }
931 if (strcmp(str, "ipv6") == 0) {
932 res = TOTEM_IP_VERSION_6;
933 }
934 if (strcmp(str, "ipv6-4") == 0) {
936 }
937 if (strcmp(str, "ipv4-6") == 0) {
939 }
940 free(str);
941 }
942
943 return (res);
944}
945
946static uint16_t generate_cluster_id (const char *cluster_name)
947{
948 int i;
949 int value = 0;
950
951 for (i = 0; i < strlen(cluster_name); i++) {
952 value <<= 1;
953 value += cluster_name[i];
954 }
955
956 return (value & 0xFFFF);
957}
958
959static int get_cluster_mcast_addr (
960 const char *cluster_name,
961 unsigned int linknumber,
962 enum totem_ip_version_enum ip_version,
963 struct totem_ip_address *res)
964{
965 uint16_t clusterid;
966 char addr[INET6_ADDRSTRLEN + 1];
967 int err;
968
969 if (cluster_name == NULL) {
970 return (-1);
971 }
972
973 clusterid = generate_cluster_id(cluster_name) + linknumber;
974 memset (res, 0, sizeof(*res));
975
976 switch (ip_version) {
979 snprintf(addr, sizeof(addr), "239.192.%d.%d", clusterid >> 8, clusterid % 0xFF);
980 break;
983 snprintf(addr, sizeof(addr), "ff15::%x", clusterid);
984 break;
985 default:
986 /*
987 * Unknown family
988 */
989 return (-1);
990 }
991
992 err = totemip_parse (res, addr, ip_version);
993
994 return (err);
995}
996
997static unsigned int generate_nodeid(
999 char *addr)
1000{
1001 unsigned int nodeid;
1002 struct totem_ip_address totemip;
1003
1004 /* AF_INET hard-coded here because auto-generated nodeids
1005 are only for IPv4 */
1006 if (totemip_parse(&totemip, addr, TOTEM_IP_VERSION_4) != 0)
1007 return -1;
1008
1009 memcpy (&nodeid, &totemip.addr, sizeof (unsigned int));
1010
1011#if __BYTE_ORDER == __LITTLE_ENDIAN
1012 nodeid = swab32 (nodeid);
1013#endif
1014
1016 nodeid &= 0x7FFFFFFF;
1017 }
1018 return nodeid;
1019}
1020
1021static int check_for_duplicate_nodeids(
1022 struct totem_config *totem_config,
1023 const char **error_string)
1024{
1025 icmap_iter_t iter;
1026 icmap_iter_t subiter;
1027 const char *iter_key;
1028 int res = 0;
1029 int retval = 0;
1030 char tmp_key[ICMAP_KEYNAME_MAXLEN];
1031 char *ring0_addr=NULL;
1032 char *ring0_addr1=NULL;
1033 unsigned int node_pos;
1034 unsigned int node_pos1;
1035 unsigned int last_node_pos = -1;
1036 unsigned int nodeid;
1037 unsigned int nodeid1;
1038 int autogenerated;
1039
1040 iter = icmap_iter_init("nodelist.node.");
1041 while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
1042 res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, tmp_key);
1043 if (res != 2) {
1044 continue;
1045 }
1046
1047 /*
1048 * This relies on the fact the icmap keys are always returned in order
1049 * so all of the keys for a node will be grouped together. We're basically
1050 * just running the code below once for each node.
1051 */
1052 if (last_node_pos == node_pos) {
1053 continue;
1054 }
1055 last_node_pos = node_pos;
1056
1057 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
1058 autogenerated = 0;
1059
1060 /* Generated nodeids are only allowed for UDP/UDPU so ring0_addr is valid here */
1061 if (icmap_get_uint32(tmp_key, &nodeid) != CS_OK) {
1062
1063 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos);
1064 if (icmap_get_string(tmp_key, &ring0_addr) != CS_OK) {
1065 continue;
1066 }
1067
1068 /* Generate nodeid so we can check that auto-generated nodeids don't clash either */
1069 nodeid = generate_nodeid(totem_config, ring0_addr);
1070 if (nodeid == -1) {
1071 continue;
1072 }
1073 autogenerated = 1;
1074 }
1075
1076 node_pos1 = 0;
1077 subiter = icmap_iter_init("nodelist.node.");
1078 while (((iter_key = icmap_iter_next(subiter, NULL, NULL)) != NULL) && (node_pos1 < node_pos)) {
1079 res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos1, tmp_key);
1080 if ((res != 2) || (node_pos1 >= node_pos)) {
1081 continue;
1082 }
1083
1084 if (strcmp(tmp_key, "nodeid") != 0) {
1085 continue;
1086 }
1087
1088 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos1);
1089 if (icmap_get_uint32(tmp_key, &nodeid1) != CS_OK) {
1090
1091 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos1);
1092 if (icmap_get_string(tmp_key, &ring0_addr1) != CS_OK) {
1093 continue;
1094 }
1095 nodeid1 = generate_nodeid(totem_config, ring0_addr1);
1096 if (nodeid1 == -1) {
1097 continue;
1098 }
1099 }
1100
1101 if (nodeid == nodeid1) {
1102 retval = -1;
1103 snprintf (error_string_response, sizeof(error_string_response),
1104 "Nodeid %u%s%s%s appears twice in corosync.conf", nodeid,
1105 autogenerated?"(autogenerated from ":"",
1106 autogenerated?ring0_addr:"",
1107 autogenerated?")":"");
1108 *error_string = error_string_response;
1109 break;
1110 }
1111 }
1112 icmap_iter_finalize(subiter);
1113 }
1114 icmap_iter_finalize(iter);
1115 return retval;
1116}
1117
1118
1119/*
1120 * This needs to be done last of all. It would be nice to do it when reading the
1121 * interface params, but the totem params need to have them to be read first. We
1122 * need both, so this is a way round that circular dependancy.
1123 */
1124static void calc_knet_ping_timers(struct totem_config *totem_config)
1125{
1126 char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
1127 int interface;
1128
1129 for (interface = 0; interface < INTERFACE_MAX; interface++) {
1130
1131 if (totem_config->interfaces[interface].configured) {
1132 if (!totem_config->interfaces[interface].knet_pong_count) {
1134 }
1135 if (!totem_config->interfaces[interface].knet_ping_timeout) {
1138 }
1139 snprintf(runtime_key_name, sizeof(runtime_key_name),
1140 "runtime.config.totem.interface.%d.knet_ping_timeout", interface);
1141 icmap_set_uint32(runtime_key_name, totem_config->interfaces[interface].knet_ping_timeout);
1142
1143 if (!totem_config->interfaces[interface].knet_ping_interval) {
1146 }
1147 snprintf(runtime_key_name, sizeof(runtime_key_name),
1148 "runtime.config.totem.interface.%d.knet_ping_interval", interface);
1149 icmap_set_uint32(runtime_key_name, totem_config->interfaces[interface].knet_ping_interval);
1150 }
1151 }
1152}
1153
1154/*
1155 * Compute difference between two set of totem interface arrays and commit it.
1156 * set1 and set2
1157 * are changed so for same ring, ip existing in both set1 and set2 are cleared
1158 * (set to 0), and ips which are only in set1 or set2 remains untouched.
1159 * totempg_node_add/remove is called.
1160 */
1161static int compute_and_set_totempg_interfaces(struct totem_interface *set1,
1162 struct totem_interface *set2)
1163{
1164 int ring_no, set1_pos, set2_pos;
1165 struct totem_ip_address empty_ip_address;
1166 int res = 0;
1167
1168 memset(&empty_ip_address, 0, sizeof(empty_ip_address));
1169
1170 for (ring_no = 0; ring_no < INTERFACE_MAX; ring_no++) {
1171 if (!set1[ring_no].configured && !set2[ring_no].configured) {
1172 continue;
1173 }
1174
1175 for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
1176 for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
1177 /*
1178 * For current ring_no remove all set1 items existing
1179 * in set2
1180 */
1181 if (memcmp(&set1[ring_no].member_list[set1_pos],
1182 &set2[ring_no].member_list[set2_pos],
1183 sizeof(struct totem_ip_address)) == 0) {
1184 memset(&set1[ring_no].member_list[set1_pos], 0,
1185 sizeof(struct totem_ip_address));
1186 memset(&set2[ring_no].member_list[set2_pos], 0,
1187 sizeof(struct totem_ip_address));
1188 }
1189 }
1190 }
1191 }
1192
1193 for (ring_no = 0; ring_no < INTERFACE_MAX; ring_no++) {
1194 for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
1195 /*
1196 * All items which remain in set1 and don't exist in set2 any more
1197 * have to be removed.
1198 */
1199 if (memcmp(&set1[ring_no].member_list[set1_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
1201 "removing dynamic member %s for ring %u",
1202 totemip_print(&set1[ring_no].member_list[set1_pos]),
1203 ring_no);
1204
1205 totempg_member_remove(&set1[ring_no].member_list[set1_pos], ring_no);
1206 }
1207 }
1208 if (!set2[ring_no].configured) {
1209 continue;
1210 }
1211 for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
1212 /*
1213 * All items which remain in set2 and don't exist in set1 are new nodes
1214 * and have to be added.
1215 */
1216 if (memcmp(&set2[ring_no].member_list[set2_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
1218 "adding dynamic member %s for ring %u",
1219 totemip_print(&set2[ring_no].member_list[set2_pos]),
1220 ring_no);
1221
1222 if (totempg_member_add(&set2[ring_no].member_list[set2_pos], ring_no)) {
1223 res = -1;
1224 }
1225 }
1226 }
1227 }
1228 return res;
1229}
1230
1231/*
1232 * Configure parameters for links
1233 */
1234static void configure_link_params(struct totem_config *totem_config, icmap_map_t map)
1235{
1236 int i;
1237 char tmp_key[ICMAP_KEYNAME_MAXLEN];
1238 char *addr_string;
1239 int err;
1240 int local_node_pos = find_local_node(map, 0);
1241
1242 for (i = 0; i<INTERFACE_MAX; i++) {
1244 continue;
1245 }
1246
1247 log_printf(LOGSYS_LEVEL_DEBUG, "Configuring link %d params\n", i);
1248
1249 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring%u_addr", local_node_pos, i);
1250 if (icmap_get_string_r(map, tmp_key, &addr_string) != CS_OK) {
1251 continue;
1252 }
1253
1255 if (err != 0) {
1256 continue;
1257 }
1259
1260 /* In case this is a new link, fill in the defaults if there was no interface{} section for it */
1263
1264 /* knet_ping_interval & knet_ping_timeout are set later once we know all the other params */
1270 totem_config->interfaces[i].knet_transport = KNET_TRANSPORT_UDP;
1273 }
1274}
1275
1276
1277static void configure_totem_links(struct totem_config *totem_config, icmap_map_t map)
1278{
1279 int i;
1280
1281 for (i = 0; i<INTERFACE_MAX; i++) {
1283 continue;
1284 }
1285
1286 log_printf(LOGSYS_LEVEL_INFO, "Configuring link %d\n", i);
1287
1289 }
1290}
1291
1292/* Check for differences in config that can't be done on-the-fly and print an error */
1293static int check_things_have_not_changed(struct totem_config *totem_config, const char **error_string)
1294{
1295 int i,j,k;
1296 const char *ip_str;
1297 char addr_buf[INET6_ADDRSTRLEN];
1298 int changed = 0;
1299
1300 for (i = 0; i<INTERFACE_MAX; i++) {
1306 "New config has different knet transport for link %d. Internal value was NOT changed.\n", i);
1307 changed = 1;
1308 }
1309
1310 /* Check each nodeid in the new configuration and make sure its IP address on this link has not changed */
1311 for (j=0; j < totem_config->interfaces[i].member_count; j++) {
1312 for (k=0; k < totem_config->orig_interfaces[i].member_count; k++) {
1313
1316
1317 /* Found our nodeid - check the IP address */
1318 if (memcmp(&totem_config->interfaces[i].member_list[j],
1320 sizeof(struct totem_ip_address))) {
1321
1323
1324 /* if ip_str is NULL then the old address was invalid and is allowed to change */
1325 if (ip_str) {
1326 strncpy(addr_buf, ip_str, sizeof(addr_buf));
1327 addr_buf[sizeof(addr_buf) - 1] = '\0';
1329 "new config has different address for link %d (addr changed from %s to %s). Internal value was NOT changed.\n",
1330 i, addr_buf, totemip_print(&totem_config->interfaces[i].member_list[j]));
1331 changed = 1;
1332 }
1333 }
1334 }
1335 }
1336 }
1337 }
1338 }
1339
1340 if (changed) {
1341 snprintf (error_string_response, sizeof(error_string_response),
1342 "To reconfigure an interface it must be deleted and recreated. A working interface needs to be available to corosync at all times");
1343 *error_string = error_string_response;
1344 return -1;
1345 }
1346 return 0;
1347}
1348
1349
1350static int put_nodelist_members_to_config(struct totem_config *totem_config, icmap_map_t map,
1351 int reload, const char **error_string)
1352{
1353 icmap_iter_t iter, iter2;
1354 const char *iter_key, *iter_key2;
1355 int res = 0;
1356 unsigned int node_pos;
1357 char tmp_key[ICMAP_KEYNAME_MAXLEN];
1358 char tmp_key2[ICMAP_KEYNAME_MAXLEN];
1359 char *node_addr_str;
1360 int member_count;
1361 unsigned int linknumber = 0;
1362 int i, j;
1363 int last_node_pos = -1;
1364
1365 /* Clear out nodelist so we can put the new one in if needed */
1366 for (i = 0; i < INTERFACE_MAX; i++) {
1367 for (j = 0; j < PROCESSOR_COUNT_MAX; j++) {
1368 memset(&totem_config->interfaces[i].member_list[j], 0, sizeof(struct totem_ip_address));
1369 }
1371 }
1372
1373 iter = icmap_iter_init_r(map, "nodelist.node.");
1374 while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
1375 res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, tmp_key);
1376 if (res != 2) {
1377 continue;
1378 }
1379 /* If it's the same as the last node_pos then skip it */
1380 if (node_pos == last_node_pos) {
1381 continue;
1382 }
1383 last_node_pos = node_pos;
1384
1385 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
1386 iter2 = icmap_iter_init_r(map, tmp_key);
1387 while ((iter_key2 = icmap_iter_next(iter2, NULL, NULL)) != NULL) {
1388 unsigned int nodeid;
1389 char *str;
1390
1391 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
1392 if (icmap_get_uint32_r(map, tmp_key, &nodeid) != CS_OK) {
1393 nodeid = 0;
1394 }
1395
1396 res = sscanf(iter_key2, "nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
1397 if (res != 3 || strcmp(tmp_key2, "_addr") != 0) {
1398 continue;
1399 }
1400 if (linknumber >= INTERFACE_MAX) {
1401 snprintf (error_string_response, sizeof(error_string_response),
1402 "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
1403 linknumber, INTERFACE_MAX - 1);
1404 *error_string = error_string_response;
1405
1406 icmap_iter_finalize(iter2);
1407 icmap_iter_finalize(iter);
1408 return (-1);
1409 }
1410
1411 if (icmap_get_string_r(map, iter_key2, &node_addr_str) != CS_OK) {
1412 continue;
1413 }
1414
1415 /* Generate nodeids if they are not provided and transport is UDP/U */
1416 if (!nodeid &&
1419 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos);
1420 if (icmap_get_string_r(map, tmp_key, &str) == CS_OK) {
1421 nodeid = generate_nodeid(totem_config, str);
1422 if (nodeid == -1) {
1423 sprintf(error_string_response,
1424 "An IPV6 network requires that a node ID be specified "
1425 "for address '%s'.", node_addr_str);
1426 *error_string = error_string_response;
1427 free(str);
1428
1429 return (-1);
1430 }
1431
1433 "Generated nodeid = " CS_PRI_NODE_ID " for %s", nodeid, str);
1434
1435 free(str);
1436 /*
1437 * Put nodeid back to nodelist to make cfgtool work
1438 */
1439 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
1440 /*
1441 * Not critical
1442 */
1443 (void)icmap_set_uint32_r(map, tmp_key, nodeid);
1444 }
1445 }
1446
1448 sprintf(error_string_response,
1449 "Knet requires an explicit nodeid to be specified "
1450 "for address '%s'.", node_addr_str);
1451 *error_string = error_string_response;
1452
1453 return (-1);
1454 }
1455
1456 if (totem_config->transport_number == TOTEM_TRANSPORT_KNET && nodeid >= KNET_MAX_HOST) {
1457 sprintf(error_string_response,
1458 "Knet requires nodeid to be less than %u "
1459 "for address '%s'.", KNET_MAX_HOST, node_addr_str);
1460 *error_string = error_string_response;
1461
1462 return (-1);
1463 }
1464
1465 member_count = totem_config->interfaces[linknumber].member_count;
1466 res = totemip_parse(&totem_config->interfaces[linknumber].member_list[member_count],
1467 node_addr_str, totem_config->ip_version);
1468 if (res == 0) {
1469 totem_config->interfaces[linknumber].member_list[member_count].nodeid = nodeid;
1470 totem_config->interfaces[linknumber].member_count++;
1471 totem_config->interfaces[linknumber].configured = 1;
1472 } else {
1473 sprintf(error_string_response, "failed to parse node address '%s'\n", node_addr_str);
1474 *error_string = error_string_response;
1475
1476 memset(&totem_config->interfaces[linknumber].member_list[member_count], 0,
1477 sizeof(struct totem_ip_address));
1478
1479 free(node_addr_str);
1480 icmap_iter_finalize(iter2);
1481 icmap_iter_finalize(iter);
1482 return -1;
1483 }
1484
1485 free(node_addr_str);
1486 }
1487
1488 icmap_iter_finalize(iter2);
1489 }
1490
1491 icmap_iter_finalize(iter);
1492
1493 configure_link_params(totem_config, map);
1494 if (reload) {
1495 log_printf(LOGSYS_LEVEL_DEBUG, "About to reconfigure links from nodelist.\n");
1496
1497 if (check_things_have_not_changed(totem_config, error_string) == -1) {
1498 return -1;
1499 }
1500 }
1501 return 0;
1502}
1503
1504static void config_convert_nodelist_to_interface(icmap_map_t map, struct totem_config *totem_config)
1505{
1506 int res = 0;
1507 int node_pos;
1508 char tmp_key[ICMAP_KEYNAME_MAXLEN];
1509 char tmp_key2[ICMAP_KEYNAME_MAXLEN];
1510 char *node_addr_str;
1511 unsigned int linknumber = 0;
1512 icmap_iter_t iter;
1513 const char *iter_key;
1514
1515 node_pos = find_local_node(map, 1);
1516 if (node_pos > -1) {
1517 /*
1518 * We found node, so create interface section
1519 */
1520 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
1521 iter = icmap_iter_init_r(map, tmp_key);
1522 while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
1523 res = sscanf(iter_key, "nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
1524 if (res != 3 || strcmp(tmp_key2, "_addr") != 0) {
1525 continue ;
1526 }
1527
1528 if (icmap_get_string_r(map, iter_key, &node_addr_str) != CS_OK) {
1529 continue;
1530 }
1531
1532 snprintf(tmp_key2, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.bindnetaddr", linknumber);
1533 icmap_set_string_r(map, tmp_key2, node_addr_str);
1534 free(node_addr_str);
1535 }
1536 icmap_iter_finalize(iter);
1537 }
1538}
1539
1540static int get_interface_params(struct totem_config *totem_config, icmap_map_t map,
1541 const char **error_string, uint64_t *warnings,
1542 int reload)
1543{
1544 int res = 0;
1545 unsigned int linknumber = 0;
1546 int member_count = 0;
1547 int i;
1548 icmap_iter_t iter, member_iter;
1549 const char *iter_key;
1550 const char *member_iter_key;
1551 char linknumber_key[ICMAP_KEYNAME_MAXLEN];
1552 char tmp_key[ICMAP_KEYNAME_MAXLEN];
1553 uint8_t u8;
1554 uint32_t u32;
1555 char *str;
1556 char *cluster_name = NULL;
1557 enum totem_ip_version_enum tmp_ip_version = TOTEM_IP_VERSION_4;
1558 int ret = 0;
1559
1560 if (reload) {
1561 for (i=0; i<INTERFACE_MAX; i++) {
1562 /*
1563 * Set back to defaults things that might have been configured and
1564 * now have been taken out of corosync.conf. These won't be caught by the
1565 * code below which only looks at interface{} sections that actually exist.
1566 */
1572 }
1573 }
1574 if (icmap_get_string_r(map, "totem.cluster_name", &cluster_name) != CS_OK) {
1575 cluster_name = NULL;
1576 }
1577
1578 iter = icmap_iter_init_r(map, "totem.interface.");
1579 while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
1580 res = sscanf(iter_key, "totem.interface.%[^.].%s", linknumber_key, tmp_key);
1581 if (res != 2) {
1582 continue;
1583 }
1584
1585 if (strcmp(tmp_key, "bindnetaddr") != 0 && totem_config->transport_number == TOTEM_TRANSPORT_UDP) {
1586 continue;
1587 }
1588
1589 member_count = 0;
1590 linknumber = atoi(linknumber_key);
1591
1592 if (linknumber >= INTERFACE_MAX) {
1593 snprintf (error_string_response, sizeof(error_string_response),
1594 "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
1595 linknumber, INTERFACE_MAX - 1);
1596
1597 *error_string = error_string_response;
1598 ret = -1;
1599 goto out;
1600 }
1601
1602 /* These things are only valid for the initial read */
1603 if (!reload) {
1604 /*
1605 * Get the bind net address
1606 */
1607 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.bindnetaddr", linknumber);
1608
1609 if (icmap_get_string_r(map, tmp_key, &str) == CS_OK) {
1610 res = totemip_parse (&totem_config->interfaces[linknumber].bindnet, str,
1612
1613 if (res) {
1614 sprintf(error_string_response, "failed to parse bindnet address '%s'\n", str);
1615 *error_string = error_string_response;
1616 free(str);
1617
1618 ret = -1;
1619 goto out;
1620 }
1621
1622 free(str);
1623 }
1624
1625 /*
1626 * Get interface multicast address
1627 */
1628 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastaddr", linknumber);
1629 if (icmap_get_string_r(map, tmp_key, &str) == CS_OK) {
1630 res = totemip_parse (&totem_config->interfaces[linknumber].mcast_addr, str,
1632
1633 if (res) {
1634 sprintf(error_string_response, "failed to parse mcast address '%s'\n", str);
1635 *error_string = error_string_response;
1636 free(str);
1637
1638 ret = -1;
1639 goto out;
1640 }
1641
1642 free(str);
1644 /*
1645 * User not specified address -> autogenerate one from cluster_name key
1646 * (if available). Return code is intentionally ignored, because
1647 * udpu doesn't need mcastaddr and validity of mcastaddr for udp is
1648 * checked later anyway.
1649 */
1650
1651 if (totem_config->interfaces[0].bindnet.family == AF_INET) {
1652 tmp_ip_version = TOTEM_IP_VERSION_4;
1653 } else if (totem_config->interfaces[0].bindnet.family == AF_INET6) {
1654 tmp_ip_version = TOTEM_IP_VERSION_6;
1655 }
1656
1657 (void)get_cluster_mcast_addr (cluster_name,
1658 linknumber,
1659 tmp_ip_version,
1660 &totem_config->interfaces[linknumber].mcast_addr);
1661 }
1662
1663 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.broadcast", linknumber);
1664 if (icmap_get_string(tmp_key, &str) == CS_OK) {
1665 if (strcmp (str, "yes") == 0) {
1667 }
1668 free(str);
1669 }
1670 }
1671
1672 /* These things are only valid for the initial read OR a newly-defined link */
1673 if (!reload || (totem_config->interfaces[linknumber].configured == 0)) {
1674
1675 /*
1676 * Get mcast port
1677 */
1678 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastport", linknumber);
1679 if (icmap_get_uint16_r(map, tmp_key, &totem_config->interfaces[linknumber].ip_port) != CS_OK) {
1681 totem_config->interfaces[linknumber].ip_port = DEFAULT_PORT + (2 * linknumber);
1682 } else {
1683 totem_config->interfaces[linknumber].ip_port = DEFAULT_PORT + linknumber;
1684 }
1685 }
1686
1687 /*
1688 * Get the TTL
1689 */
1690 totem_config->interfaces[linknumber].ttl = 1;
1691
1692 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.ttl", linknumber);
1693
1694 if (icmap_get_uint8_r(map, tmp_key, &u8) == CS_OK) {
1695 totem_config->interfaces[linknumber].ttl = u8;
1696 }
1697
1699 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_transport", linknumber);
1700 if (icmap_get_string_r(map, tmp_key, &str) == CS_OK) {
1701#ifdef KNET_TRANSPORT_SCTP
1702 if (strcmp(str, "sctp") == 0) {
1703 totem_config->interfaces[linknumber].knet_transport = KNET_TRANSPORT_SCTP;
1704 log_printf(LOGSYS_LEVEL_WARNING, "WARNING SCTP transport is deprecated and will be removed in a future release.\n");
1705 } else
1706#endif
1707 if (strcmp(str, "udp") == 0) {
1708 totem_config->interfaces[linknumber].knet_transport = KNET_TRANSPORT_UDP;
1709 }
1710 else {
1711#ifdef KNET_TRANSPORT_SCTP
1712 *error_string = "Unrecognised knet_transport. expected 'udp' or 'sctp'";
1713#else
1714 *error_string = "Unrecognised knet_transport. only 'udp' is supported";
1715#endif
1716 ret = -1;
1717 goto out;
1718 }
1719 }
1720 }
1721 totem_config->interfaces[linknumber].configured = 1;
1722
1723 /*
1724 * Get the knet link params
1725 */
1727 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_link_priority", linknumber);
1728
1729 if (icmap_get_uint8_r(map, tmp_key, &u8) == CS_OK) {
1730 totem_config->interfaces[linknumber].knet_link_priority = u8;
1731 }
1732
1733 totem_config->interfaces[linknumber].knet_ping_interval = 0; /* real default applied later */
1734 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_ping_interval", linknumber);
1735 if (icmap_get_uint32_r(map, tmp_key, &u32) == CS_OK) {
1736 totem_config->interfaces[linknumber].knet_ping_interval = u32;
1737 }
1738 totem_config->interfaces[linknumber].knet_ping_timeout = 0; /* real default applied later */
1739 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_ping_timeout", linknumber);
1740 if (icmap_get_uint32_r(map, tmp_key, &u32) == CS_OK) {
1741 totem_config->interfaces[linknumber].knet_ping_timeout = u32;
1742 }
1744 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_ping_precision", linknumber);
1745 if (icmap_get_uint32_r(map, tmp_key, &u32) == CS_OK) {
1746 totem_config->interfaces[linknumber].knet_ping_precision = u32;
1747 }
1749 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_pong_count", linknumber);
1750 if (icmap_get_uint32_r(map, tmp_key, &u32) == CS_OK) {
1751 totem_config->interfaces[linknumber].knet_pong_count = u32;
1752 }
1753
1754 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.member.", linknumber);
1755 member_iter = icmap_iter_init_r(map, tmp_key);
1756 while ((member_iter_key = icmap_iter_next(member_iter, NULL, NULL)) != NULL) {
1757 if (member_count == 0) {
1758 if (icmap_get_string("nodelist.node.0.ring0_addr", &str) == CS_OK) {
1759 free(str);
1761 break;
1762 } else {
1764 }
1765 }
1766
1767 if (icmap_get_string_r(map, member_iter_key, &str) == CS_OK) {
1768 res = totemip_parse (&totem_config->interfaces[linknumber].member_list[member_count++],
1769 str, totem_config->ip_version);
1770 if (res) {
1771 sprintf(error_string_response, "failed to parse node address '%s'\n", str);
1772 *error_string = error_string_response;
1773
1774 icmap_iter_finalize(member_iter);
1775 free(str);
1776 ret = -1;
1777 goto out;
1778 }
1779
1780 free(str);
1781 }
1782 }
1783 icmap_iter_finalize(member_iter);
1784
1785 totem_config->interfaces[linknumber].member_count = member_count;
1786
1787 }
1788
1789out:
1790 icmap_iter_finalize(iter);
1791 free(cluster_name);
1792
1793 return (ret);
1794}
1795
1797 struct totem_config *totem_config,
1798 const char **error_string,
1799 uint64_t *warnings)
1800{
1801 int res = 0;
1802 char *str, *ring0_addr_str;
1803 char tmp_key[ICMAP_KEYNAME_MAXLEN];
1804 uint16_t u16;
1805 int i;
1806 int local_node_pos;
1807 uint32_t u32;
1808
1809 *warnings = 0;
1810
1811 memset (totem_config, 0, sizeof (struct totem_config));
1812 totem_config->interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
1813 if (totem_config->interfaces == 0) {
1814 *error_string = "Out of memory trying to allocate ethernet interface storage area";
1815 return -1;
1816 }
1817
1819 if (icmap_get_string("totem.transport", &str) == CS_OK) {
1820 if (strcmp (str, "udpu") == 0) {
1822 } else if (strcmp (str, "udp") == 0) {
1824 } else if (strcmp (str, "knet") == 0) {
1826 } else {
1827 *error_string = "Invalid transport type. Should be udpu, udp or knet";
1828 free(str);
1829 return -1;
1830 }
1831
1832 free(str);
1833 }
1834
1835 memset (totem_config->interfaces, 0,
1836 sizeof (struct totem_interface) * INTERFACE_MAX);
1837
1838 strcpy (totem_config->link_mode, "passive");
1839
1840 icmap_get_uint32("totem.version", (uint32_t *)&totem_config->version);
1841
1842 /* initial crypto load */
1843 if (totem_get_crypto(totem_config, icmap_get_global_map(), error_string) != 0) {
1844 return -1;
1845 }
1846 if (totem_config_keyread(totem_config, icmap_get_global_map(), error_string) != 0) {
1847 return -1;
1848 }
1851
1852 if (icmap_get_string("totem.link_mode", &str) == CS_OK) {
1853 if (strlen(str) >= TOTEM_LINK_MODE_BYTES) {
1854 *error_string = "totem.link_mode is too long";
1855 free(str);
1856
1857 return -1;
1858 }
1859 strcpy (totem_config->link_mode, str);
1860 free(str);
1861 }
1862
1863 if (icmap_get_uint32("totem.nodeid", &u32) == CS_OK) {
1865 }
1866
1868 if (icmap_get_string("totem.clear_node_high_bit", &str) == CS_OK) {
1869 if (strcmp (str, "yes") == 0) {
1871 }
1872 free(str);
1873 }
1874
1875 icmap_get_uint32("totem.threads", &totem_config->threads);
1876
1877 icmap_get_uint32("totem.netmtu", &totem_config->net_mtu);
1878
1879 totem_config->ip_version = totem_config_get_ip_version(totem_config);
1880
1881 if (icmap_get_string("totem.interface.0.bindnetaddr", &str) != CS_OK) {
1882 /*
1883 * We were not able to find ring 0 bindnet addr. Try to use nodelist informations
1884 */
1885 config_convert_nodelist_to_interface(icmap_get_global_map(), totem_config);
1886 } else {
1887 if (icmap_get_string("nodelist.node.0.ring0_addr", &ring0_addr_str) == CS_OK) {
1888 /*
1889 * Both bindnetaddr and ring0_addr are set.
1890 * Log warning information, and use nodelist instead
1891 */
1893
1894 config_convert_nodelist_to_interface(icmap_get_global_map(), totem_config);
1895
1896 free(ring0_addr_str);
1897 }
1898
1899 free(str);
1900 }
1901
1902 /*
1903 * Broadcast option is global but set in interface section,
1904 * so reset before processing interfaces.
1905 */
1907
1908 res = get_interface_params(totem_config, icmap_get_global_map(), error_string, warnings, 0);
1909 if (res < 0) {
1910 return res;
1911 }
1912
1913 /*
1914 * Use broadcast is global, so if set, make sure to fill mcast addr correctly
1915 * broadcast is only supported for UDP so just do interface 0;
1916 */
1919 "255.255.255.255", TOTEM_IP_VERSION_4);
1920 }
1921
1922 totem_config->ip_dscp = 0;
1923 (void)icmap_get_uint8("totem.ip_dscp", &totem_config->ip_dscp);
1924
1925 /*
1926 * Store automatically generated items back to icmap only for UDP
1927 */
1929 for (i = 0; i < INTERFACE_MAX; i++) {
1931 continue;
1932 }
1933 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastaddr", i);
1934 if (icmap_get_string(tmp_key, &str) == CS_OK) {
1935 free(str);
1936 } else {
1937 str = (char *)totemip_print(&totem_config->interfaces[i].mcast_addr);
1938 icmap_set_string(tmp_key, str);
1939 }
1940
1941 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastport", i);
1942 if (icmap_get_uint16(tmp_key, &u16) != CS_OK) {
1944 }
1945 }
1946 }
1947
1948 /*
1949 * Store mcastport value to cmap runtime section for KNET
1950 */
1952 for (i = 0; i < INTERFACE_MAX; i++) {
1954 continue;
1955 }
1956 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "runtime.config.totem.interface.%u.mcastport", i);
1958 }
1959 }
1960
1961 /*
1962 * Check existence of nodelist
1963 */
1964 if ((icmap_get_string("nodelist.node.0.name", &str) == CS_OK) ||
1965 (icmap_get_string("nodelist.node.0.ring0_addr", &str) == CS_OK)) {
1966 free(str);
1967 /*
1968 * find local node
1969 */
1970 local_node_pos = find_local_node(icmap_get_global_map(), 1);
1971 if (local_node_pos != -1) {
1972
1973 assert(totem_config->node_id == 0);
1974
1975 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", local_node_pos);
1976 (void)icmap_get_uint32(tmp_key, &totem_config->node_id);
1977
1978
1980 *error_string = "Knet requires an explicit nodeid for the local node";
1981 return -1;
1982 }
1983
1986
1987 snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", local_node_pos);
1988 icmap_get_string(tmp_key, &str);
1989
1990 totem_config->node_id = generate_nodeid(totem_config, str);
1991 if (totem_config->node_id == -1) {
1992 *error_string = "An IPV6 network requires that a node ID be specified";
1993
1994 free(str);
1995 return (-1);
1996 }
1997
1999
2000 free(str);
2001 }
2002
2003 /* Users must not change this */
2004 icmap_set_ro_access("nodelist.local_node_pos", 0, 1);
2005 }
2006
2007 if (put_nodelist_members_to_config(totem_config, icmap_get_global_map(), 0, error_string)) {
2008 return -1;
2009 }
2010 }
2011
2012 /*
2013 * Get things that might change in the future (and can depend on totem_config->interfaces);
2014 */
2016
2017 calc_knet_ping_timers(totem_config);
2018
2019 /* This is now done in the totemknet interface callback */
2020 /* configure_totem_links(totem_config, icmap_get_global_map()); */
2021
2022 add_totem_config_notification(totem_config);
2023
2024 return 0;
2025}
2026
2027
2029 struct totem_config *totem_config,
2030 const char **error_string)
2031{
2032 static char local_error_reason[512];
2033 char parse_error[512];
2034 const char *error_reason = local_error_reason;
2035 int i;
2036 uint32_t u32;
2037 int num_configured = 0;
2038 unsigned int interface_max = INTERFACE_MAX;
2039
2040 for (i = 0; i < INTERFACE_MAX; i++) {
2042 num_configured++;
2043 }
2044 }
2045 if (num_configured == 0) {
2046 error_reason = "No interfaces defined";
2047 goto parse_error;
2048 }
2049
2050 /* Check we found a local node name */
2051 if (icmap_get_uint32("nodelist.local_node_pos", &u32) != CS_OK) {
2052 error_reason = "No valid name found for local host";
2053 goto parse_error;
2054 }
2055
2056 for (i = 0; i < INTERFACE_MAX; i++) {
2057 /*
2058 * Some error checking of parsed data to make sure its valid
2059 */
2060
2061 struct totem_ip_address null_addr;
2062
2064 continue;
2065 }
2066
2067 memset (&null_addr, 0, sizeof (struct totem_ip_address));
2068
2070 memcmp (&totem_config->interfaces[i].mcast_addr, &null_addr,
2071 sizeof (struct totem_ip_address)) == 0) {
2072 snprintf (local_error_reason, sizeof(local_error_reason),
2073 "No multicast address specified for interface %u", i);
2074 goto parse_error;
2075 }
2076
2077 if (totem_config->interfaces[i].ip_port == 0) {
2078 snprintf (local_error_reason, sizeof(local_error_reason),
2079 "No multicast port specified for interface %u", i);
2080 goto parse_error;
2081 }
2082
2083 if (totem_config->interfaces[i].ttl > 255) {
2084 snprintf (local_error_reason, sizeof(local_error_reason),
2085 "Invalid TTL (should be 0..255) for interface %u", i);
2086 goto parse_error;
2087 }
2089 totem_config->interfaces[i].ttl != 1) {
2090 snprintf (local_error_reason, sizeof(local_error_reason),
2091 "Can only set ttl on multicast transport types for interface %u", i);
2092 goto parse_error;
2093 }
2095 snprintf (local_error_reason, sizeof(local_error_reason),
2096 "Invalid link priority (should be 0..255) for interface %u", i);
2097 goto parse_error;
2098 }
2101 snprintf (local_error_reason, sizeof(local_error_reason),
2102 "Can only set link priority on knet transport type for interface %u", i);
2103 goto parse_error;
2104 }
2105
2106 if (totem_config->interfaces[i].mcast_addr.family == AF_INET6 &&
2107 totem_config->node_id == 0) {
2108 snprintf (local_error_reason, sizeof(local_error_reason),
2109 "An IPV6 network requires that a node ID be specified for interface %u", i);
2110 goto parse_error;
2111 }
2112
2115 snprintf (local_error_reason, sizeof(local_error_reason),
2116 "Multicast address family does not match bind address family for interface %u", i);
2117 goto parse_error;
2118 }
2119
2121 snprintf (local_error_reason, sizeof(local_error_reason),
2122 "mcastaddr is not a correct multicast address for interface %u", i);
2123 goto parse_error;
2124 }
2125 }
2126 }
2127
2128 if (totem_config->version != 2) {
2129 error_reason = "This totem parser can only parse version 2 configurations.";
2130 goto parse_error;
2131 }
2132
2134 return (-1);
2135 }
2136
2137 if (check_for_duplicate_nodeids(totem_config, error_string) == -1) {
2138 return (-1);
2139 }
2140
2141 /*
2142 * KNET Link values validation
2143 */
2144 if (strcmp (totem_config->link_mode, "active") &&
2145 strcmp (totem_config->link_mode, "rr") &&
2146 strcmp (totem_config->link_mode, "passive")) {
2147 snprintf (local_error_reason, sizeof(local_error_reason),
2148 "The Knet link mode \"%s\" specified is invalid. It must be active, passive or rr.\n", totem_config->link_mode);
2149 goto parse_error;
2150 }
2151
2152 /* Only Knet does multiple interfaces */
2154 interface_max = 1;
2155 }
2156
2157 if (interface_max < num_configured) {
2158 snprintf (parse_error, sizeof(parse_error),
2159 "%d is too many configured interfaces for non-Knet transport.",
2160 num_configured);
2161 error_reason = parse_error;
2162 goto parse_error;
2163 }
2164
2165 /* Only knet allows crypto */
2167 if ((strcmp(totem_config->crypto_cipher_type, "none") != 0) ||
2168 (strcmp(totem_config->crypto_hash_type, "none") != 0)) {
2169
2170 snprintf (parse_error, sizeof(parse_error),
2171 "crypto_cipher & crypto_hash are only valid for the Knet transport.");
2172 error_reason = parse_error;
2173 goto parse_error;
2174 }
2175 }
2176
2177 if (totem_config->net_mtu == 0) {
2179 totem_config->net_mtu = KNET_MAX_PACKET_SIZE;
2180 }
2181 else {
2183 }
2184 }
2185
2186 return 0;
2187
2188parse_error:
2189 snprintf (error_string_response, sizeof(error_string_response),
2190 "parse error in config: %s\n", error_reason);
2191 *error_string = error_string_response;
2192 return (-1);
2193
2194}
2195
2196static int read_keyfile (
2197 const char *key_location,
2198 struct totem_config *totem_config,
2199 const char **error_string)
2200{
2201 int fd;
2202 int res;
2203 int saved_errno;
2204 char error_str[100];
2205 const char *error_ptr;
2206
2207 fd = open (key_location, O_RDONLY);
2208 if (fd == -1) {
2209 error_ptr = qb_strerror_r(errno, error_str, sizeof(error_str));
2210 snprintf (error_string_response, sizeof(error_string_response),
2211 "Could not open %s: %s\n",
2212 key_location, error_ptr);
2213 goto parse_error;
2214 }
2215
2217 saved_errno = errno;
2218 close (fd);
2219
2220 if (res == -1) {
2221 error_ptr = qb_strerror_r (saved_errno, error_str, sizeof(error_str));
2222 snprintf (error_string_response, sizeof(error_string_response),
2223 "Could not read %s: %s\n",
2224 key_location, error_ptr);
2225 goto parse_error;
2226 }
2227
2228 if (res < TOTEM_PRIVATE_KEY_LEN_MIN) {
2229 snprintf (error_string_response, sizeof(error_string_response),
2230 "Could only read %d bits of minimum %u bits from %s.\n",
2231 res * 8, TOTEM_PRIVATE_KEY_LEN_MIN * 8, key_location);
2232 goto parse_error;
2233 }
2234
2236
2237 return 0;
2238
2239parse_error:
2240 *error_string = error_string_response;
2241 return (-1);
2242}
2243
2245 struct totem_config *totem_config,
2246 icmap_map_t map,
2247 const char **error_string)
2248{
2249 int got_key = 0;
2250 char *key_location = NULL;
2251 int res;
2252 size_t key_len;
2253 char old_key[TOTEM_PRIVATE_KEY_LEN_MAX];
2254 size_t old_key_len;
2255
2256 /* Take a copy so we can see if it has changed */
2257 memcpy(old_key, totem_config->private_key, sizeof(totem_config->private_key));
2258 old_key_len = totem_config->private_key_len;
2259
2260 memset (totem_config->private_key, 0, sizeof(totem_config->private_key));
2262
2263 if (strcmp(totem_config->crypto_cipher_type, "none") == 0 &&
2264 strcmp(totem_config->crypto_hash_type, "none") == 0) {
2265 return (0);
2266 }
2267
2268 /* cmap may store the location of the key file */
2269 if (icmap_get_string_r(map, "totem.keyfile", &key_location) == CS_OK) {
2270 res = read_keyfile(key_location, totem_config, error_string);
2271 free(key_location);
2272 if (res) {
2273 goto key_error;
2274 }
2275 got_key = 1;
2276 } else { /* Or the key itself may be in the cmap */
2277 if (icmap_get_r(map, "totem.key", NULL, &key_len, NULL) == CS_OK) {
2278 if (key_len > sizeof(totem_config->private_key)) {
2279 sprintf(error_string_response, "key is too long");
2280 goto key_error;
2281 }
2282 if (key_len < TOTEM_PRIVATE_KEY_LEN_MIN) {
2283 sprintf(error_string_response, "key is too short");
2284 goto key_error;
2285 }
2286 if (icmap_get_r(map, "totem.key", totem_config->private_key, &key_len, NULL) == CS_OK) {
2287 totem_config->private_key_len = key_len;
2288 got_key = 1;
2289 } else {
2290 sprintf(error_string_response, "can't load private key");
2291 goto key_error;
2292 }
2293 }
2294 }
2295
2296 /* In desperation we read the default filename */
2297 if (!got_key) {
2298 res = read_keyfile(COROSYSCONFDIR "/authkey", totem_config, error_string);
2299 if (res)
2300 goto key_error;
2301 }
2302
2303 if (old_key_len != totem_config->private_key_len ||
2304 memcmp(old_key, totem_config->private_key, sizeof(totem_config->private_key))) {
2306 }
2307
2308 return (0);
2309
2310key_error:
2311 *error_string = error_string_response;
2312 return (-1);
2313
2314}
2315
2316int totem_reread_crypto_config(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
2317{
2318 if (totem_get_crypto(totem_config, map, error_string) != 0) {
2319 return -1;
2320 }
2321 if (totem_config_keyread(totem_config, map, error_string) != 0) {
2322 return -1;
2323 }
2324 return 0;
2325}
2326
2327static void debug_dump_totem_config(const struct totem_config *totem_config)
2328{
2329
2330 log_printf(LOGSYS_LEVEL_DEBUG, "Token Timeout (%d ms) retransmit timeout (%d ms)",
2333 uint32_t token_warning_ms = totem_config->token_warning * totem_config->token_timeout / 100;
2334 log_printf(LOGSYS_LEVEL_DEBUG, "Token warning every %d ms (%d%% of Token Timeout)",
2335 token_warning_ms, totem_config->token_warning);
2336 if (token_warning_ms < totem_config->token_retransmit_timeout)
2338 "The token warning interval (%d ms) is less than the token retransmit timeout (%d ms) "
2339 "which can lead to spurious token warnings. Consider increasing the token_warning parameter.",
2340 token_warning_ms, totem_config->token_retransmit_timeout);
2341
2342 } else
2343 log_printf(LOGSYS_LEVEL_DEBUG, "Token warnings disabled");
2344 log_printf(LOGSYS_LEVEL_DEBUG, "token hold (%d ms) retransmits before loss (%d retrans)",
2346 log_printf(LOGSYS_LEVEL_DEBUG, "join (%d ms) send_join (%d ms) consensus (%d ms) merge (%d ms)",
2349 log_printf(LOGSYS_LEVEL_DEBUG, "downcheck (%d ms) fail to recv const (%d msgs)",
2352 "seqno unchanged const (%d rotations) Maximum network MTU %d",
2355 "window size per rotation (%d messages) maximum messages per rotation (%d messages)",
2357 log_printf(LOGSYS_LEVEL_DEBUG, "missed count const (%d messages)", totem_config->miss_count_const);
2358 log_printf(LOGSYS_LEVEL_DEBUG, "heartbeat_failures_allowed (%d)",
2360 log_printf(LOGSYS_LEVEL_DEBUG, "max_network_delay (%d ms)", totem_config->max_network_delay);
2361}
2362
2363
2364static void totem_change_notify(
2365 int32_t event,
2366 const char *key_name,
2367 struct icmap_notify_value new_val,
2368 struct icmap_notify_value old_val,
2369 void *user_data)
2370{
2371 struct totem_config *totem_config = (struct totem_config *)user_data;
2372 uint32_t *param;
2373 uint8_t reloading;
2374 const char *deleted_key = NULL;
2375 const char *error_string;
2376
2377 /*
2378 * If a full reload is in progress then don't do anything until it's done and
2379 * can reconfigure it all atomically
2380 */
2381 if (icmap_get_uint8("config.reload_in_progress", &reloading) == CS_OK && reloading)
2382 return;
2383
2384 param = totem_get_param_by_name((struct totem_config *)user_data, key_name);
2385 /*
2386 * Process change only if changed key is found in totem_config (-> param is not NULL)
2387 * or for special key token_coefficient. token_coefficient key is not stored in
2388 * totem_config, but it is used for computation of token timeout.
2389 */
2390 if (!param && strcmp(key_name, "totem.token_coefficient") != 0)
2391 return;
2392
2393 /*
2394 * Values other than UINT32 are not supported, or needed (yet)
2395 */
2396 switch (event) {
2397 case ICMAP_TRACK_DELETE:
2398 deleted_key = key_name;
2399 break;
2400 case ICMAP_TRACK_ADD:
2401 case ICMAP_TRACK_MODIFY:
2402 deleted_key = NULL;
2403 break;
2404 default:
2405 break;
2406 }
2407
2409 log_printf(LOGSYS_LEVEL_DEBUG, "Totem related config key changed. Dumping actual totem config.");
2410 debug_dump_totem_config(totem_config);
2412 log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
2413 /*
2414 * TODO: Consider corosync exit and/or load defaults for volatile
2415 * values. For now, log error seems to be enough
2416 */
2417 }
2418}
2419
2420
2422 struct totem_config *totem_config,
2423 icmap_map_t map,
2424 const char **error_string)
2425{
2426 uint64_t warnings = 0LL;
2427
2428 get_interface_params(totem_config, map, error_string, &warnings, 1);
2429 if (put_nodelist_members_to_config (totem_config, map, 1, error_string)) {
2430 return -1;
2431 }
2432
2433 calc_knet_ping_timers(totem_config);
2434
2435 log_printf(LOGSYS_LEVEL_DEBUG, "Configuration reloaded. Dumping actual totem config.");
2436 debug_dump_totem_config(totem_config);
2437
2438 /* Reinstate the local_node_pos */
2439 (void)find_local_node(map, 0);
2440
2441 return 0;
2442}
2443
2445 struct totem_config *totem_config,
2446 icmap_map_t map)
2447{
2448 int res;
2449 struct totem_interface *new_interfaces = NULL;
2450
2451 new_interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
2452 assert(new_interfaces != NULL);
2453 memcpy(new_interfaces, totem_config->interfaces, sizeof (struct totem_interface) * INTERFACE_MAX);
2454
2455 /* Set link parameters including local_ip */
2456 configure_totem_links(totem_config, map);
2457
2458 /* Add & remove nodes & link properties */
2459 res = compute_and_set_totempg_interfaces(totem_config->orig_interfaces, new_interfaces);
2460
2461 /* Does basic global params (like compression) */
2463
2464 free(new_interfaces);
2465
2466 /*
2467 * On a reload this return is ignored because it's too late to do anything about it,
2468 * but errors are reported back via cmap.
2469 */
2470 return res;
2471
2472}
2473
2474static void add_totem_config_notification(struct totem_config *totem_config)
2475{
2477
2478 icmap_track_add("totem.",
2480 totem_change_notify,
2482 &icmap_track);
2483}
#define COROSYSCONFDIR
Definition config.h:8
#define INTERFACE_MAX
Definition coroapi.h:88
unsigned int nodeid
Definition coroapi.h:0
unsigned char addr[TOTEMIP_ADDRLEN]
Definition coroapi.h:2
#define PROCESSOR_COUNT_MAX
Definition coroapi.h:96
#define CS_PRI_NODE_ID
Definition corotypes.h:59
@ CS_OK
Definition corotypes.h:99
uint8_t param
uint32_t value
icmap_iter_t icmap_iter_init_r(const icmap_map_t map, const char *prefix)
icmap_iter_init_r
Definition icmap.c:1088
cs_error_t icmap_get_uint8(const char *key_name, uint8_t *u8)
Definition icmap.c:872
#define ICMAP_TRACK_MODIFY
Definition icmap.h:78
cs_error_t icmap_get_string_r(const icmap_map_t map, const char *key_name, char **str)
Definition icmap.c:739
cs_error_t icmap_get_uint16(const char *key_name, uint16_t *u16)
Definition icmap.c:884
cs_error_t icmap_get_uint32(const char *key_name, uint32_t *u32)
Definition icmap.c:896
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:1229
cs_error_t icmap_set_uint32_r(const icmap_map_t map, const char *key_name, uint32_t value)
Definition icmap.c:531
struct icmap_map * icmap_map_t
icmap type.
Definition icmap.h:118
cs_error_t icmap_get_uint8_r(const icmap_map_t map, const char *key_name, uint8_t *u8)
Definition icmap.c:806
#define ICMAP_TRACK_DELETE
Definition icmap.h:77
cs_error_t icmap_set_uint16(const char *key_name, uint16_t value)
Definition icmap.c:589
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:1163
cs_error_t icmap_set_string(const char *key_name, const char *value)
Definition icmap.c:631
#define ICMAP_TRACK_PREFIX
Whole prefix is tracked, instead of key only (so "totem." tracking means that "totem....
Definition icmap.h:85
icmap_iter_t icmap_iter_init(const char *prefix)
Initialize iterator with given prefix.
Definition icmap.c:1093
cs_error_t icmap_get_uint16_r(const icmap_map_t map, const char *key_name, uint16_t *u16)
Definition icmap.c:818
cs_error_t icmap_set_int32_r(const icmap_map_t map, const char *key_name, int32_t value)
Definition icmap.c:525
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:1099
icmap_map_t icmap_get_global_map(void)
Return global icmap.
Definition icmap.c:268
qb_map_iter_t * icmap_iter_t
Itterator type.
Definition icmap.h:123
cs_error_t icmap_set_string_r(const icmap_map_t map, const char *key_name, const char *value)
Definition icmap.c:561
void icmap_iter_finalize(icmap_iter_t iter)
Finalize iterator.
Definition icmap.c:1120
cs_error_t icmap_get_int32_r(const icmap_map_t map, const char *key_name, int32_t *i32)
Definition icmap.c:824
cs_error_t icmap_get_r(const icmap_map_t map, const char *key_name, void *value, size_t *value_len, icmap_value_types_t *type)
Same as icmap_get but it's reentrant and operates on given icmap_map.
Definition icmap.c:696
struct icmap_track * icmap_track_t
Track type.
Definition icmap.h:128
#define ICMAP_KEYNAME_MAXLEN
Maximum length of key in icmap.
Definition icmap.h:48
cs_error_t icmap_get_uint32_r(const icmap_map_t map, const char *key_name, uint32_t *u32)
Definition icmap.c:830
cs_error_t icmap_set_uint32(const char *key_name, uint32_t value)
Definition icmap.c:601
#define ICMAP_TRACK_ADD
Definition icmap.h:76
cs_error_t icmap_get_string(const char *key_name, char **str)
Shortcut for icmap_get for string type.
Definition icmap.c:860
#define LOGSYS_LEVEL_ERROR
Definition logsys.h:72
#define log_printf(level, format, args...)
Definition logsys.h:332
#define LOGSYS_LEVEL_INFO
Definition logsys.h:75
#define LOGSYS_LEVEL_WARNING
Definition logsys.h:73
#define LOGSYS_LEVEL_DEBUG
Definition logsys.h:76
void * user_data
Definition sam.c:127
Structure passed as new_value and old_value in change callback.
Definition icmap.h:91
char crypto_model[CONFIG_STRING_LEN_MAX]
Definition totem.h:224
unsigned int max_messages
Definition totem.h:220
unsigned int heartbeat_failures_allowed
Definition totem.h:214
unsigned int token_timeout
Definition totem.h:182
unsigned int private_key_len
Definition totem.h:177
unsigned int knet_mtu
Definition totem.h:170
unsigned int node_id
Definition totem.h:167
unsigned int broadcast_use
Definition totem.h:222
uint32_t knet_compression_threshold
Definition totem.h:236
unsigned int window_size
Definition totem.h:218
unsigned int downcheck_timeout
Definition totem.h:200
unsigned int miss_count_const
Definition totem.h:242
totem_transport_t transport_number
Definition totem.h:240
struct totem_interface * interfaces
Definition totem.h:165
int crypto_changed
Definition totem.h:232
unsigned int cancel_token_hold_on_retransmit
Definition totem.h:248
unsigned int fail_to_recv_const
Definition totem.h:202
unsigned int clear_node_high_bit
Definition totem.h:168
unsigned int merge_timeout
Definition totem.h:198
struct totem_interface * orig_interfaces
Definition totem.h:166
unsigned char ip_dscp
Definition totem.h:250
int knet_compression_level
Definition totem.h:238
unsigned int net_mtu
Definition totem.h:210
int version
Definition totem.h:160
char knet_compression_model[CONFIG_STRING_LEN_MAX]
Definition totem.h:234
unsigned int block_unlisted_ips
Definition totem.h:246
unsigned int token_retransmits_before_loss_const
Definition totem.h:190
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN_MAX]
Definition totem.h:175
int crypto_index
Definition totem.h:230
unsigned int max_network_delay
Definition totem.h:216
unsigned int seqno_unchanged_const
Definition totem.h:204
unsigned int consensus_timeout
Definition totem.h:196
unsigned int knet_pmtud_interval
Definition totem.h:169
char crypto_cipher_type[CONFIG_STRING_LEN_MAX]
Definition totem.h:226
unsigned int threads
Definition totem.h:212
unsigned int send_join_timeout
Definition totem.h:194
char link_mode[TOTEM_LINK_MODE_BYTES]
Definition totem.h:206
enum totem_ip_version_enum ip_version
Definition totem.h:244
unsigned int token_retransmit_timeout
Definition totem.h:186
char crypto_hash_type[CONFIG_STRING_LEN_MAX]
Definition totem.h:228
unsigned int token_warning
Definition totem.h:184
unsigned int join_timeout
Definition totem.h:192
unsigned int token_hold_timeout
Definition totem.h:188
struct totem_ip_address local_ip
Definition totem.h:86
int knet_ping_timeout
Definition totem.h:93
int knet_link_priority
Definition totem.h:91
uint16_t ip_port
Definition totem.h:87
int knet_ping_interval
Definition totem.h:92
uint8_t configured
Definition totem.h:89
int knet_ping_precision
Definition totem.h:94
int knet_pong_count
Definition totem.h:95
int knet_transport
Definition totem.h:96
int member_count
Definition totem.h:90
struct totem_ip_address bindnet
Definition totem.h:83
struct totem_ip_address member_list[PROCESSOR_COUNT_MAX]
Definition totem.h:97
uint16_t ttl
Definition totem.h:88
struct totem_ip_address mcast_addr
Definition totem.h:85
The totem_ip_address struct.
Definition coroapi.h:111
unsigned int nodeid
Definition coroapi.h:112
unsigned short family
Definition coroapi.h:113
#define swab32(x)
The swab32 macro.
Definition swab.h:51
@ TOTEM_PRIVATE_KEY_LEN_MAX
Definition totem.h:137
@ TOTEM_PRIVATE_KEY_LEN_MIN
Definition totem.h:136
#define CONFIG_STRING_LEN_MAX
Definition totem.h:54
@ TOTEM_LINK_MODE_BYTES
Definition totem.h:140
@ TOTEM_TRANSPORT_UDPU
Definition totem.h:144
@ TOTEM_TRANSPORT_KNET
Definition totem.h:145
@ TOTEM_TRANSPORT_UDP
Definition totem.h:143
#define MINIMUM_TIMEOUT
Definition totemconfig.c:77
#define TOKEN_RETRANSMITS_BEFORE_LOSS_CONST
Definition totemconfig.c:68
#define JOIN_TIMEOUT
Definition totemconfig.c:72
#define DEFAULT_PORT
Definition totemconfig.c:97
#define MAX_MESSAGES
Definition totemconfig.c:81
#define MAX_NETWORK_DELAY
Definition totemconfig.c:79
#define KNET_PONG_COUNT
Definition totemconfig.c:92
#define KNET_PMTUD_INTERVAL
Definition totemconfig.c:93
#define MINIMUM_TIMEOUT_HOLD
Definition totemconfig.c:78
#define TOKEN_COEFFICIENT
Definition totemconfig.c:71
#define SEQNO_UNCHANGED_CONST
Definition totemconfig.c:76
void totem_volatile_config_read(struct totem_config *totem_config, icmap_map_t temp_map, const char *deleted_key)
int totem_config_read(struct totem_config *totem_config, const char **error_string, uint64_t *warnings)
#define MISS_COUNT_CONST
Definition totemconfig.c:82
int totemconfig_commit_new_params(struct totem_config *totem_config, icmap_map_t map)
int totem_volatile_config_validate(struct totem_config *totem_config, icmap_map_t temp_map, const char **error_string)
#define TOKEN_WARNING
Definition totemconfig.c:70
#define KNET_MTU
Definition totemconfig.c:94
int totem_reread_crypto_config(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
#define MERGE_TIMEOUT
Definition totemconfig.c:73
#define KNET_PING_PRECISION
Definition totemconfig.c:91
int totem_config_validate(struct totem_config *totem_config, const char **error_string)
#define BLOCK_UNLISTED_IPS
Definition totemconfig.c:83
#define KNET_DEFAULT_TRANSPORT
Definition totemconfig.c:95
#define UDP_NETMTU
Definition totemconfig.c:86
#define CANCEL_TOKEN_HOLD_ON_RETRANSMIT
Definition totemconfig.c:84
#define FAIL_TO_RECV_CONST
Definition totemconfig.c:75
#define WINDOW_SIZE
Definition totemconfig.c:80
#define DOWNCHECK_TIMEOUT
Definition totemconfig.c:74
#define TOKEN_TIMEOUT
Definition totemconfig.c:69
int totemconfig_configure_new_params(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
int totem_config_keyread(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
#define TOTEM_CONFIG_BINDNETADDR_NODELIST_SET
Definition totemconfig.h:48
#define TOTEM_CONFIG_WARNING_TOTEM_NODEID_SET
Definition totemconfig.h:47
#define TOTEM_CONFIG_WARNING_MEMBERS_IGNORED
Definition totemconfig.h:45
#define TOTEM_CONFIG_WARNING_MEMBERS_DEPRECATED
Definition totemconfig.h:46
int totemip_parse(struct totem_ip_address *totemip, const char *addr, enum totem_ip_version_enum ip_version)
Definition totemip.c:306
const char * totemip_print(const struct totem_ip_address *addr)
Definition totemip.c:256
totem_ip_version_enum
Definition totemip.h:70
@ TOTEM_IP_VERSION_6_4
Definition totemip.h:74
@ TOTEM_IP_VERSION_4
Definition totemip.h:71
@ TOTEM_IP_VERSION_6
Definition totemip.h:72
@ TOTEM_IP_VERSION_4_6
Definition totemip.h:73
int totemip_is_mcast(struct totem_ip_address *addr)
Definition totemip.c:134
int totempg_iface_set(struct totem_ip_address *interface_addr, unsigned short ip_port, unsigned int iface_no)
Definition totempg.c:1437
int totempg_reconfigure(void)
Definition totempg.c:1569
int totempg_member_remove(const struct totem_ip_address *member, int ring_no)
Definition totempg.c:1562
int totempg_member_add(const struct totem_ip_address *member, int ring_no)
Definition totempg.c:1555