38 #include <sys/types.h>
40 #include <sys/socket.h>
42 #include <netinet/in.h>
43 #include <arpa/inet.h>
54 #include <qb/qbipc_common.h>
56 #include <qb/qblist.h>
78 #define DEFAULT_SHUTDOWN_TIMEOUT 5
80 static struct qb_list_head trackers_list;
86 static struct cfg_info *shutdown_con;
87 static uint32_t shutdown_flags;
88 static int shutdown_yes;
89 static int shutdown_no;
90 static int shutdown_expected;
94 struct qb_list_head
list;
100 static void cfg_confchg_fn (
102 const unsigned int *member_list,
size_t member_list_entries,
103 const unsigned int *left_list,
size_t left_list_entries,
104 const unsigned int *joined_list,
size_t joined_list_entries,
111 static int cfg_lib_init_fn (
void *conn);
113 static int cfg_lib_exit_fn (
void *conn);
115 static void message_handler_req_exec_cfg_ringreenable (
119 static void message_handler_req_exec_cfg_killnode (
123 static void message_handler_req_exec_cfg_shutdown (
127 static void message_handler_req_exec_cfg_reload_config (
131 static void exec_cfg_killnode_endian_convert (
void *msg);
133 static void message_handler_req_lib_cfg_ringstatusget (
137 static void message_handler_req_lib_cfg_ringreenable (
141 static void message_handler_req_lib_cfg_killnode (
145 static void message_handler_req_lib_cfg_tryshutdown (
149 static void message_handler_req_lib_cfg_replytoshutdown (
153 static void message_handler_req_lib_cfg_get_node_addrs (
157 static void message_handler_req_lib_cfg_local_get (
161 static void message_handler_req_lib_cfg_reload_config (
165 static void message_handler_req_lib_cfg_reopen_log_files (
179 .lib_handler_fn = message_handler_req_lib_cfg_ringreenable,
183 .lib_handler_fn = message_handler_req_lib_cfg_killnode,
187 .lib_handler_fn = message_handler_req_lib_cfg_tryshutdown,
191 .lib_handler_fn = message_handler_req_lib_cfg_replytoshutdown,
195 .lib_handler_fn = message_handler_req_lib_cfg_get_node_addrs,
199 .lib_handler_fn = message_handler_req_lib_cfg_local_get,
203 .lib_handler_fn = message_handler_req_lib_cfg_reload_config,
207 .lib_handler_fn = message_handler_req_lib_cfg_reopen_log_files,
218 .exec_handler_fn = message_handler_req_exec_cfg_killnode,
219 .exec_endian_convert_fn = exec_cfg_killnode_endian_convert
222 .exec_handler_fn = message_handler_req_exec_cfg_shutdown,
225 .exec_handler_fn = message_handler_req_exec_cfg_reload_config,
233 .
name =
"corosync configuration service",
236 .private_data_size =
sizeof(
struct cfg_info),
239 .lib_init_fn = cfg_lib_init_fn,
240 .lib_exit_fn = cfg_lib_exit_fn,
241 .lib_engine = cfg_lib_engine,
243 .exec_init_fn = cfg_exec_init_fn,
244 .exec_engine = cfg_exec_engine,
246 .confchg_fn = cfg_confchg_fn
276 static char *cfg_exec_init_fn (
281 qb_list_init(&trackers_list);
285 static void cfg_confchg_fn (
287 const unsigned int *member_list,
size_t member_list_entries,
288 const unsigned int *left_list,
size_t left_list_entries,
289 const unsigned int *joined_list,
size_t joined_list_entries,
297 static int send_shutdown(
void)
317 static void send_test_shutdown(
void *only_conn,
void *exclude_conn,
int status)
320 struct qb_list_head *iter;
329 TRACE1(
"sending testshutdown to only %p", only_conn);
333 qb_list_for_each(iter, &trackers_list) {
336 if (ci->
conn != exclude_conn) {
346 static void check_shutdown_status(
void)
361 if (shutdown_yes + shutdown_no >= shutdown_expected) {
366 if (shutdown_yes >= shutdown_expected ||
368 TRACE1(
"shutdown confirmed");
389 TRACE1(
"shutdown cancelled");
403 shutdown_yes, shutdown_no, shutdown_flags);
412 static void shutdown_timer_fn(
void *arg)
419 shutdown_no = shutdown_expected;
420 check_shutdown_status();
426 static void remove_ci_from_shutdown(
struct cfg_info *ci)
434 if (ci == shutdown_con) {
439 if (!qb_list_empty(&ci->
list)) {
440 qb_list_del(&ci->
list);
441 qb_list_init(&ci->
list);
459 check_shutdown_status();
465 int cfg_lib_exit_fn (
void *conn)
470 remove_ci_from_shutdown(ci);
475 static int cfg_lib_init_fn (
void *
conn)
480 qb_list_init(&ci->
list);
489 static void message_handler_req_exec_cfg_ringreenable (
498 static void exec_cfg_killnode_endian_convert (
void *msg)
509 static void message_handler_req_exec_cfg_killnode (
531 static void message_handler_req_exec_cfg_shutdown (
545 static int nullcheck_strcmp(
const char* left,
const char *right)
555 return strcmp(left, right);
561 static void delete_and_notify_if_changed(
icmap_map_t temp_map,
const char *key_name)
576 static void remove_ro_entries(
icmap_map_t temp_map)
578 delete_and_notify_if_changed(temp_map,
"totem.secauth");
579 delete_and_notify_if_changed(temp_map,
"totem.crypto_hash");
580 delete_and_notify_if_changed(temp_map,
"totem.crypto_cipher");
581 delete_and_notify_if_changed(temp_map,
"totem.keyfile");
582 delete_and_notify_if_changed(temp_map,
"totem.key");
583 delete_and_notify_if_changed(temp_map,
"totem.version");
584 delete_and_notify_if_changed(temp_map,
"totem.threads");
585 delete_and_notify_if_changed(temp_map,
"totem.ip_version");
586 delete_and_notify_if_changed(temp_map,
"totem.rrp_mode");
587 delete_and_notify_if_changed(temp_map,
"totem.netmtu");
588 delete_and_notify_if_changed(temp_map,
"totem.interface.ringnumber");
589 delete_and_notify_if_changed(temp_map,
"totem.interface.bindnetaddr");
590 delete_and_notify_if_changed(temp_map,
"totem.interface.mcastaddr");
591 delete_and_notify_if_changed(temp_map,
"totem.interface.broadcast");
592 delete_and_notify_if_changed(temp_map,
"totem.interface.mcastport");
593 delete_and_notify_if_changed(temp_map,
"totem.interface.ttl");
594 delete_and_notify_if_changed(temp_map,
"totem.vsftype");
595 delete_and_notify_if_changed(temp_map,
"totem.transport");
596 delete_and_notify_if_changed(temp_map,
"totem.cluster_name");
597 delete_and_notify_if_changed(temp_map,
"quorum.provider");
598 delete_and_notify_if_changed(temp_map,
"system.move_to_root_cgroup");
599 delete_and_notify_if_changed(temp_map,
"system.sched_rr");
600 delete_and_notify_if_changed(temp_map,
"system.priority");
601 delete_and_notify_if_changed(temp_map,
"system.qb_ipc_type");
602 delete_and_notify_if_changed(temp_map,
"system.state_dir");
612 static void remove_deleted_entries(
icmap_map_t temp_map,
const char *prefix)
616 const char *old_key, *new_key;
625 while (old_key || new_key) {
626 ret = nullcheck_strcmp(old_key, new_key);
627 if ((ret < 0 && old_key) || !new_key) {
637 ret = nullcheck_strcmp(old_key, new_key);
638 }
while (ret < 0 && old_key);
640 else if ((ret > 0 && new_key) || !old_key) {
650 ret = nullcheck_strcmp(old_key, new_key);
651 }
while (ret > 0 && new_key);
665 static void message_handler_req_exec_cfg_reload_config (
672 const char *error_string;
701 remove_deleted_entries(temp_map,
"logging.");
702 remove_deleted_entries(temp_map,
"totem.");
703 remove_deleted_entries(temp_map,
"nodelist.");
704 remove_deleted_entries(temp_map,
"quorum.");
705 remove_deleted_entries(temp_map,
"uidgid.config.");
706 remove_deleted_entries(temp_map,
"nozzle.");
709 remove_ro_entries(temp_map);
745 static void message_handler_req_lib_cfg_ringstatusget (
751 unsigned int iface_count;
753 const char *totem_ip_string;
776 for (i = 0; i < iface_count; i++) {
780 if (!totem_ip_string) {
790 snprintf(ifname,
sizeof(ifname),
"%d %s", iface_ids[i], totem_ip_string);
814 static void message_handler_req_lib_cfg_ringreenable (
831 static void message_handler_req_lib_cfg_killnode (
864 static void message_handler_req_lib_cfg_tryshutdown (
870 struct qb_list_head *iter;
920 shutdown_expected = 0;
922 qb_list_for_each(iter, &trackers_list) {
936 if (shutdown_expected == 0) {
966 shutdown_timer_fn, &shutdown_timer);
971 send_test_shutdown(NULL, conn,
CS_OK);
982 static void message_handler_req_lib_cfg_replytoshutdown (
1005 check_shutdown_status();
1018 static void message_handler_req_lib_cfg_get_node_addrs (
void *conn,
1025 unsigned int num_interfaces = 0;
1026 struct sockaddr_storage *ss;
1046 if (num_interfaces) {
1049 i < num_interfaces; i++) {
1050 ss = (
struct sockaddr_storage *)&node_ifs[i].
addr;
1051 if (ss->ss_family) {
1064 static void message_handler_req_lib_cfg_local_get (
void *conn,
const void *msg)
1077 static void message_handler_req_lib_cfg_reload_config (
void *conn,
const void *msg)
1099 static void message_handler_req_lib_cfg_reopen_log_files (
void *conn,
const void *msg)