38 #include <sys/types.h>
40 #include <sys/socket.h>
42 #include <netinet/in.h>
43 #include <arpa/inet.h>
55 #include <qb/qbipc_common.h>
57 #include <qb/qblist.h>
81 #define DEFAULT_SHUTDOWN_TIMEOUT 5
83 static struct qb_list_head trackers_list;
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;
97 struct qb_list_head
list;
103 static void cfg_confchg_fn (
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,
114 static int cfg_lib_init_fn (
void *conn);
116 static int cfg_lib_exit_fn (
void *conn);
118 static void message_handler_req_exec_cfg_ringreenable (
122 static void message_handler_req_exec_cfg_killnode (
126 static void message_handler_req_exec_cfg_shutdown (
130 static void message_handler_req_exec_cfg_reload_config (
134 static void message_handler_req_exec_cfg_reconfig_crypto (
138 static void exec_cfg_killnode_endian_convert (
void *msg);
140 static void message_handler_req_lib_cfg_ringstatusget (
144 static void message_handler_req_lib_cfg_ringreenable (
148 static void message_handler_req_lib_cfg_killnode (
152 static void message_handler_req_lib_cfg_tryshutdown (
156 static void message_handler_req_lib_cfg_replytoshutdown (
160 static void message_handler_req_lib_cfg_get_node_addrs (
164 static void message_handler_req_lib_cfg_local_get (
168 static void message_handler_req_lib_cfg_reload_config (
172 static void message_handler_req_lib_cfg_reopen_log_files (
186 .lib_handler_fn = message_handler_req_lib_cfg_ringreenable,
190 .lib_handler_fn = message_handler_req_lib_cfg_killnode,
194 .lib_handler_fn = message_handler_req_lib_cfg_tryshutdown,
198 .lib_handler_fn = message_handler_req_lib_cfg_replytoshutdown,
202 .lib_handler_fn = message_handler_req_lib_cfg_get_node_addrs,
206 .lib_handler_fn = message_handler_req_lib_cfg_local_get,
210 .lib_handler_fn = message_handler_req_lib_cfg_reload_config,
214 .lib_handler_fn = message_handler_req_lib_cfg_reopen_log_files,
225 .exec_handler_fn = message_handler_req_exec_cfg_killnode,
226 .exec_endian_convert_fn = exec_cfg_killnode_endian_convert
229 .exec_handler_fn = message_handler_req_exec_cfg_shutdown,
232 .exec_handler_fn = message_handler_req_exec_cfg_reload_config,
235 .exec_handler_fn = message_handler_req_exec_cfg_reconfig_crypto,
243 .
name =
"corosync configuration service",
246 .private_data_size =
sizeof(
struct cfg_info),
249 .lib_init_fn = cfg_lib_init_fn,
250 .lib_exit_fn = cfg_lib_exit_fn,
251 .lib_engine = cfg_lib_engine,
253 .exec_init_fn = cfg_exec_init_fn,
254 .exec_engine = cfg_exec_engine,
256 .confchg_fn = cfg_confchg_fn
291 static char *cfg_exec_init_fn (
296 qb_list_init(&trackers_list);
300 static void cfg_confchg_fn (
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,
312 static int send_shutdown(
void)
332 static void send_test_shutdown(
void *only_conn,
void *exclude_conn,
int status)
335 struct qb_list_head *iter;
344 TRACE1(
"sending testshutdown to only %p", only_conn);
348 qb_list_for_each(iter, &trackers_list) {
351 if (ci->
conn != exclude_conn) {
361 static void check_shutdown_status(
void)
376 if (shutdown_yes + shutdown_no >= shutdown_expected) {
381 if (shutdown_yes >= shutdown_expected ||
383 TRACE1(
"shutdown confirmed");
404 TRACE1(
"shutdown cancelled");
418 shutdown_yes, shutdown_no, shutdown_flags);
427 static void shutdown_timer_fn(
void *arg)
434 shutdown_no = shutdown_expected;
435 check_shutdown_status();
441 static void remove_ci_from_shutdown(
struct cfg_info *ci)
449 if (ci == shutdown_con) {
454 if (!qb_list_empty(&ci->
list)) {
455 qb_list_del(&ci->
list);
456 qb_list_init(&ci->
list);
474 check_shutdown_status();
480 int cfg_lib_exit_fn (
void *conn)
485 remove_ci_from_shutdown(ci);
490 static int cfg_lib_init_fn (
void *
conn)
495 qb_list_init(&ci->
list);
504 static void message_handler_req_exec_cfg_ringreenable (
513 static void exec_cfg_killnode_endian_convert (
void *msg)
524 static void message_handler_req_exec_cfg_killnode (
546 static void message_handler_req_exec_cfg_shutdown (
560 static int nullcheck_strcmp(
const char* left,
const char *right)
570 return strcmp(left, right);
576 static void delete_and_notify_if_changed(
icmap_map_t temp_map,
const char *key_name)
591 static void remove_ro_entries(
icmap_map_t temp_map)
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");
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");
629 static void remove_deleted_entries(
icmap_map_t temp_map,
const char *prefix)
633 const char *old_key, *new_key;
642 while (old_key || new_key) {
643 ret = nullcheck_strcmp(old_key, new_key);
644 if ((ret < 0 && old_key) || !new_key) {
654 ret = nullcheck_strcmp(old_key, new_key);
655 }
while (ret < 0 && old_key);
657 else if ((ret > 0 && new_key) || !old_key) {
667 ret = nullcheck_strcmp(old_key, new_key);
668 }
while (ret > 0 && new_key);
682 static void message_handler_req_exec_cfg_reload_config (
690 const char *error_string;
700 memset(&new_config, 0,
sizeof(new_config));
706 goto reload_fini_nomap;
716 goto reload_fini_nofree;
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.");
731 remove_ro_entries(temp_map);
734 memset(&new_config, 0,
sizeof(new_config));
736 assert(new_config.orig_interfaces != NULL);
739 new_config.crypto_changed = 0;
742 assert(new_config.interfaces != NULL);
749 memcpy(&new_config.interfaces[0], &new_config.orig_interfaces[0],
778 if (new_config.crypto_changed) {
779 #ifndef HAVE_KNET_CRYPTO_RECONF
780 new_config.crypto_changed = 0;
799 free(new_config.interfaces);
808 free(new_config.orig_interfaces);
819 if (new_config.crypto_changed) {
856 static void message_handler_req_exec_cfg_reconfig_crypto (
874 req_exec_cfg_crypto_reconfig2.header.size =
880 iovec.iov_base = (
char *)&req_exec_cfg_crypto_reconfig2;
892 static void message_handler_req_lib_cfg_ringstatusget (
898 unsigned int iface_count;
900 const char *totem_ip_string;
923 for (i = 0; i < iface_count; i++) {
927 if (!totem_ip_string) {
937 snprintf(ifname,
sizeof(ifname),
"%d %s", iface_ids[i], totem_ip_string);
961 static void message_handler_req_lib_cfg_ringreenable (
978 static void message_handler_req_lib_cfg_killnode (
990 const char *iter_key;
992 char *status_str = NULL;
993 int match_nodeid_flag = 0;
1001 if (sscanf(iter_key,
"runtime.members.%u.%s", &
nodeid, key_name) != 2) {
1004 if (strcmp(key_name,
"status") != 0) {
1010 match_nodeid_flag = 1;
1016 if (strcmp(status_str,
"joined") != 0) {
1023 if (!match_nodeid_flag) {
1054 static void message_handler_req_lib_cfg_tryshutdown (
1060 struct qb_list_head *iter;
1110 shutdown_expected = 0;
1112 qb_list_for_each(iter, &trackers_list) {
1119 shutdown_expected++;
1126 if (shutdown_expected == 0) {
1156 shutdown_timer_fn, &shutdown_timer);
1161 send_test_shutdown(NULL, conn,
CS_OK);
1172 static void message_handler_req_lib_cfg_replytoshutdown (
1182 if (!shutdown_con) {
1195 check_shutdown_status();
1208 static void message_handler_req_lib_cfg_get_node_addrs (
void *conn,
1215 unsigned int num_interfaces = 0;
1216 struct sockaddr_storage *ss;
1236 if (num_interfaces) {
1239 i < num_interfaces; i++) {
1240 ss = (
struct sockaddr_storage *)&node_ifs[i].
addr;
1241 if (ss->ss_family) {
1254 static void message_handler_req_lib_cfg_local_get (
void *conn,
const void *msg)
1267 static void message_handler_req_lib_cfg_reload_config (
void *conn,
const void *msg)
1289 static void message_handler_req_lib_cfg_reopen_log_files (
void *conn,
const void *msg)
#define SERVICE_ID_MAKE(a, b)
totem_configuration_type
The totem_configuration_type enum.
qb_loop_timer_handle corosync_timer_handle_t
corosync_timer_handle_t
#define corosync_fatal_error(err)
unsigned char addr[TOTEMIP_ADDRLEN]
@ CS_LIB_FLOW_CONTROL_REQUIRED
@ CS_LIB_FLOW_CONTROL_NOT_REQUIRED
@ COROSYNC_FATAL_ERROR_EXIT
int coroparse_configparse(icmap_map_t config_map, const char **error_string)
cs_error_t
The cs_error_t enum.
struct corosync_service_engine * cfg_get_service_engine_ver0(void)
struct corosync_service_engine cfg_service_engine
@ MESSAGE_REQ_EXEC_CFG_RELOAD_CONFIG
@ MESSAGE_REQ_EXEC_CFG_SHUTDOWN
@ MESSAGE_REQ_EXEC_CFG_RINGREENABLE
@ MESSAGE_REQ_EXEC_CFG_KILLNODE
@ MESSAGE_REQ_EXEC_CFG_CRYPTO_RECONFIG
LOGSYS_DECLARE_SUBSYS("CFG")
#define DEFAULT_SHUTDOWN_TIMEOUT
icmap_iter_t icmap_iter_init_r(const icmap_map_t map, const char *prefix)
icmap_iter_init_r
cs_error_t icmap_get_string_r(const icmap_map_t map, const char *key_name, char **str)
cs_error_t icmap_get_uint32(const char *key_name, uint32_t *u32)
cs_error_t icmap_set_uint8(const char *key_name, uint8_t value)
cs_error_t icmap_delete(const char *key_name)
Delete key from map.
cs_error_t icmap_set_int32(const char *key_name, int32_t value)
cs_error_t icmap_delete_r(const icmap_map_t map, const char *key_name)
icmap_delete_r
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.
icmap_iter_t icmap_iter_init(const char *prefix)
Initialize iterator with given prefix.
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.
cs_error_t icmap_init_r(icmap_map_t *result)
Initialize additional (local, reentrant) icmap_map.
const char * icmap_iter_next(icmap_iter_t iter, size_t *value_len, icmap_value_types_t *type)
Return next item in iterator iter.
icmap_map_t icmap_get_global_map(void)
Return global icmap.
qb_map_iter_t * icmap_iter_t
Itterator type.
void icmap_iter_finalize(icmap_iter_t iter)
Finalize iterator.
void icmap_fini_r(const icmap_map_t map)
Finalize local, reentrant icmap.
#define ICMAP_KEYNAME_MAXLEN
Maximum length of key in icmap.
@ CFG_SHUTDOWN_FLAG_REGARDLESS
@ CFG_SHUTDOWN_FLAG_IMMEDIATE
#define CFG_INTERFACE_STATUS_MAX_LEN
#define CFG_INTERFACE_NAME_MAX_LEN
@ MESSAGE_RES_CFG_LOCAL_GET
@ MESSAGE_RES_CFG_RELOAD_CONFIG
@ MESSAGE_RES_CFG_RINGSTATUSGET
@ MESSAGE_RES_CFG_TRYSHUTDOWN
@ MESSAGE_RES_CFG_GET_NODE_ADDRS
@ MESSAGE_RES_CFG_REOPEN_LOG_FILES
@ MESSAGE_RES_CFG_TESTSHUTDOWN
@ MESSAGE_RES_CFG_KILLNODE
@ MESSAGE_RES_CFG_REPLYTOSHUTDOWN
@ MESSAGE_RES_CFG_RINGREENABLE
#define CFG_MAX_INTERFACES
#define LOGSYS_LEVEL_ERROR
#define log_printf(level, format, args...)
#define LOGSYS_LEVEL_NOTICE
#define TRACE1(format, args...)
cs_error_t logsys_reopen_log_files(void)
#define LOGSYS_LEVEL_DEBUG
enum cfg_info::@8 shutdown_reply
The corosync_api_v1 struct.
int(* timer_add_duration)(unsigned long long nanoseconds_in_future, void *data, void(*timer_nf)(void *data), corosync_timer_handle_t *handle)
int(* totem_mcast)(const struct iovec *iovec, unsigned int iov_len, unsigned int guarantee)
void(* timer_delete)(corosync_timer_handle_t timer_handle)
unsigned int(* totem_nodeid_get)(void)
void(* ipc_refcnt_dec)(void *conn)
void(* ipc_source_set)(mar_message_source_t *source, void *conn)
void(* shutdown_request)(void)
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)
void(* ipc_refcnt_inc)(void *conn)
int(* ipc_dispatch_send)(void *conn, const void *msg, size_t mlen)
const char *(* totem_ip_print)(const struct totem_ip_address *addr)
int(* ipc_response_send)(void *conn, const void *msg, size_t mlen)
void *(* ipc_private_data_get)(void *conn)
The corosync_exec_handler struct.
void(* exec_handler_fn)(const void *msg, unsigned int nodeid)
The corosync_lib_handler struct.
void(* lib_handler_fn)(void *conn, const void *msg)
The corosync_service_engine struct.
uint8_t value[CS_MAX_NAME_LENGTH]
The mar_message_source_t struct.
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.
The req_lib_cfg_killnode struct.
The req_lib_cfg_replytoshutdown struct.
The req_lib_cfg_tryshutdown struct.
The res_lib_cfg_get_node_addrs struct.
The res_lib_cfg_killnode struct.
The res_lib_cfg_local_get struct.
The res_lib_cfg_reload_config struct.
The res_lib_cfg_reopen_log_files struct.
The res_lib_cfg_replytoshutdown struct.
The res_lib_cfg_ringreenable struct.
The res_lib_cfg_ringstatusget struct.
The res_lib_cfg_testshutdown struct.
The res_lib_cfg_tryshutdown struct.
The totem_ip_address struct.
@ CRYPTO_RECONFIG_PHASE_CLEANUP
@ CRYPTO_RECONFIG_PHASE_ACTIVATE
void totem_volatile_config_read(struct totem_config *totem_config, icmap_map_t temp_map, const char *deleted_key)
void totemconfig_commit_new_params(struct totem_config *totem_config, icmap_map_t map)
int totem_volatile_config_validate(struct totem_config *totem_config, icmap_map_t temp_map, const char **error_string)
int totem_reread_crypto_config(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
int totemconfig_configure_new_params(struct totem_config *totem_config, icmap_map_t map, const char **error_string)
void totempg_get_config(struct totem_config *config)
void totempg_put_config(struct totem_config *config)
int totempg_crypto_reconfigure_phase(cfg_message_crypto_reconfig_phase_t phase)
struct memb_ring_id ring_id
struct totem_message_header header