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.allow_knet_handle_fallback");
616  delete_and_notify_if_changed(temp_map, "system.sched_rr");
617  delete_and_notify_if_changed(temp_map, "system.priority");
618  delete_and_notify_if_changed(temp_map, "system.qb_ipc_type");
619  delete_and_notify_if_changed(temp_map, "system.state_dir");
620 }
621 
622 /*
623  * Remove entries that exist in the global map, but not in the temp_map, this will
624  * cause delete notifications to be sent to any listeners.
625  *
626  * NOTE: This routine depends entirely on the keys returned by the iterators
627  * being in alpha-sorted order.
628  */
629 static void remove_deleted_entries(icmap_map_t temp_map, const char *prefix)
630 {
631  icmap_iter_t old_iter;
632  icmap_iter_t new_iter;
633  const char *old_key, *new_key;
634  int ret;
635 
636  old_iter = icmap_iter_init(prefix);
637  new_iter = icmap_iter_init_r(temp_map, prefix);
638 
639  old_key = icmap_iter_next(old_iter, NULL, NULL);
640  new_key = icmap_iter_next(new_iter, NULL, NULL);
641 
642  while (old_key || new_key) {
643  ret = nullcheck_strcmp(old_key, new_key);
644  if ((ret < 0 && old_key) || !new_key) {
645  /*
646  * new_key is greater, a line (or more) has been deleted
647  * Continue until old is >= new
648  */
649  do {
650  /* Remove it from icmap & send notifications */
651  icmap_delete(old_key);
652 
653  old_key = icmap_iter_next(old_iter, NULL, NULL);
654  ret = nullcheck_strcmp(old_key, new_key);
655  } while (ret < 0 && old_key);
656  }
657  else if ((ret > 0 && new_key) || !old_key) {
658  /*
659  * old_key is greater, a line (or more) has been added
660  * Continue until new is >= old
661  *
662  * we don't need to do anything special with this like tell
663  * icmap. That will happen when we copy the values over
664  */
665  do {
666  new_key = icmap_iter_next(new_iter, NULL, NULL);
667  ret = nullcheck_strcmp(old_key, new_key);
668  } while (ret > 0 && new_key);
669  }
670  if (ret == 0) {
671  new_key = icmap_iter_next(new_iter, NULL, NULL);
672  old_key = icmap_iter_next(old_iter, NULL, NULL);
673  }
674  }
675  icmap_iter_finalize(new_iter);
676  icmap_iter_finalize(old_iter);
677 }
678 
679 /*
680  * Reload configuration file
681  */
682 static void message_handler_req_exec_cfg_reload_config (
683  const void *message,
684  unsigned int nodeid)
685 {
688  struct totem_config new_config;
689  icmap_map_t temp_map;
690  const char *error_string;
691  int res = CS_OK;
692 
693  ENTER();
694 
695  log_printf(LOGSYS_LEVEL_NOTICE, "Config reload requested by node " CS_PRI_NODE_ID, nodeid);
696 
697  icmap_set_uint8("config.totemconfig_reload_in_progress", 1);
698 
699  /* Make sure there is no rubbish in this that might be checked, even on error */
700  memset(&new_config, 0, sizeof(new_config));
701  /*
702  * Set up a new hashtable as a staging area.
703  */
704  if ((res = icmap_init_r(&temp_map)) != CS_OK) {
705  log_printf(LOGSYS_LEVEL_ERROR, "Unable to create temporary icmap. config file reload cancelled\n");
706  goto reload_fini_nomap;
707  }
708 
709  /*
710  * Load new config into the temporary map
711  */
712  res = coroparse_configparse(temp_map, &error_string);
713  if (res == -1) {
714  log_printf (LOGSYS_LEVEL_ERROR, "Unable to reload config file: %s", error_string);
715  res = CS_ERR_INVALID_PARAM;
716  goto reload_fini_nofree;
717  }
718 
719  /* Signal start of the reload process */
720  icmap_set_uint8("config.reload_in_progress", 1);
721 
722  /* Detect deleted entries and remove them from the main icmap hashtable */
723  remove_deleted_entries(temp_map, "logging.");
724  remove_deleted_entries(temp_map, "totem.");
725  remove_deleted_entries(temp_map, "nodelist.");
726  remove_deleted_entries(temp_map, "quorum.");
727  remove_deleted_entries(temp_map, "uidgid.config.");
728  remove_deleted_entries(temp_map, "nozzle.");
729 
730  /* Remove entries that cannot be changed */
731  remove_ro_entries(temp_map);
732 
733  /* Take a copy of the current setup so we can check what has changed */
734  memset(&new_config, 0, sizeof(new_config));
735  new_config.orig_interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
736  assert(new_config.orig_interfaces != NULL);
737 
738  totempg_get_config(&new_config);
739  new_config.crypto_changed = 0;
740 
741  new_config.interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
742  assert(new_config.interfaces != NULL);
743  memset(new_config.interfaces, 0, sizeof (struct totem_interface) * INTERFACE_MAX);
744 
745  /* For UDP[U] the configuration on link0 is static (apart from the nodelist) and only read at
746  startup. So preserve it here */
747  if ( (new_config.transport_number == TOTEM_TRANSPORT_UDP) ||
748  (new_config.transport_number == TOTEM_TRANSPORT_UDPU)) {
749  memcpy(&new_config.interfaces[0], &new_config.orig_interfaces[0],
750  sizeof(struct totem_interface));
751  }
752 
753  /* Calculate new node and interface definitions */
754  if (totemconfig_configure_new_params(&new_config, temp_map, &error_string) == -1) {
755  log_printf (LOGSYS_LEVEL_ERROR, "Cannot configure new interface definitions: %s\n", error_string);
756  res = CS_ERR_INVALID_PARAM;
757  goto reload_fini;
758  }
759 
760  /* Read from temp_map into new_config */
761  totem_volatile_config_read(&new_config, temp_map, NULL);
762 
763  /* Get updated crypto parameters. Will set a flag in new_config if things have changed */
764  if (totem_reread_crypto_config(&new_config, temp_map, &error_string) == -1) {
765  log_printf (LOGSYS_LEVEL_ERROR, "Crypto configuration is not valid: %s\n", error_string);
766  res = CS_ERR_INVALID_PARAM;
767  goto reload_fini;
768  }
769 
770  /* Validate dynamic parameters */
771  if (totem_volatile_config_validate(&new_config, temp_map, &error_string) == -1) {
772  log_printf (LOGSYS_LEVEL_ERROR, "Configuration is not valid: %s\n", error_string);
773  res = CS_ERR_INVALID_PARAM;
774  goto reload_fini;
775  }
776 
777  /* Save this here so we can get at it for the later phases of crypto change */
778  if (new_config.crypto_changed) {
779 #ifndef HAVE_KNET_CRYPTO_RECONF
780  new_config.crypto_changed = 0;
781  log_printf (LOGSYS_LEVEL_ERROR, "Crypto reconfiguration is not supported by the linked version of knet\n");
782  res = CS_ERR_INVALID_PARAM;
783  goto reload_fini;
784 #endif
785  }
786 
787  /*
788  * Copy new keys into live config.
789  */
790  if ( (res = icmap_copy_map(icmap_get_global_map(), temp_map)) != CS_OK) {
791  log_printf (LOGSYS_LEVEL_ERROR, "Error making new config live. cmap database may be inconsistent\n");
792  /* Return res from icmap */
793  goto reload_fini;
794  }
795 
796  /* Copy into live system */
797  totempg_put_config(&new_config);
798  totemconfig_commit_new_params(&new_config, temp_map);
799  free(new_config.interfaces);
800 
801 reload_fini:
802  /* All done - let clients know */
803  icmap_set_int32("config.reload_status", res);
804  icmap_set_uint8("config.totemconfig_reload_in_progress", 0);
805  icmap_set_uint8("config.reload_in_progress", 0);
806 
807  /* Finished with the temporary storage */
808  free(new_config.orig_interfaces);
809 
810 reload_fini_nofree:
811  icmap_fini_r(temp_map);
812 
813 reload_fini_nomap:
814 
815  /* If crypto was changed, now it's loaded on all nodes we can enable it.
816  * Each node sends its own PHASE message so we're not relying on the leader
817  * node to survive the transition
818  */
819  if (new_config.crypto_changed) {
821  struct iovec iovec;
822 
823  req_exec_cfg_crypto_reconfig.header.size =
824  sizeof (struct req_exec_cfg_crypto_reconfig);
828 
829  iovec.iov_base = (char *)&req_exec_cfg_crypto_reconfig;
830  iovec.iov_len = sizeof (struct req_exec_cfg_crypto_reconfig);
831 
832  assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
833  }
834 
835  /* All done, return result to the caller if it was on this system */
836  if (nodeid == api->totem_nodeid_get()) {
839  res_lib_cfg_reload_config.header.error = res;
842  sizeof(res_lib_cfg_reload_config));
843  api->ipc_refcnt_dec(req_exec_cfg_reload_config->source.conn);;
844  }
845 
846  LEAVE();
847 }
848 
849 /* Handle the phases of crypto reload
850  * The first time we are called is after the new crypto config has been loaded
851  * but not activated.
852  *
853  * 1 - activate the new crypto configuration
854  * 2 - clear out the old configuration
855  */
856 static void message_handler_req_exec_cfg_reconfig_crypto (
857  const void *message,
858  unsigned int nodeid)
859 {
861 
862  /* Got our own reconfig message */
863  if (nodeid == api->totem_nodeid_get()) {
864  log_printf (LOGSYS_LEVEL_DEBUG, "Crypto reconfiguration phase %d", req_exec_cfg_crypto_reconfig->phase);
865 
866  /* Do the deed */
868 
869  /* Move to the next phase if not finished */
871  struct req_exec_cfg_crypto_reconfig req_exec_cfg_crypto_reconfig2;
872  struct iovec iovec;
873 
874  req_exec_cfg_crypto_reconfig2.header.size =
875  sizeof (struct req_exec_cfg_crypto_reconfig);
876  req_exec_cfg_crypto_reconfig2.header.id = SERVICE_ID_MAKE (CFG_SERVICE,
878  req_exec_cfg_crypto_reconfig2.phase = CRYPTO_RECONFIG_PHASE_CLEANUP;
879 
880  iovec.iov_base = (char *)&req_exec_cfg_crypto_reconfig2;
881  iovec.iov_len = sizeof (struct req_exec_cfg_crypto_reconfig);
882 
883  assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
884  }
885  }
886 }
887 
888 
889 /*
890  * Library Interface Implementation
891  */
892 static void message_handler_req_lib_cfg_ringstatusget (
893  void *conn,
894  const void *msg)
895 {
897  struct totem_ip_address interfaces[INTERFACE_MAX];
898  unsigned int iface_count;
899  char **status;
900  const char *totem_ip_string;
901  char ifname[CFG_INTERFACE_NAME_MAX_LEN];
902  unsigned int iface_ids[INTERFACE_MAX];
903  unsigned int i;
904  cs_error_t res = CS_OK;
905 
906  ENTER();
907 
909  res_lib_cfg_ringstatusget.header.size = sizeof (struct res_lib_cfg_ringstatusget);
910 
911  api->totem_ifaces_get (
912  api->totem_nodeid_get(),
913  iface_ids,
914  interfaces,
916  &status,
917  &iface_count);
918 
919  assert(iface_count <= CFG_MAX_INTERFACES);
920 
921  res_lib_cfg_ringstatusget.interface_count = iface_count;
922 
923  for (i = 0; i < iface_count; i++) {
924  totem_ip_string
925  = (const char *)api->totem_ip_print (&interfaces[i]);
926 
927  if (!totem_ip_string) {
928  totem_ip_string="";
929  }
930 
931  /* Allow for i/f number at the start */
932  if (strlen(totem_ip_string) >= CFG_INTERFACE_NAME_MAX_LEN-3) {
933  log_printf(LOGSYS_LEVEL_ERROR, "String representation of interface %u is too long", i);
934  res = CS_ERR_NAME_TOO_LONG;
935  goto send_response;
936  }
937  snprintf(ifname, sizeof(ifname), "%d %s", iface_ids[i], totem_ip_string);
938 
939  if (strlen(status[i]) >= CFG_INTERFACE_STATUS_MAX_LEN) {
940  log_printf(LOGSYS_LEVEL_ERROR, "Status string for interface %u is too long", i);
941  res = CS_ERR_NAME_TOO_LONG;
942  goto send_response;
943  }
944 
945  strcpy ((char *)&res_lib_cfg_ringstatusget.interface_status[i],
946  status[i]);
947  strcpy ((char *)&res_lib_cfg_ringstatusget.interface_name[i],
948  ifname);
949  }
950 
951 send_response:
952  res_lib_cfg_ringstatusget.header.error = res;
953  api->ipc_response_send (
954  conn,
956  sizeof (struct res_lib_cfg_ringstatusget));
957 
958  LEAVE();
959 }
960 
961 static void message_handler_req_lib_cfg_ringreenable (
962  void *conn,
963  const void *msg)
964 {
966  ENTER();
967 
969  res_lib_cfg_ringreenable.header.size = sizeof (struct res_lib_cfg_ringreenable);
971  api->ipc_response_send (
973  sizeof (struct res_lib_cfg_ringreenable));
974 
975  LEAVE();
976 }
977 
978 static void message_handler_req_lib_cfg_killnode (
979  void *conn,
980  const void *msg)
981 {
982  const struct req_lib_cfg_killnode *req_lib_cfg_killnode = msg;
985  struct iovec iovec;
986  char key_name[ICMAP_KEYNAME_MAXLEN];
987  char tmp_key[ICMAP_KEYNAME_MAXLEN + 1];
988  icmap_map_t map;
989  icmap_iter_t iter;
990  const char *iter_key;
991  uint32_t nodeid;
992  char *status_str = NULL;
993  int match_nodeid_flag = 0;
994  cs_error_t error = CS_OK;
995 
996  ENTER();
997 
998  map = icmap_get_global_map();
999  iter = icmap_iter_init_r(map, "runtime.members.");
1000  while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
1001  if (sscanf(iter_key, "runtime.members.%u.%s", &nodeid, key_name) != 2) {
1002  continue;
1003  }
1004  if (strcmp(key_name, "status") != 0) {
1005  continue;
1006  }
1007  if (nodeid != req_lib_cfg_killnode->nodeid) {
1008  continue;
1009  }
1010  match_nodeid_flag = 1;
1011  snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "runtime.members.%u.status", nodeid);
1012  if (icmap_get_string_r(map, tmp_key, &status_str) != CS_OK) {
1013  error = CS_ERR_LIBRARY;
1014  goto send_response;
1015  }
1016  if (strcmp(status_str, "joined") != 0) {
1017  error = CS_ERR_NOT_EXIST;
1018  goto send_response;
1019  }
1020  break;
1021  }
1022 
1023  if (!match_nodeid_flag) {
1024  error = CS_ERR_NOT_EXIST;
1025  goto send_response;
1026  }
1027 
1028  req_exec_cfg_killnode.header.size =
1029  sizeof (struct req_exec_cfg_killnode);
1033  marshall_to_mar_name_t(&req_exec_cfg_killnode.reason, &req_lib_cfg_killnode->reason);
1034 
1035  iovec.iov_base = (char *)&req_exec_cfg_killnode;
1036  iovec.iov_len = sizeof (struct req_exec_cfg_killnode);
1037 
1038  (void)api->totem_mcast (&iovec, 1, TOTEM_SAFE);
1039 
1040 send_response:
1041  res_lib_cfg_killnode.header.size = sizeof(struct res_lib_cfg_killnode);
1043  res_lib_cfg_killnode.header.error = error;
1044 
1046  sizeof(res_lib_cfg_killnode));
1047 
1048  free(status_str);
1049  icmap_iter_finalize(iter);
1050  LEAVE();
1051 }
1052 
1053 
1054 static void message_handler_req_lib_cfg_tryshutdown (
1055  void *conn,
1056  const void *msg)
1057 {
1058  struct cfg_info *ci = (struct cfg_info *)api->ipc_private_data_get (conn);
1060  struct qb_list_head *iter;
1061 
1062  ENTER();
1063 
1066 
1067  /*
1068  * Tell other nodes
1069  */
1070  send_shutdown();
1071 
1072  res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
1074  res_lib_cfg_tryshutdown.header.error = CS_OK;
1076  sizeof(res_lib_cfg_tryshutdown));
1077 
1078  LEAVE();
1079  return;
1080  }
1081 
1082  /*
1083  * Shutdown in progress, return an error
1084  */
1085  if (shutdown_con) {
1087 
1088  res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
1090  res_lib_cfg_tryshutdown.header.error = CS_ERR_EXIST;
1091 
1093  sizeof(res_lib_cfg_tryshutdown));
1094 
1095 
1096  LEAVE();
1097 
1098  return;
1099  }
1100 
1101  ci->conn = conn;
1102  shutdown_con = (struct cfg_info *)api->ipc_private_data_get (conn);
1103  shutdown_flags = req_lib_cfg_tryshutdown->flags;
1104  shutdown_yes = 0;
1105  shutdown_no = 0;
1106 
1107  /*
1108  * Count the number of listeners
1109  */
1110  shutdown_expected = 0;
1111 
1112  qb_list_for_each(iter, &trackers_list) {
1113  struct cfg_info *testci = qb_list_entry(iter, struct cfg_info, list);
1114  /*
1115  * It is assumed that we will allow shutdown
1116  */
1117  if (testci != ci) {
1119  shutdown_expected++;
1120  }
1121  }
1122 
1123  /*
1124  * If no-one is listening for events then we can just go down now
1125  */
1126  if (shutdown_expected == 0) {
1128 
1129  res_lib_cfg_tryshutdown.header.size = sizeof(struct res_lib_cfg_tryshutdown);
1131  res_lib_cfg_tryshutdown.header.error = CS_OK;
1132 
1133  /*
1134  * Tell originator that shutdown was confirmed
1135  */
1137  sizeof(res_lib_cfg_tryshutdown));
1138 
1139  send_shutdown();
1140  LEAVE();
1141  return;
1142  }
1143  else {
1144  unsigned int shutdown_timeout = DEFAULT_SHUTDOWN_TIMEOUT;
1145 
1146  /*
1147  * Look for a shutdown timeout in configuration map
1148  */
1149  icmap_get_uint32("cfg.shutdown_timeout", &shutdown_timeout);
1150 
1151  /*
1152  * Start the timer. If we don't get a full set of replies before this goes
1153  * off we'll cancel the shutdown
1154  */
1155  api->timer_add_duration((unsigned long long)shutdown_timeout*1000000000, NULL,
1156  shutdown_timer_fn, &shutdown_timer);
1157 
1158  /*
1159  * Tell the users we would like to shut down
1160  */
1161  send_test_shutdown(NULL, conn, CS_OK);
1162  }
1163 
1164  /*
1165  * We don't sent a reply to the caller here.
1166  * We send it when we know if we can shut down or not
1167  */
1168 
1169  LEAVE();
1170 }
1171 
1172 static void message_handler_req_lib_cfg_replytoshutdown (
1173  void *conn,
1174  const void *msg)
1175 {
1176  struct cfg_info *ci = (struct cfg_info *)api->ipc_private_data_get (conn);
1179  int status = CS_OK;
1180 
1181  ENTER();
1182  if (!shutdown_con) {
1183  status = CS_ERR_ACCESS;
1184  goto exit_fn;
1185  }
1186 
1188  shutdown_yes++;
1189  ci->shutdown_reply = SHUTDOWN_REPLY_YES;
1190  }
1191  else {
1192  shutdown_no++;
1193  ci->shutdown_reply = SHUTDOWN_REPLY_NO;
1194  }
1195  check_shutdown_status();
1196 
1197 exit_fn:
1198  res_lib_cfg_replytoshutdown.header.error = status;
1201 
1203  sizeof(res_lib_cfg_replytoshutdown));
1204 
1205  LEAVE();
1206 }
1207 
1208 static void message_handler_req_lib_cfg_get_node_addrs (void *conn,
1209  const void *msg)
1210 {
1211  struct totem_ip_address node_ifs[INTERFACE_MAX];
1212  unsigned int iface_ids[INTERFACE_MAX];
1213  char buf[PIPE_BUF];
1214  char **status;
1215  unsigned int num_interfaces = 0;
1216  struct sockaddr_storage *ss;
1217  int ret = CS_OK;
1218  int i;
1219  int live_addrs = 0;
1222  unsigned int nodeid = req_lib_cfg_get_node_addrs->nodeid;
1223  char *addr_buf;
1224 
1225  if (nodeid == 0)
1226  nodeid = api->totem_nodeid_get();
1227 
1228  if (api->totem_ifaces_get(nodeid, iface_ids, node_ifs, INTERFACE_MAX, &status, &num_interfaces)) {
1229  ret = CS_ERR_EXIST;
1230  num_interfaces = 0;
1231  }
1232 
1233  res_lib_cfg_get_node_addrs->header.size = sizeof(struct res_lib_cfg_get_node_addrs) + (num_interfaces * TOTEMIP_ADDRLEN);
1235  res_lib_cfg_get_node_addrs->header.error = ret;
1236  if (num_interfaces) {
1237  res_lib_cfg_get_node_addrs->family = node_ifs[0].family;
1238  for (i = 0, addr_buf = (char *)res_lib_cfg_get_node_addrs->addrs;
1239  i < num_interfaces; i++) {
1240  ss = (struct sockaddr_storage *)&node_ifs[i].addr;
1241  if (ss->ss_family) {
1242  memcpy(addr_buf, node_ifs[i].addr, TOTEMIP_ADDRLEN);
1243  live_addrs++;
1244  addr_buf += TOTEMIP_ADDRLEN;
1245  }
1246  }
1247  res_lib_cfg_get_node_addrs->num_addrs = live_addrs;
1248  } else {
1250  }
1252 }
1253 
1254 static void message_handler_req_lib_cfg_local_get (void *conn, const void *msg)
1255 {
1257 
1258  res_lib_cfg_local_get.header.size = sizeof(res_lib_cfg_local_get);
1260  res_lib_cfg_local_get.header.error = CS_OK;
1261  res_lib_cfg_local_get.local_nodeid = api->totem_nodeid_get ();
1262 
1264  sizeof(res_lib_cfg_local_get));
1265 }
1266 
1267 static void message_handler_req_lib_cfg_reload_config (void *conn, const void *msg)
1268 {
1270  struct iovec iovec;
1271 
1272  ENTER();
1273 
1274  req_exec_cfg_reload_config.header.size =
1275  sizeof (struct req_exec_cfg_reload_config);
1278  api->ipc_source_set (&req_exec_cfg_reload_config.source, conn);
1279  api->ipc_refcnt_inc(conn);
1280 
1281  iovec.iov_base = (char *)&req_exec_cfg_reload_config;
1282  iovec.iov_len = sizeof (struct req_exec_cfg_reload_config);
1283 
1284  assert (api->totem_mcast (&iovec, 1, TOTEM_SAFE) == 0);
1285 
1286  LEAVE();
1287 }
1288 
1289 static void message_handler_req_lib_cfg_reopen_log_files (void *conn, const void *msg)
1290 {
1292  cs_error_t res;
1293 
1294  ENTER();
1295 
1296  log_printf(LOGSYS_LEVEL_DEBUG, "Reopening logging files\n");
1297 
1298  res = logsys_reopen_log_files();
1299 
1302  res_lib_cfg_reopen_log_files.header.error = res;
1303  api->ipc_response_send(conn,
1306 
1307  LEAVE();
1308 }
#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