corosync  3.1.0
exec/cfg.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005-2006 MontaVista Software, Inc.
3  * Copyright (c) 2006-2018 Red Hat, Inc.
4  *
5  * All rights reserved.
6  *
7  * Author: Steven Dake (sdake@redhat.com)
8  *
9  * This software licensed under BSD license, the text of which follows:
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
14  * - Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  * - Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  * - Neither the name of the MontaVista Software, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33  * THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #include <config.h>
37 
38 #include <sys/types.h>
39 #include <sys/uio.h>
40 #include <sys/socket.h>
41 #include <sys/un.h>
42 #include <netinet/in.h>
43 #include <arpa/inet.h>
44 #include <unistd.h>
45 #include <fcntl.h>
46 #include <stdlib.h>
47 #include <stdio.h>
48 #include <stddef.h>
49 #include <limits.h>
50 #include <errno.h>
51 #include <string.h>
52 #include <assert.h>
53 
54 #include <corosync/corotypes.h>
55 #include <qb/qbipc_common.h>
56 #include <corosync/cfg.h>
57 #include <qb/qblist.h>
58 #include <corosync/mar_gen.h>
59 #include <corosync/totem/totemip.h>
60 #include <corosync/totem/totem.h>
61 #include <corosync/ipc_cfg.h>
62 #include <corosync/logsys.h>
63 #include <corosync/coroapi.h>
64 #include <corosync/icmap.h>
65 #include <corosync/corodefs.h>
66 
67 #include "totemconfig.h"
68 #include "service.h"
69 #include "main.h"
70 
72 
79 };
80 
81 #define DEFAULT_SHUTDOWN_TIMEOUT 5
82 
83 static struct qb_list_head trackers_list;
84 
85 /*
86  * Variables controlling a requested shutdown
87  */
88 static corosync_timer_handle_t shutdown_timer;
89 static struct cfg_info *shutdown_con;
90 static uint32_t shutdown_flags;
91 static int shutdown_yes;
92 static int shutdown_no;
93 static int shutdown_expected;
94 
95 struct cfg_info
96 {
97  struct qb_list_head list;
98  void *conn;
99  void *tracker_conn;
101 };
102 
103 static void cfg_confchg_fn (
104  enum totem_configuration_type configuration_type,
105  const unsigned int *member_list, size_t member_list_entries,
106  const unsigned int *left_list, size_t left_list_entries,
107  const unsigned int *joined_list, size_t joined_list_entries,
108  const struct memb_ring_id *ring_id);
109 
110 static char *cfg_exec_init_fn (struct corosync_api_v1 *corosync_api_v1);
111 
112 static struct corosync_api_v1 *api;
113 
114 static int cfg_lib_init_fn (void *conn);
115 
116 static int cfg_lib_exit_fn (void *conn);
117 
118 static void message_handler_req_exec_cfg_ringreenable (
119  const void *message,
120  unsigned int nodeid);
121 
122 static void message_handler_req_exec_cfg_killnode (
123  const void *message,
124  unsigned int nodeid);
125 
126 static void message_handler_req_exec_cfg_shutdown (
127  const void *message,
128  unsigned int nodeid);
129 
130 static void message_handler_req_exec_cfg_reload_config (
131  const void *message,
132  unsigned int nodeid);
133 
134 static void message_handler_req_exec_cfg_reconfig_crypto (
135  const void *message,
136  unsigned int nodeid);
137 
138 static void exec_cfg_killnode_endian_convert (void *msg);
139 
140 static void message_handler_req_lib_cfg_ringstatusget (
141  void *conn,
142  const void *msg);
143 
144 static void message_handler_req_lib_cfg_ringreenable (
145  void *conn,
146  const void *msg);
147 
148 static void message_handler_req_lib_cfg_killnode (
149  void *conn,
150  const void *msg);
151 
152 static void message_handler_req_lib_cfg_tryshutdown (
153  void *conn,
154  const void *msg);
155 
156 static void message_handler_req_lib_cfg_replytoshutdown (
157  void *conn,
158  const void *msg);
159 
160 static void message_handler_req_lib_cfg_get_node_addrs (
161  void *conn,
162  const void *msg);
163 
164 static void message_handler_req_lib_cfg_local_get (
165  void *conn,
166  const void *msg);
167 
168 static void message_handler_req_lib_cfg_reload_config (
169  void *conn,
170  const void *msg);
171 
172 static void message_handler_req_lib_cfg_reopen_log_files (
173  void *conn,
174  const void *msg);
175 
176 /*
177  * Service Handler Definition
178  */
179 static struct corosync_lib_handler cfg_lib_engine[] =
180 {
181  { /* 0 */
182  .lib_handler_fn = message_handler_req_lib_cfg_ringstatusget,
183  .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
184  },
185  { /* 1 */
186  .lib_handler_fn = message_handler_req_lib_cfg_ringreenable,
187  .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
188  },
189  { /* 2 */
190  .lib_handler_fn = message_handler_req_lib_cfg_killnode,
191  .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
192  },
193  { /* 3 */
194  .lib_handler_fn = message_handler_req_lib_cfg_tryshutdown,
195  .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
196  },
197  { /* 4 */
198  .lib_handler_fn = message_handler_req_lib_cfg_replytoshutdown,
199  .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
200  },
201  { /* 5 */
202  .lib_handler_fn = message_handler_req_lib_cfg_get_node_addrs,
203  .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED
204  },
205  { /* 6 */
206  .lib_handler_fn = message_handler_req_lib_cfg_local_get,
207  .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED
208  },
209  { /* 7 */
210  .lib_handler_fn = message_handler_req_lib_cfg_reload_config,
211  .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
212  },
213  { /* 8 */
214  .lib_handler_fn = message_handler_req_lib_cfg_reopen_log_files,
215  .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED
216  }
217 };
218 
219 static struct corosync_exec_handler cfg_exec_engine[] =
220 {
221  { /* 0 */
222  .exec_handler_fn = message_handler_req_exec_cfg_ringreenable,
223  },
224  { /* 1 */
225  .exec_handler_fn = message_handler_req_exec_cfg_killnode,
226  .exec_endian_convert_fn = exec_cfg_killnode_endian_convert
227  },
228  { /* 2 */
229  .exec_handler_fn = message_handler_req_exec_cfg_shutdown,
230  },
231  { /* 3 */
232  .exec_handler_fn = message_handler_req_exec_cfg_reload_config,
233  },
234  { /* 4 */
235  .exec_handler_fn = message_handler_req_exec_cfg_reconfig_crypto,
236  }
237 };
238 
239 /*
240  * Exports the interface for the service
241  */
243  .name = "corosync configuration service",
244  .id = CFG_SERVICE,
245  .priority = 1,
246  .private_data_size = sizeof(struct cfg_info),
247  .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED,
248  .allow_inquorate = CS_LIB_ALLOW_INQUORATE,
249  .lib_init_fn = cfg_lib_init_fn,
250  .lib_exit_fn = cfg_lib_exit_fn,
251  .lib_engine = cfg_lib_engine,
252  .lib_engine_count = sizeof (cfg_lib_engine) / sizeof (struct corosync_lib_handler),
253  .exec_init_fn = cfg_exec_init_fn,
254  .exec_engine = cfg_exec_engine,
255  .exec_engine_count = sizeof (cfg_exec_engine) / sizeof (struct corosync_exec_handler),
256  .confchg_fn = cfg_confchg_fn
257 };
258 
260 {
261  return (&cfg_service_engine);
262 }
263 
265  struct qb_ipc_request_header header __attribute__((aligned(8)));
266  mar_message_source_t source __attribute__((aligned(8)));
267 };
268 
270  struct qb_ipc_request_header header __attribute__((aligned(8)));
271  mar_message_source_t source __attribute__((aligned(8)));
272 };
273 
275  struct qb_ipc_request_header header __attribute__((aligned(8)));
276  mar_uint32_t phase __attribute__((aligned(8)));
277 };
278 
280  struct qb_ipc_request_header header __attribute__((aligned(8)));
282  mar_name_t reason __attribute__((aligned(8)));
283 };
284 
286  struct qb_ipc_request_header header __attribute__((aligned(8)));
287 };
288 
289 /* IMPL */
290 
291 static char *cfg_exec_init_fn (
293 {
294  api = corosync_api_v1;
295 
296  qb_list_init(&trackers_list);
297  return (NULL);
298 }
299 
300 static void cfg_confchg_fn (
301  enum totem_configuration_type configuration_type,
302  const unsigned int *member_list, size_t member_list_entries,
303  const unsigned int *left_list, size_t left_list_entries,
304  const unsigned int *joined_list, size_t joined_list_entries,
305  const struct memb_ring_id *ring_id)
306 {
307 }
308 
309 /*
310  * Tell other nodes we are shutting down
311  */
312 static int send_shutdown(void)
313 {
315  struct iovec iovec;
316 
317  ENTER();
318  req_exec_cfg_shutdown.header.size =
319  sizeof (struct req_exec_cfg_shutdown);
322 
323  iovec.iov_base = (char *)&req_exec_cfg_shutdown;
324  iovec.iov_len = sizeof (struct req_exec_cfg_shutdown);
325 
326  assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
327 
328  LEAVE();
329  return 0;
330 }
331 
332 static void send_test_shutdown(void *only_conn, void *exclude_conn, int status)
333 {
335  struct qb_list_head *iter;
336 
337  ENTER();
338  res_lib_cfg_testshutdown.header.size = sizeof(struct res_lib_cfg_testshutdown);
340  res_lib_cfg_testshutdown.header.error = status;
341  res_lib_cfg_testshutdown.flags = shutdown_flags;
342 
343  if (only_conn) {
344  TRACE1("sending testshutdown to only %p", only_conn);
346  sizeof(res_lib_cfg_testshutdown));
347  } else {
348  qb_list_for_each(iter, &trackers_list) {
349  struct cfg_info *ci = qb_list_entry(iter, struct cfg_info, list);
350 
351  if (ci->conn != exclude_conn) {
352  TRACE1("sending testshutdown to %p", ci->tracker_conn);
354  sizeof(res_lib_cfg_testshutdown));
355  }
356  }
357  }
358  LEAVE();
359 }
360 
361 static void check_shutdown_status(void)
362 {
363  ENTER();
364 
365  /*
366  * Shutdown client might have gone away
367  */
368  if (!shutdown_con) {
369  LEAVE();
370  return;
371  }
372 
373  /*
374  * All replies safely gathered in ?
375  */
376  if (shutdown_yes + shutdown_no >= shutdown_expected) {
378 
379  api->timer_delete(shutdown_timer);
380 
381  if (shutdown_yes >= shutdown_expected ||
382  shutdown_flags == CFG_SHUTDOWN_FLAG_REGARDLESS) {
383  TRACE1("shutdown confirmed");
384 
385  res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
387  res_lib_cfg_tryshutdown.header.error = CS_OK;
388 
389  /*
390  * Tell originator that shutdown was confirmed
391  */
392  api->ipc_response_send(shutdown_con->conn, &res_lib_cfg_tryshutdown,
393  sizeof(res_lib_cfg_tryshutdown));
394  shutdown_con = NULL;
395 
396  /*
397  * Tell other nodes we are going down
398  */
399  send_shutdown();
400 
401  }
402  else {
403 
404  TRACE1("shutdown cancelled");
405  res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
407  res_lib_cfg_tryshutdown.header.error = CS_ERR_BUSY;
408 
409  /*
410  * Tell originator that shutdown was cancelled
411  */
412  api->ipc_response_send(shutdown_con->conn, &res_lib_cfg_tryshutdown,
413  sizeof(res_lib_cfg_tryshutdown));
414  shutdown_con = NULL;
415  }
416 
417  log_printf(LOGSYS_LEVEL_DEBUG, "shutdown decision is: (yes count: %d, no count: %d) flags=%x",
418  shutdown_yes, shutdown_no, shutdown_flags);
419  }
420  LEAVE();
421 }
422 
423 
424 /*
425  * Not all nodes responded to the shutdown (in time)
426  */
427 static void shutdown_timer_fn(void *arg)
428 {
429  ENTER();
430 
431  /*
432  * Mark undecideds as "NO"
433  */
434  shutdown_no = shutdown_expected;
435  check_shutdown_status();
436 
437  send_test_shutdown(NULL, NULL, CS_ERR_TIMEOUT);
438  LEAVE();
439 }
440 
441 static void remove_ci_from_shutdown(struct cfg_info *ci)
442 {
443  ENTER();
444 
445  /*
446  * If the controlling shutdown process has quit, then cancel the
447  * shutdown session
448  */
449  if (ci == shutdown_con) {
450  shutdown_con = NULL;
451  api->timer_delete(shutdown_timer);
452  }
453 
454  if (!qb_list_empty(&ci->list)) {
455  qb_list_del(&ci->list);
456  qb_list_init(&ci->list);
457 
458  /*
459  * Remove our option
460  */
461  if (shutdown_con) {
462  if (ci->shutdown_reply == SHUTDOWN_REPLY_YES)
463  shutdown_yes--;
464  if (ci->shutdown_reply == SHUTDOWN_REPLY_NO)
465  shutdown_no--;
466  }
467 
468  /*
469  * If we are leaving, then that's an implicit YES to shutdown
470  */
471  ci->shutdown_reply = SHUTDOWN_REPLY_YES;
472  shutdown_yes++;
473 
474  check_shutdown_status();
475  }
476  LEAVE();
477 }
478 
479 
480 int cfg_lib_exit_fn (void *conn)
481 {
482  struct cfg_info *ci = (struct cfg_info *)api->ipc_private_data_get (conn);
483 
484  ENTER();
485  remove_ci_from_shutdown(ci);
486  LEAVE();
487  return (0);
488 }
489 
490 static int cfg_lib_init_fn (void *conn)
491 {
492  struct cfg_info *ci = (struct cfg_info *)api->ipc_private_data_get (conn);
493 
494  ENTER();
495  qb_list_init(&ci->list);
496  LEAVE();
497 
498  return (0);
499 }
500 
501 /*
502  * Executive message handlers
503  */
504 static void message_handler_req_exec_cfg_ringreenable (
505  const void *message,
506  unsigned int nodeid)
507 {
508  ENTER();
509 
510  LEAVE();
511 }
512 
513 static void exec_cfg_killnode_endian_convert (void *msg)
514 {
516  (struct req_exec_cfg_killnode *)msg;
517  ENTER();
518 
519  swab_mar_name_t(&req_exec_cfg_killnode->reason);
520  LEAVE();
521 }
522 
523 
524 static void message_handler_req_exec_cfg_killnode (
525  const void *message,
526  unsigned int nodeid)
527 {
528  const struct req_exec_cfg_killnode *req_exec_cfg_killnode = message;
529  cs_name_t reason;
530 
531  ENTER();
532  log_printf(LOGSYS_LEVEL_DEBUG, "request to kill node " CS_PRI_NODE_ID " (us=" CS_PRI_NODE_ID ")",
533  req_exec_cfg_killnode->nodeid, api->totem_nodeid_get());
534  if (req_exec_cfg_killnode->nodeid == api->totem_nodeid_get()) {
535  marshall_from_mar_name_t(&reason, &req_exec_cfg_killnode->reason);
536  log_printf(LOGSYS_LEVEL_NOTICE, "Killed by node " CS_PRI_NODE_ID " : %s",
537  nodeid, reason.value);
539  }
540  LEAVE();
541 }
542 
543 /*
544  * Self shutdown
545  */
546 static void message_handler_req_exec_cfg_shutdown (
547  const void *message,
548  unsigned int nodeid)
549 {
550  ENTER();
551 
552  log_printf(LOGSYS_LEVEL_NOTICE, "Node " CS_PRI_NODE_ID " was shut down by sysadmin", nodeid);
553  if (nodeid == api->totem_nodeid_get()) {
554  api->shutdown_request();
555  }
556  LEAVE();
557 }
558 
559 /* strcmp replacement that can handle NULLs */
560 static int nullcheck_strcmp(const char* left, const char *right)
561 {
562  if (!left && right)
563  return -1;
564  if (left && !right)
565  return 1;
566 
567  if (!left && !right)
568  return 0;
569 
570  return strcmp(left, right);
571 }
572 
573 /*
574  * If a key has changed value in the new file, then warn the user and remove it from the temp_map
575  */
576 static void delete_and_notify_if_changed(icmap_map_t temp_map, const char *key_name)
577 {
578  if (!(icmap_key_value_eq(temp_map, key_name, icmap_get_global_map(), key_name))) {
579  if (icmap_delete_r(temp_map, key_name) == CS_OK) {
580  log_printf(LOGSYS_LEVEL_NOTICE, "Modified entry '%s' in corosync.conf cannot be changed at run-time", key_name);
581  }
582  }
583 }
584 /*
585  * Remove any keys from the new config file that in the new corosync.conf but that
586  * cannot be changed at run time. A log message will be issued for each
587  * entry that the user wants to change but they cannot.
588  *
589  * Add more here as needed.
590  */
591 static void remove_ro_entries(icmap_map_t temp_map)
592 {
593 #ifndef HAVE_KNET_CRYPTO_RECONF
594  delete_and_notify_if_changed(temp_map, "totem.secauth");
595  delete_and_notify_if_changed(temp_map, "totem.crypto_hash");
596  delete_and_notify_if_changed(temp_map, "totem.crypto_cipher");
597  delete_and_notify_if_changed(temp_map, "totem.keyfile");
598  delete_and_notify_if_changed(temp_map, "totem.key");
599 #endif
600  delete_and_notify_if_changed(temp_map, "totem.version");
601  delete_and_notify_if_changed(temp_map, "totem.threads");
602  delete_and_notify_if_changed(temp_map, "totem.ip_version");
603  delete_and_notify_if_changed(temp_map, "totem.rrp_mode");
604  delete_and_notify_if_changed(temp_map, "totem.netmtu");
605  delete_and_notify_if_changed(temp_map, "totem.interface.ringnumber");
606  delete_and_notify_if_changed(temp_map, "totem.interface.bindnetaddr");
607  delete_and_notify_if_changed(temp_map, "totem.interface.mcastaddr");
608  delete_and_notify_if_changed(temp_map, "totem.interface.broadcast");
609  delete_and_notify_if_changed(temp_map, "totem.interface.mcastport");
610  delete_and_notify_if_changed(temp_map, "totem.interface.ttl");
611  delete_and_notify_if_changed(temp_map, "totem.transport");
612  delete_and_notify_if_changed(temp_map, "totem.cluster_name");
613  delete_and_notify_if_changed(temp_map, "quorum.provider");
614  delete_and_notify_if_changed(temp_map, "system.move_to_root_cgroup");
615  delete_and_notify_if_changed(temp_map, "system.sched_rr");
616  delete_and_notify_if_changed(temp_map, "system.priority");
617  delete_and_notify_if_changed(temp_map, "system.qb_ipc_type");
618  delete_and_notify_if_changed(temp_map, "system.state_dir");
619 }
620 
621 /*
622  * Remove entries that exist in the global map, but not in the temp_map, this will
623  * cause delete notifications to be sent to any listeners.
624  *
625  * NOTE: This routine depends entirely on the keys returned by the iterators
626  * being in alpha-sorted order.
627  */
628 static void remove_deleted_entries(icmap_map_t temp_map, const char *prefix)
629 {
630  icmap_iter_t old_iter;
631  icmap_iter_t new_iter;
632  const char *old_key, *new_key;
633  int ret;
634 
635  old_iter = icmap_iter_init(prefix);
636  new_iter = icmap_iter_init_r(temp_map, prefix);
637 
638  old_key = icmap_iter_next(old_iter, NULL, NULL);
639  new_key = icmap_iter_next(new_iter, NULL, NULL);
640 
641  while (old_key || new_key) {
642  ret = nullcheck_strcmp(old_key, new_key);
643  if ((ret < 0 && old_key) || !new_key) {
644  /*
645  * new_key is greater, a line (or more) has been deleted
646  * Continue until old is >= new
647  */
648  do {
649  /* Remove it from icmap & send notifications */
650  icmap_delete(old_key);
651 
652  old_key = icmap_iter_next(old_iter, NULL, NULL);
653  ret = nullcheck_strcmp(old_key, new_key);
654  } while (ret < 0 && old_key);
655  }
656  else if ((ret > 0 && new_key) || !old_key) {
657  /*
658  * old_key is greater, a line (or more) has been added
659  * Continue until new is >= old
660  *
661  * we don't need to do anything special with this like tell
662  * icmap. That will happen when we copy the values over
663  */
664  do {
665  new_key = icmap_iter_next(new_iter, NULL, NULL);
666  ret = nullcheck_strcmp(old_key, new_key);
667  } while (ret > 0 && new_key);
668  }
669  if (ret == 0) {
670  new_key = icmap_iter_next(new_iter, NULL, NULL);
671  old_key = icmap_iter_next(old_iter, NULL, NULL);
672  }
673  }
674  icmap_iter_finalize(new_iter);
675  icmap_iter_finalize(old_iter);
676 }
677 
678 /*
679  * Reload configuration file
680  */
681 static void message_handler_req_exec_cfg_reload_config (
682  const void *message,
683  unsigned int nodeid)
684 {
687  struct totem_config new_config;
688  icmap_map_t temp_map;
689  const char *error_string;
690  int res = CS_OK;
691 
692  ENTER();
693 
694  log_printf(LOGSYS_LEVEL_NOTICE, "Config reload requested by node " CS_PRI_NODE_ID, nodeid);
695 
696  icmap_set_uint8("config.totemconfig_reload_in_progress", 1);
697 
698  /* Make sure there is no rubbish in this that might be checked, even on error */
699  memset(&new_config, 0, sizeof(new_config));
700  /*
701  * Set up a new hashtable as a staging area.
702  */
703  if ((res = icmap_init_r(&temp_map)) != CS_OK) {
704  log_printf(LOGSYS_LEVEL_ERROR, "Unable to create temporary icmap. config file reload cancelled\n");
705  goto reload_fini_nomap;
706  }
707 
708  /*
709  * Load new config into the temporary map
710  */
711  res = coroparse_configparse(temp_map, &error_string);
712  if (res == -1) {
713  log_printf (LOGSYS_LEVEL_ERROR, "Unable to reload config file: %s", error_string);
714  res = CS_ERR_INVALID_PARAM;
715  goto reload_fini_nofree;
716  }
717 
718  /* Signal start of the reload process */
719  icmap_set_uint8("config.reload_in_progress", 1);
720 
721  /* Detect deleted entries and remove them from the main icmap hashtable */
722  remove_deleted_entries(temp_map, "logging.");
723  remove_deleted_entries(temp_map, "totem.");
724  remove_deleted_entries(temp_map, "nodelist.");
725  remove_deleted_entries(temp_map, "quorum.");
726  remove_deleted_entries(temp_map, "uidgid.config.");
727  remove_deleted_entries(temp_map, "nozzle.");
728 
729  /* Remove entries that cannot be changed */
730  remove_ro_entries(temp_map);
731 
732  /* Take a copy of the current setup so we can check what has changed */
733  memset(&new_config, 0, sizeof(new_config));
734  new_config.orig_interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
735  assert(new_config.orig_interfaces != NULL);
736 
737  totempg_get_config(&new_config);
738  new_config.crypto_changed = 0;
739 
740  new_config.interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
741  assert(new_config.interfaces != NULL);
742  memset(new_config.interfaces, 0, sizeof (struct totem_interface) * INTERFACE_MAX);
743 
744  /* For UDP[U] the configuration on link0 is static (apart from the nodelist) and only read at
745  startup. So preserve it here */
746  if ( (new_config.transport_number == TOTEM_TRANSPORT_UDP) ||
747  (new_config.transport_number == TOTEM_TRANSPORT_UDPU)) {
748  memcpy(&new_config.interfaces[0], &new_config.orig_interfaces[0],
749  sizeof(struct totem_interface));
750  }
751 
752  /* Calculate new node and interface definitions */
753  if (totemconfig_configure_new_params(&new_config, temp_map, &error_string) == -1) {
754  log_printf (LOGSYS_LEVEL_ERROR, "Cannot configure new interface definitions: %s\n", error_string);
755  res = CS_ERR_INVALID_PARAM;
756  goto reload_fini;
757  }
758 
759  /* Read from temp_map into new_config */
760  totem_volatile_config_read(&new_config, temp_map, NULL);
761 
762  /* Get updated crypto parameters. Will set a flag in new_config if things have changed */
763  if (totem_reread_crypto_config(&new_config, temp_map, &error_string) == -1) {
764  log_printf (LOGSYS_LEVEL_ERROR, "Crypto configuration is not valid: %s\n", error_string);
765  res = CS_ERR_INVALID_PARAM;
766  goto reload_fini;
767  }
768 
769  /* Validate dynamic parameters */
770  if (totem_volatile_config_validate(&new_config, temp_map, &error_string) == -1) {
771  log_printf (LOGSYS_LEVEL_ERROR, "Configuration is not valid: %s\n", error_string);
772  res = CS_ERR_INVALID_PARAM;
773  goto reload_fini;
774  }
775 
776  /* Save this here so we can get at it for the later phases of crypto change */
777  if (new_config.crypto_changed) {
778 #ifndef HAVE_KNET_CRYPTO_RECONF
779  new_config.crypto_changed = 0;
780  log_printf (LOGSYS_LEVEL_ERROR, "Crypto reconfiguration is not supported by the linked version of knet\n");
781  res = CS_ERR_INVALID_PARAM;
782  goto reload_fini;
783 #endif
784  }
785 
786  /*
787  * Copy new keys into live config.
788  */
789  if ( (res = icmap_copy_map(icmap_get_global_map(), temp_map)) != CS_OK) {
790  log_printf (LOGSYS_LEVEL_ERROR, "Error making new config live. cmap database may be inconsistent\n");
791  /* Return res from icmap */
792  goto reload_fini;
793  }
794 
795  /* Copy into live system */
796  totempg_put_config(&new_config);
797  totemconfig_commit_new_params(&new_config, temp_map);
798  free(new_config.interfaces);
799 
800 reload_fini:
801  /* All done - let clients know */
802  icmap_set_int32("config.reload_status", res);
803  icmap_set_uint8("config.totemconfig_reload_in_progress", 0);
804  icmap_set_uint8("config.reload_in_progress", 0);
805 
806  /* Finished with the temporary storage */
807  free(new_config.orig_interfaces);
808 
809 reload_fini_nofree:
810  icmap_fini_r(temp_map);
811 
812 reload_fini_nomap:
813 
814  /* If crypto was changed, now it's loaded on all nodes we can enable it.
815  * Each node sends its own PHASE message so we're not relying on the leader
816  * node to survive the transition
817  */
818  if (new_config.crypto_changed) {
820  struct iovec iovec;
821 
822  req_exec_cfg_crypto_reconfig.header.size =
823  sizeof (struct req_exec_cfg_crypto_reconfig);
827 
828  iovec.iov_base = (char *)&req_exec_cfg_crypto_reconfig;
829  iovec.iov_len = sizeof (struct req_exec_cfg_crypto_reconfig);
830 
831  assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
832  }
833 
834  /* All done, return result to the caller if it was on this system */
835  if (nodeid == api->totem_nodeid_get()) {
838  res_lib_cfg_reload_config.header.error = res;
841  sizeof(res_lib_cfg_reload_config));
842  api->ipc_refcnt_dec(req_exec_cfg_reload_config->source.conn);;
843  }
844 
845  LEAVE();
846 }
847 
848 /* Handle the phases of crypto reload
849  * The first time we are called is after the new crypto config has been loaded
850  * but not activated.
851  *
852  * 1 - activate the new crypto configuration
853  * 2 - clear out the old configuration
854  */
855 static void message_handler_req_exec_cfg_reconfig_crypto (
856  const void *message,
857  unsigned int nodeid)
858 {
860 
861  /* Got our own reconfig message */
862  if (nodeid == api->totem_nodeid_get()) {
863  log_printf (LOGSYS_LEVEL_DEBUG, "Crypto reconfiguration phase %d", req_exec_cfg_crypto_reconfig->phase);
864 
865  /* Do the deed */
867 
868  /* Move to the next phase if not finished */
870  struct req_exec_cfg_crypto_reconfig req_exec_cfg_crypto_reconfig2;
871  struct iovec iovec;
872 
873  req_exec_cfg_crypto_reconfig2.header.size =
874  sizeof (struct req_exec_cfg_crypto_reconfig);
875  req_exec_cfg_crypto_reconfig2.header.id = SERVICE_ID_MAKE (CFG_SERVICE,
877  req_exec_cfg_crypto_reconfig2.phase = CRYPTO_RECONFIG_PHASE_CLEANUP;
878 
879  iovec.iov_base = (char *)&req_exec_cfg_crypto_reconfig2;
880  iovec.iov_len = sizeof (struct req_exec_cfg_crypto_reconfig);
881 
882  assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
883  }
884  }
885 }
886 
887 
888 /*
889  * Library Interface Implementation
890  */
891 static void message_handler_req_lib_cfg_ringstatusget (
892  void *conn,
893  const void *msg)
894 {
896  struct totem_ip_address interfaces[INTERFACE_MAX];
897  unsigned int iface_count;
898  char **status;
899  const char *totem_ip_string;
900  char ifname[CFG_INTERFACE_NAME_MAX_LEN];
901  unsigned int iface_ids[INTERFACE_MAX];
902  unsigned int i;
903  cs_error_t res = CS_OK;
904 
905  ENTER();
906 
908  res_lib_cfg_ringstatusget.header.size = sizeof (struct res_lib_cfg_ringstatusget);
909 
910  api->totem_ifaces_get (
911  api->totem_nodeid_get(),
912  iface_ids,
913  interfaces,
915  &status,
916  &iface_count);
917 
918  assert(iface_count <= CFG_MAX_INTERFACES);
919 
920  res_lib_cfg_ringstatusget.interface_count = iface_count;
921 
922  for (i = 0; i < iface_count; i++) {
923  totem_ip_string
924  = (const char *)api->totem_ip_print (&interfaces[i]);
925 
926  if (!totem_ip_string) {
927  totem_ip_string="";
928  }
929 
930  /* Allow for i/f number at the start */
931  if (strlen(totem_ip_string) >= CFG_INTERFACE_NAME_MAX_LEN-3) {
932  log_printf(LOGSYS_LEVEL_ERROR, "String representation of interface %u is too long", i);
933  res = CS_ERR_NAME_TOO_LONG;
934  goto send_response;
935  }
936  snprintf(ifname, sizeof(ifname), "%d %s", iface_ids[i], totem_ip_string);
937 
938  if (strlen(status[i]) >= CFG_INTERFACE_STATUS_MAX_LEN) {
939  log_printf(LOGSYS_LEVEL_ERROR, "Status string for interface %u is too long", i);
940  res = CS_ERR_NAME_TOO_LONG;
941  goto send_response;
942  }
943 
944  strcpy ((char *)&res_lib_cfg_ringstatusget.interface_status[i],
945  status[i]);
946  strcpy ((char *)&res_lib_cfg_ringstatusget.interface_name[i],
947  ifname);
948  }
949 
950 send_response:
951  res_lib_cfg_ringstatusget.header.error = res;
952  api->ipc_response_send (
953  conn,
955  sizeof (struct res_lib_cfg_ringstatusget));
956 
957  LEAVE();
958 }
959 
960 static void message_handler_req_lib_cfg_ringreenable (
961  void *conn,
962  const void *msg)
963 {
965  ENTER();
966 
968  res_lib_cfg_ringreenable.header.size = sizeof (struct res_lib_cfg_ringreenable);
970  api->ipc_response_send (
972  sizeof (struct res_lib_cfg_ringreenable));
973 
974  LEAVE();
975 }
976 
977 static void message_handler_req_lib_cfg_killnode (
978  void *conn,
979  const void *msg)
980 {
981  const struct req_lib_cfg_killnode *req_lib_cfg_killnode = msg;
984  struct iovec iovec;
985  char key_name[ICMAP_KEYNAME_MAXLEN];
986  char tmp_key[ICMAP_KEYNAME_MAXLEN + 1];
987  icmap_map_t map;
988  icmap_iter_t iter;
989  const char *iter_key;
990  uint32_t nodeid;
991  char *status_str = NULL;
992  int match_nodeid_flag = 0;
993  cs_error_t error = CS_OK;
994 
995  ENTER();
996 
997  map = icmap_get_global_map();
998  iter = icmap_iter_init_r(map, "runtime.members.");
999  while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
1000  if (sscanf(iter_key, "runtime.members.%u.%s", &nodeid, key_name) != 2) {
1001  continue;
1002  }
1003  if (strcmp(key_name, "status") != 0) {
1004  continue;
1005  }
1006  if (nodeid != req_lib_cfg_killnode->nodeid) {
1007  continue;
1008  }
1009  match_nodeid_flag = 1;
1010  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "runtime.members.%u.status", nodeid);
1011  if (icmap_get_string_r(map, tmp_key, &status_str) != CS_OK) {
1012  error = CS_ERR_LIBRARY;
1013  goto send_response;
1014  }
1015  if (strcmp(status_str, "joined") != 0) {
1016  error = CS_ERR_NOT_EXIST;
1017  goto send_response;
1018  }
1019  break;
1020  }
1021 
1022  if (!match_nodeid_flag) {
1023  error = CS_ERR_NOT_EXIST;
1024  goto send_response;
1025  }
1026 
1027  req_exec_cfg_killnode.header.size =
1028  sizeof (struct req_exec_cfg_killnode);
1032  marshall_to_mar_name_t(&req_exec_cfg_killnode.reason, &req_lib_cfg_killnode->reason);
1033 
1034  iovec.iov_base = (char *)&req_exec_cfg_killnode;
1035  iovec.iov_len = sizeof (struct req_exec_cfg_killnode);
1036 
1037  (void)api->totem_mcast (&iovec, 1, TOTEM_SAFE);
1038 
1039 send_response:
1040  res_lib_cfg_killnode.header.size = sizeof(struct res_lib_cfg_killnode);
1042  res_lib_cfg_killnode.header.error = error;
1043 
1045  sizeof(res_lib_cfg_killnode));
1046 
1047  free(status_str);
1048  icmap_iter_finalize(iter);
1049  LEAVE();
1050 }
1051 
1052 
1053 static void message_handler_req_lib_cfg_tryshutdown (
1054  void *conn,
1055  const void *msg)
1056 {
1057  struct cfg_info *ci = (struct cfg_info *)api->ipc_private_data_get (conn);
1059  struct qb_list_head *iter;
1060 
1061  ENTER();
1062 
1065 
1066  /*
1067  * Tell other nodes
1068  */
1069  send_shutdown();
1070 
1071  res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
1073  res_lib_cfg_tryshutdown.header.error = CS_OK;
1075  sizeof(res_lib_cfg_tryshutdown));
1076 
1077  LEAVE();
1078  return;
1079  }
1080 
1081  /*
1082  * Shutdown in progress, return an error
1083  */
1084  if (shutdown_con) {
1086 
1087  res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
1089  res_lib_cfg_tryshutdown.header.error = CS_ERR_EXIST;
1090 
1092  sizeof(res_lib_cfg_tryshutdown));
1093 
1094 
1095  LEAVE();
1096 
1097  return;
1098  }
1099 
1100  ci->conn = conn;
1101  shutdown_con = (struct cfg_info *)api->ipc_private_data_get (conn);
1102  shutdown_flags = req_lib_cfg_tryshutdown->flags;
1103  shutdown_yes = 0;
1104  shutdown_no = 0;
1105 
1106  /*
1107  * Count the number of listeners
1108  */
1109  shutdown_expected = 0;
1110 
1111  qb_list_for_each(iter, &trackers_list) {
1112  struct cfg_info *testci = qb_list_entry(iter, struct cfg_info, list);
1113  /*
1114  * It is assumed that we will allow shutdown
1115  */
1116  if (testci != ci) {
1118  shutdown_expected++;
1119  }
1120  }
1121 
1122  /*
1123  * If no-one is listening for events then we can just go down now
1124  */
1125  if (shutdown_expected == 0) {
1127 
1128  res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
1130  res_lib_cfg_tryshutdown.header.error = CS_OK;
1131 
1132  /*
1133  * Tell originator that shutdown was confirmed
1134  */
1136  sizeof(res_lib_cfg_tryshutdown));
1137 
1138  send_shutdown();
1139  LEAVE();
1140  return;
1141  }
1142  else {
1143  unsigned int shutdown_timeout = DEFAULT_SHUTDOWN_TIMEOUT;
1144 
1145  /*
1146  * Look for a shutdown timeout in configuration map
1147  */
1148  icmap_get_uint32("cfg.shutdown_timeout", &shutdown_timeout);
1149 
1150  /*
1151  * Start the timer. If we don't get a full set of replies before this goes
1152  * off we'll cancel the shutdown
1153  */
1154  api->timer_add_duration((unsigned long long)shutdown_timeout*1000000000, NULL,
1155  shutdown_timer_fn, &shutdown_timer);
1156 
1157  /*
1158  * Tell the users we would like to shut down
1159  */
1160  send_test_shutdown(NULL, conn, CS_OK);
1161  }
1162 
1163  /*
1164  * We don't sent a reply to the caller here.
1165  * We send it when we know if we can shut down or not
1166  */
1167 
1168  LEAVE();
1169 }
1170 
1171 static void message_handler_req_lib_cfg_replytoshutdown (
1172  void *conn,
1173  const void *msg)
1174 {
1175  struct cfg_info *ci = (struct cfg_info *)api->ipc_private_data_get (conn);
1178  int status = CS_OK;
1179 
1180  ENTER();
1181  if (!shutdown_con) {
1182  status = CS_ERR_ACCESS;
1183  goto exit_fn;
1184  }
1185 
1187  shutdown_yes++;
1188  ci->shutdown_reply = SHUTDOWN_REPLY_YES;
1189  }
1190  else {
1191  shutdown_no++;
1192  ci->shutdown_reply = SHUTDOWN_REPLY_NO;
1193  }
1194  check_shutdown_status();
1195 
1196 exit_fn:
1197  res_lib_cfg_replytoshutdown.header.error = status;
1200 
1202  sizeof(res_lib_cfg_replytoshutdown));
1203 
1204  LEAVE();
1205 }
1206 
1207 static void message_handler_req_lib_cfg_get_node_addrs (void *conn,
1208  const void *msg)
1209 {
1210  struct totem_ip_address node_ifs[INTERFACE_MAX];
1211  unsigned int iface_ids[INTERFACE_MAX];
1212  char buf[PIPE_BUF];
1213  char **status;
1214  unsigned int num_interfaces = 0;
1215  struct sockaddr_storage *ss;
1216  int ret = CS_OK;
1217  int i;
1218  int live_addrs = 0;
1221  unsigned int nodeid = req_lib_cfg_get_node_addrs->nodeid;
1222  char *addr_buf;
1223 
1224  if (nodeid == 0)
1225  nodeid = api->totem_nodeid_get();
1226 
1227  if (api->totem_ifaces_get(nodeid, iface_ids, node_ifs, INTERFACE_MAX, &status, &num_interfaces)) {
1228  ret = CS_ERR_EXIST;
1229  num_interfaces = 0;
1230  }
1231 
1232  res_lib_cfg_get_node_addrs->header.size = sizeof(struct res_lib_cfg_get_node_addrs) + (num_interfaces * TOTEMIP_ADDRLEN);
1234  res_lib_cfg_get_node_addrs->header.error = ret;
1235  if (num_interfaces) {
1236  res_lib_cfg_get_node_addrs->family = node_ifs[0].family;
1237  for (i = 0, addr_buf = (char *)res_lib_cfg_get_node_addrs->addrs;
1238  i < num_interfaces; i++) {
1239  ss = (struct sockaddr_storage *)&node_ifs[i].addr;
1240  if (ss->ss_family) {
1241  memcpy(addr_buf, node_ifs[i].addr, TOTEMIP_ADDRLEN);
1242  live_addrs++;
1243  addr_buf += TOTEMIP_ADDRLEN;
1244  }
1245  }
1246  res_lib_cfg_get_node_addrs->num_addrs = live_addrs;
1247  } else {
1249  }
1251 }
1252 
1253 static void message_handler_req_lib_cfg_local_get (void *conn, const void *msg)
1254 {
1256 
1257  res_lib_cfg_local_get.header.size = sizeof(res_lib_cfg_local_get);
1259  res_lib_cfg_local_get.header.error = CS_OK;
1260  res_lib_cfg_local_get.local_nodeid = api->totem_nodeid_get ();
1261 
1263  sizeof(res_lib_cfg_local_get));
1264 }
1265 
1266 static void message_handler_req_lib_cfg_reload_config (void *conn, const void *msg)
1267 {
1269  struct iovec iovec;
1270 
1271  ENTER();
1272 
1273  req_exec_cfg_reload_config.header.size =
1274  sizeof (struct req_exec_cfg_reload_config);
1277  api->ipc_source_set (&req_exec_cfg_reload_config.source, conn);
1278  api->ipc_refcnt_inc(conn);
1279 
1280  iovec.iov_base = (char *)&req_exec_cfg_reload_config;
1281  iovec.iov_len = sizeof (struct req_exec_cfg_reload_config);
1282 
1283  assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
1284 
1285  LEAVE();
1286 }
1287 
1288 static void message_handler_req_lib_cfg_reopen_log_files (void *conn, const void *msg)
1289 {
1291  cs_error_t res;
1292 
1293  ENTER();
1294 
1295  log_printf(LOGSYS_LEVEL_DEBUG, "Reopening logging files\n");
1296 
1297  res = logsys_reopen_log_files();
1298 
1301  res_lib_cfg_reopen_log_files.header.error = res;
1302  api->ipc_response_send(conn,
1305 
1306  LEAVE();
1307 }
#define SERVICE_ID_MAKE(a, b)
Definition: coroapi.h:458
totem_configuration_type
The totem_configuration_type enum.
Definition: coroapi.h:132
#define INTERFACE_MAX
Definition: coroapi.h:88
@ CS_LIB_ALLOW_INQUORATE
Definition: coroapi.h:164
qb_loop_timer_handle corosync_timer_handle_t
corosync_timer_handle_t
Definition: coroapi.h:74
unsigned int nodeid
Definition: coroapi.h:0
#define corosync_fatal_error(err)
Definition: coroapi.h:424
unsigned char addr[TOTEMIP_ADDRLEN]
Definition: coroapi.h:2
@ CS_LIB_FLOW_CONTROL_REQUIRED
Definition: coroapi.h:152
@ CS_LIB_FLOW_CONTROL_NOT_REQUIRED
Definition: coroapi.h:153
@ COROSYNC_FATAL_ERROR_EXIT
Definition: coroapi.h:184
#define TOTEM_SAFE
Definition: coroapi.h:103
#define TOTEMIP_ADDRLEN
Definition: coroapi.h:86
@ CFG_SERVICE
Definition: corodefs.h:45
int coroparse_configparse(icmap_map_t config_map, const char **error_string)
Definition: coroparse.c:258
#define CS_PRI_NODE_ID
Definition: corotypes.h:59
cs_error_t
The cs_error_t enum.
Definition: corotypes.h:97
@ CS_ERR_NAME_TOO_LONG
Definition: corotypes.h:110
@ CS_ERR_ACCESS
Definition: corotypes.h:108
@ CS_ERR_BUSY
Definition: corotypes.h:107
@ CS_ERR_TIMEOUT
Definition: corotypes.h:102
@ CS_OK
Definition: corotypes.h:98
@ CS_ERR_INVALID_PARAM
Definition: corotypes.h:104
@ CS_ERR_LIBRARY
Definition: corotypes.h:99
@ CS_ERR_NOT_EXIST
Definition: corotypes.h:109
@ CS_ERR_EXIST
Definition: corotypes.h:111
@ CS_ERR_NOT_SUPPORTED
Definition: corotypes.h:116
struct corosync_service_engine * cfg_get_service_engine_ver0(void)
Definition: exec/cfg.c:259
struct corosync_service_engine cfg_service_engine
Definition: exec/cfg.c:242
cfg_message_req_types
Definition: exec/cfg.c:73
@ MESSAGE_REQ_EXEC_CFG_RELOAD_CONFIG
Definition: exec/cfg.c:77
@ MESSAGE_REQ_EXEC_CFG_SHUTDOWN
Definition: exec/cfg.c:76
@ MESSAGE_REQ_EXEC_CFG_RINGREENABLE
Definition: exec/cfg.c:74
@ MESSAGE_REQ_EXEC_CFG_KILLNODE
Definition: exec/cfg.c:75
@ MESSAGE_REQ_EXEC_CFG_CRYPTO_RECONFIG
Definition: exec/cfg.c:78
LOGSYS_DECLARE_SUBSYS("CFG")
#define DEFAULT_SHUTDOWN_TIMEOUT
Definition: exec/cfg.c:81
icmap_iter_t icmap_iter_init_r(const icmap_map_t map, const char *prefix)
icmap_iter_init_r
Definition: icmap.c:1084
cs_error_t icmap_get_string_r(const icmap_map_t map, const char *key_name, char **str)
Definition: icmap.c:735
cs_error_t icmap_get_uint32(const char *key_name, uint32_t *u32)
Definition: icmap.c:892
cs_error_t icmap_set_uint8(const char *key_name, uint8_t value)
Definition: icmap.c:573
cs_error_t icmap_delete(const char *key_name)
Delete key from map.
Definition: icmap.c:653
cs_error_t icmap_set_int32(const char *key_name, int32_t value)
Definition: icmap.c:591
cs_error_t icmap_delete_r(const icmap_map_t map, const char *key_name)
icmap_delete_r
Definition: icmap.c:633
int icmap_key_value_eq(const icmap_map_t map1, const char *key_name1, const icmap_map_t map2, const char *key_name2)
Compare value of key with name key_name1 in map1 with key with name key_name2 in map2.
Definition: icmap.c:385
icmap_iter_t icmap_iter_init(const char *prefix)
Initialize iterator with given prefix.
Definition: icmap.c:1089
cs_error_t icmap_copy_map(icmap_map_t dst_map, const icmap_map_t src_map)
Copy content of src_map icmap to dst_map icmap.
Definition: icmap.c:1298
cs_error_t icmap_init_r(icmap_map_t *result)
Initialize additional (local, reentrant) icmap_map.
Definition: icmap.c:188
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:1095
icmap_map_t icmap_get_global_map(void)
Return global icmap.
Definition: icmap.c:264
qb_map_iter_t * icmap_iter_t
Itterator type.
Definition: icmap.h:123
void icmap_iter_finalize(icmap_iter_t iter)
Finalize iterator.
Definition: icmap.c:1116
void icmap_fini_r(const icmap_map_t map)
Finalize local, reentrant icmap.
Definition: icmap.c:238
#define ICMAP_KEYNAME_MAXLEN
Maximum length of key in icmap.
Definition: icmap.h:48
@ CFG_SHUTDOWN_FLAG_REGARDLESS
Definition: ipc_cfg.h:258
@ CFG_SHUTDOWN_FLAG_IMMEDIATE
Definition: ipc_cfg.h:259
#define CFG_INTERFACE_STATUS_MAX_LEN
Definition: ipc_cfg.h:43
#define CFG_INTERFACE_NAME_MAX_LEN
Definition: ipc_cfg.h:42
@ MESSAGE_RES_CFG_LOCAL_GET
Definition: ipc_cfg.h:81
@ MESSAGE_RES_CFG_RELOAD_CONFIG
Definition: ipc_cfg.h:83
@ MESSAGE_RES_CFG_RINGSTATUSGET
Definition: ipc_cfg.h:69
@ MESSAGE_RES_CFG_TRYSHUTDOWN
Definition: ipc_cfg.h:78
@ MESSAGE_RES_CFG_GET_NODE_ADDRS
Definition: ipc_cfg.h:80
@ MESSAGE_RES_CFG_REOPEN_LOG_FILES
Definition: ipc_cfg.h:84
@ MESSAGE_RES_CFG_TESTSHUTDOWN
Definition: ipc_cfg.h:79
@ MESSAGE_RES_CFG_KILLNODE
Definition: ipc_cfg.h:77
@ MESSAGE_RES_CFG_REPLYTOSHUTDOWN
Definition: ipc_cfg.h:82
@ MESSAGE_RES_CFG_RINGREENABLE
Definition: ipc_cfg.h:70
#define CFG_MAX_INTERFACES
Definition: ipc_cfg.h:48
#define LOGSYS_LEVEL_ERROR
Definition: logsys.h:72
#define LEAVE
Definition: logsys.h:325
#define log_printf(level, format, args...)
Definition: logsys.h:323
#define LOGSYS_LEVEL_NOTICE
Definition: logsys.h:74
#define TRACE1(format, args...)
Definition: logsys.h:326
cs_error_t logsys_reopen_log_files(void)
Definition: logsys.c:890
#define LOGSYS_LEVEL_DEBUG
Definition: logsys.h:76
#define ENTER
Definition: logsys.h:324
uint32_t mar_uint32_t
Definition: mar_gen.h:53
void * conn
Definition: exec/cfg.c:98
enum cfg_info::@8 shutdown_reply
void * tracker_conn
Definition: exec/cfg.c:99
@ SHUTDOWN_REPLY_YES
Definition: exec/cfg.c:100
@ SHUTDOWN_REPLY_NO
Definition: exec/cfg.c:100
@ SHUTDOWN_REPLY_UNKNOWN
Definition: exec/cfg.c:100
struct qb_list_head list
Definition: exec/cfg.c:97
The corosync_api_v1 struct.
Definition: coroapi.h:225
int(* timer_add_duration)(unsigned long long nanoseconds_in_future, void *data, void(*timer_nf)(void *data), corosync_timer_handle_t *handle)
Definition: coroapi.h:229
int(* totem_mcast)(const struct iovec *iovec, unsigned int iov_len, unsigned int guarantee)
Definition: coroapi.h:279
void(* timer_delete)(corosync_timer_handle_t timer_handle)
Definition: coroapi.h:241
unsigned int(* totem_nodeid_get)(void)
Definition: coroapi.h:275
void(* ipc_refcnt_dec)(void *conn)
Definition: coroapi.h:270
void(* ipc_source_set)(mar_message_source_t *source, void *conn)
Definition: coroapi.h:252
void(* shutdown_request)(void)
Definition: coroapi.h:429
int(* totem_ifaces_get)(unsigned int nodeid, unsigned int *interface_ids, struct totem_ip_address *interfaces, unsigned int interfaces_size, char ***status, unsigned int *iface_count)
Definition: coroapi.h:282
void(* ipc_refcnt_inc)(void *conn)
Definition: coroapi.h:268
int(* ipc_dispatch_send)(void *conn, const void *msg, size_t mlen)
Definition: coroapi.h:263
const char *(* totem_ip_print)(const struct totem_ip_address *addr)
Definition: coroapi.h:292
int(* ipc_response_send)(void *conn, const void *msg, size_t mlen)
Definition: coroapi.h:258
void *(* ipc_private_data_get)(void *conn)
Definition: coroapi.h:256
The corosync_exec_handler struct.
Definition: coroapi.h:475
void(* exec_handler_fn)(const void *msg, unsigned int nodeid)
Definition: coroapi.h:476
The corosync_lib_handler struct.
Definition: coroapi.h:467
void(* lib_handler_fn)(void *conn, const void *msg)
Definition: coroapi.h:468
The corosync_service_engine struct.
Definition: coroapi.h:490
const char * name
Definition: coroapi.h:491
The cs_name_t struct.
Definition: corotypes.h:65
uint8_t value[CS_MAX_NAME_LENGTH]
Definition: corotypes.h:67
The mar_message_source_t struct.
Definition: coroapi.h:50
mar_name_t struct
Definition: mar_gen.h:166
The memb_ring_id struct.
Definition: coroapi.h:122
struct qb_ipc_request_header header __attribute__((aligned(8)))
mar_uint32_t phase __attribute__((aligned(8)))
mar_uint32_t nodeid __attribute__((aligned(8)))
mar_name_t reason __attribute__((aligned(8)))
struct qb_ipc_request_header header __attribute__((aligned(8)))
mar_message_source_t source __attribute__((aligned(8)))
struct qb_ipc_request_header header __attribute__((aligned(8)))
mar_message_source_t source __attribute__((aligned(8)))
struct qb_ipc_request_header header __attribute__((aligned(8)))
struct qb_ipc_request_header header __attribute__((aligned(8)))
The req_lib_cfg_get_node_addrs struct.
Definition: ipc_cfg.h:175
The req_lib_cfg_killnode struct.
Definition: ipc_cfg.h:121
The req_lib_cfg_replytoshutdown struct.
Definition: ipc_cfg.h:152
The req_lib_cfg_tryshutdown struct.
Definition: ipc_cfg.h:137
unsigned int flags
Definition: ipc_cfg.h:139
The res_lib_cfg_get_node_addrs struct.
Definition: ipc_cfg.h:183
unsigned int num_addrs
Definition: ipc_cfg.h:186
The res_lib_cfg_killnode struct.
Definition: ipc_cfg.h:130
The res_lib_cfg_local_get struct.
Definition: ipc_cfg.h:201
The res_lib_cfg_reload_config struct.
Definition: ipc_cfg.h:216
The res_lib_cfg_reopen_log_files struct.
Definition: ipc_cfg.h:230
The res_lib_cfg_replytoshutdown struct.
Definition: ipc_cfg.h:160
The res_lib_cfg_ringreenable struct.
Definition: ipc_cfg.h:114
The res_lib_cfg_ringstatusget struct.
Definition: ipc_cfg.h:97
The res_lib_cfg_testshutdown struct.
Definition: ipc_cfg.h:167
unsigned int flags
Definition: ipc_cfg.h:169
The res_lib_cfg_tryshutdown struct.
Definition: ipc_cfg.h:145
The totem_ip_address struct.
Definition: coroapi.h:111
@ CRYPTO_RECONFIG_PHASE_CLEANUP
Definition: totem.h:156
@ CRYPTO_RECONFIG_PHASE_ACTIVATE
Definition: totem.h:155
@ TOTEM_TRANSPORT_UDPU
Definition: totem.h:144
@ TOTEM_TRANSPORT_UDP
Definition: totem.h:143
void totem_volatile_config_read(struct totem_config *totem_config, icmap_map_t temp_map, const char *deleted_key)
Definition: totemconfig.c:303
void totemconfig_commit_new_params(struct totem_config *totem_config, icmap_map_t map)
Definition: totemconfig.c:2364
int totem_volatile_config_validate(struct totem_config *totem_config, icmap_map_t temp_map, const char **error_string)
Definition: totemconfig.c:368
int totem_reread_crypto_config(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
Definition: totemconfig.c:2236
int totemconfig_configure_new_params(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
Definition: totemconfig.c:2341
void totempg_get_config(struct totem_config *config)
Definition: totempg.c:1595
void totempg_put_config(struct totem_config *config)
Definition: totempg.c:1605
int totempg_crypto_reconfigure_phase(cfg_message_crypto_reconfig_phase_t phase)
Definition: totempg.c:1564
struct memb_ring_id ring_id
Definition: totemsrp.c:4
struct totem_message_header header
Definition: totemsrp.c:0