This source file includes following definitions.
- register_fsa_error_adv
- register_fsa_input_adv
- fsa_dump_queue
- copy_ha_msg_input
- delete_fsa_input
- get_message
- fsa_typed_data_adv
- do_msg_route
- route_message
- relay_message
- authorize_version
- controld_authorize_ipc_message
- handle_message
- handle_failcount_op
- handle_lrm_delete
- handle_remote_state
- create_ping_reply
- handle_ping
- handle_node_list
- handle_node_info_request
- verify_feature_set
- handle_shutdown_self_ack
- handle_shutdown_ack
- handle_request
- handle_response
- handle_shutdown_request
- send_msg_via_ipc
- delete_ha_msg_input
- broadcast_remote_state_message
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <sys/param.h>
13 #include <string.h>
14 #include <time.h>
15
16 #include <crm/crm.h>
17 #include <crm/common/xml.h>
18 #include <crm/cluster/internal.h>
19 #include <crm/cib.h>
20 #include <crm/common/ipc_internal.h>
21
22 #include <pacemaker-controld.h>
23
24 static enum crmd_fsa_input handle_message(xmlNode *msg,
25 enum crmd_fsa_cause cause);
26 static xmlNode* create_ping_reply(const xmlNode *msg);
27 static void handle_response(xmlNode *stored_msg);
28 static enum crmd_fsa_input handle_request(xmlNode *stored_msg,
29 enum crmd_fsa_cause cause);
30 static enum crmd_fsa_input handle_shutdown_request(xmlNode *stored_msg);
31 static void send_msg_via_ipc(xmlNode * msg, const char *sys, const char *src);
32
33
34 static int last_data_id = 0;
35
36 void
37 register_fsa_error_adv(enum crmd_fsa_cause cause, enum crmd_fsa_input input,
38 fsa_data_t * cur_data, void *new_data, const char *raised_from)
39 {
40
41 if (controld_globals.fsa_actions != A_NOTHING) {
42 register_fsa_input_adv(cur_data ? cur_data->fsa_cause : C_FSA_INTERNAL,
43 I_NULL, cur_data ? cur_data->data : NULL,
44 controld_globals.fsa_actions, TRUE, __func__);
45 }
46
47
48 crm_info("Resetting the current action list");
49 fsa_dump_actions(controld_globals.fsa_actions, "Drop");
50 controld_globals.fsa_actions = A_NOTHING;
51
52
53 register_fsa_input_adv(cause, input, new_data, A_NOTHING, TRUE, raised_from);
54 }
55
56 void
57 register_fsa_input_adv(enum crmd_fsa_cause cause, enum crmd_fsa_input input,
58 void *data, uint64_t with_actions,
59 gboolean prepend, const char *raised_from)
60 {
61 unsigned old_len = g_list_length(controld_globals.fsa_message_queue);
62 fsa_data_t *fsa_data = NULL;
63
64 if (raised_from == NULL) {
65 raised_from = "<unknown>";
66 }
67
68 if (input == I_NULL && with_actions == A_NOTHING ) {
69
70 crm_err("Cannot add entry to queue: no input and no action");
71 return;
72 }
73
74 if (input == I_WAIT_FOR_EVENT) {
75 controld_set_global_flags(controld_fsa_is_stalled);
76 crm_debug("Stalling the FSA pending further input: source=%s cause=%s data=%p queue=%d",
77 raised_from, fsa_cause2string(cause), data, old_len);
78
79 if (old_len > 0) {
80 fsa_dump_queue(LOG_TRACE);
81 prepend = FALSE;
82 }
83
84 if (data == NULL) {
85 controld_set_fsa_action_flags(with_actions);
86 fsa_dump_actions(with_actions, "Restored");
87 return;
88 }
89
90
91
92
93 with_actions |= controld_globals.fsa_actions;
94 controld_globals.fsa_actions = A_NOTHING;
95 }
96
97 last_data_id++;
98 crm_trace("%s %s FSA input %d (%s) due to %s, %s data",
99 raised_from, (prepend? "prepended" : "appended"), last_data_id,
100 fsa_input2string(input), fsa_cause2string(cause),
101 (data? "with" : "without"));
102
103 fsa_data = pcmk__assert_alloc(1, sizeof(fsa_data_t));
104 fsa_data->id = last_data_id;
105 fsa_data->fsa_input = input;
106 fsa_data->fsa_cause = cause;
107 fsa_data->origin = raised_from;
108 fsa_data->data = NULL;
109 fsa_data->data_type = fsa_dt_none;
110 fsa_data->actions = with_actions;
111
112 if (with_actions != A_NOTHING) {
113 crm_trace("Adding actions %.16llx to input",
114 (unsigned long long) with_actions);
115 }
116
117 if (data != NULL) {
118 switch (cause) {
119 case C_FSA_INTERNAL:
120 case C_CRMD_STATUS_CALLBACK:
121 case C_IPC_MESSAGE:
122 case C_HA_MESSAGE:
123 CRM_CHECK(((ha_msg_input_t *) data)->msg != NULL,
124 crm_err("Bogus data from %s", raised_from));
125 crm_trace("Copying %s data from %s as cluster message data",
126 fsa_cause2string(cause), raised_from);
127 fsa_data->data = copy_ha_msg_input(data);
128 fsa_data->data_type = fsa_dt_ha_msg;
129 break;
130
131 case C_LRM_OP_CALLBACK:
132 crm_trace("Copying %s data from %s as lrmd_event_data_t",
133 fsa_cause2string(cause), raised_from);
134 fsa_data->data = lrmd_copy_event((lrmd_event_data_t *) data);
135 fsa_data->data_type = fsa_dt_lrm;
136 break;
137
138 case C_TIMER_POPPED:
139 case C_SHUTDOWN:
140 case C_UNKNOWN:
141 case C_STARTUP:
142 crm_crit("Copying %s data (from %s) is not yet implemented",
143 fsa_cause2string(cause), raised_from);
144 crmd_exit(CRM_EX_SOFTWARE);
145 break;
146 }
147 }
148
149
150 if (prepend) {
151 controld_globals.fsa_message_queue
152 = g_list_prepend(controld_globals.fsa_message_queue, fsa_data);
153 } else {
154 controld_globals.fsa_message_queue
155 = g_list_append(controld_globals.fsa_message_queue, fsa_data);
156 }
157
158 crm_trace("FSA message queue length is %d",
159 g_list_length(controld_globals.fsa_message_queue));
160
161
162
163 if (old_len == g_list_length(controld_globals.fsa_message_queue)) {
164 crm_err("Couldn't add message to the queue");
165 }
166
167 if (input != I_WAIT_FOR_EVENT) {
168 controld_trigger_fsa();
169 }
170 }
171
172 void
173 fsa_dump_queue(int log_level)
174 {
175 int offset = 0;
176
177 for (GList *iter = controld_globals.fsa_message_queue; iter != NULL;
178 iter = iter->next) {
179 fsa_data_t *data = (fsa_data_t *) iter->data;
180
181 do_crm_log_unlikely(log_level,
182 "queue[%d.%d]: input %s raised by %s(%p.%d)\t(cause=%s)",
183 offset++, data->id, fsa_input2string(data->fsa_input),
184 data->origin, data->data, data->data_type,
185 fsa_cause2string(data->fsa_cause));
186 }
187 }
188
189 ha_msg_input_t *
190 copy_ha_msg_input(ha_msg_input_t * orig)
191 {
192 xmlNode *wrapper = NULL;
193
194 ha_msg_input_t *copy = pcmk__assert_alloc(1, sizeof(ha_msg_input_t));
195
196 copy->msg = (orig != NULL)? pcmk__xml_copy(NULL, orig->msg) : NULL;
197
198 wrapper = pcmk__xe_first_child(copy->msg, PCMK__XE_CRM_XML, NULL, NULL);
199 copy->xml = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);
200 return copy;
201 }
202
203 void
204 delete_fsa_input(fsa_data_t * fsa_data)
205 {
206 lrmd_event_data_t *op = NULL;
207 xmlNode *foo = NULL;
208
209 if (fsa_data == NULL) {
210 return;
211 }
212 crm_trace("About to free %s data", fsa_cause2string(fsa_data->fsa_cause));
213
214 if (fsa_data->data != NULL) {
215 switch (fsa_data->data_type) {
216 case fsa_dt_ha_msg:
217 delete_ha_msg_input(fsa_data->data);
218 break;
219
220 case fsa_dt_xml:
221 foo = fsa_data->data;
222 pcmk__xml_free(foo);
223 break;
224
225 case fsa_dt_lrm:
226 op = (lrmd_event_data_t *) fsa_data->data;
227 lrmd_free_event(op);
228 break;
229
230 case fsa_dt_none:
231 if (fsa_data->data != NULL) {
232 crm_err("Don't know how to free %s data from %s",
233 fsa_cause2string(fsa_data->fsa_cause), fsa_data->origin);
234 crmd_exit(CRM_EX_SOFTWARE);
235 }
236 break;
237 }
238 crm_trace("%s data freed", fsa_cause2string(fsa_data->fsa_cause));
239 }
240
241 free(fsa_data);
242 }
243
244
245 fsa_data_t *
246 get_message(void)
247 {
248 fsa_data_t *message
249 = (fsa_data_t *) controld_globals.fsa_message_queue->data;
250
251 controld_globals.fsa_message_queue
252 = g_list_remove(controld_globals.fsa_message_queue, message);
253 crm_trace("Processing input %d", message->id);
254 return message;
255 }
256
257 void *
258 fsa_typed_data_adv(fsa_data_t * fsa_data, enum fsa_data_type a_type, const char *caller)
259 {
260 void *ret_val = NULL;
261
262 if (fsa_data == NULL) {
263 crm_err("%s: No FSA data available", caller);
264
265 } else if (fsa_data->data == NULL) {
266 crm_err("%s: No message data available. Origin: %s", caller, fsa_data->origin);
267
268 } else if (fsa_data->data_type != a_type) {
269 crm_crit("%s: Message data was the wrong type! %d vs. requested=%d. Origin: %s",
270 caller, fsa_data->data_type, a_type, fsa_data->origin);
271 pcmk__assert(fsa_data->data_type == a_type);
272 } else {
273 ret_val = fsa_data->data;
274 }
275
276 return ret_val;
277 }
278
279
280 void
281 do_msg_route(long long action,
282 enum crmd_fsa_cause cause,
283 enum crmd_fsa_state cur_state,
284 enum crmd_fsa_input current_input, fsa_data_t * msg_data)
285 {
286 ha_msg_input_t *input = fsa_typed_data(fsa_dt_ha_msg);
287
288 route_message(msg_data->fsa_cause, input->msg);
289 }
290
291 void
292 route_message(enum crmd_fsa_cause cause, xmlNode * input)
293 {
294 ha_msg_input_t fsa_input;
295 enum crmd_fsa_input result = I_NULL;
296
297 fsa_input.msg = input;
298 CRM_CHECK(cause == C_IPC_MESSAGE || cause == C_HA_MESSAGE, return);
299
300
301 if (relay_message(input, cause == C_IPC_MESSAGE)) {
302 return;
303 }
304
305
306 result = handle_message(input, cause);
307
308
309 switch (result) {
310 case I_NULL:
311 case I_CIB_OP:
312 case I_ROUTER:
313 case I_NODE_JOIN:
314 case I_JOIN_REQUEST:
315 case I_JOIN_RESULT:
316 break;
317 default:
318
319 register_fsa_input_later(cause, result, &fsa_input);
320 return;
321 }
322
323 if (result != I_NULL) {
324
325 register_fsa_input(cause, result, &fsa_input);
326 }
327 }
328
329 gboolean
330 relay_message(xmlNode * msg, gboolean originated_locally)
331 {
332 enum pcmk_ipc_server dest = pcmk_ipc_unknown;
333 bool is_for_dc = false;
334 bool is_for_dcib = false;
335 bool is_for_te = false;
336 bool is_for_crm = false;
337 bool is_for_cib = false;
338 bool is_local = false;
339 bool broadcast = false;
340 const char *host_to = NULL;
341 const char *sys_to = NULL;
342 const char *sys_from = NULL;
343 const char *type = NULL;
344 const char *task = NULL;
345 const char *ref = NULL;
346 pcmk__node_status_t *node_to = NULL;
347
348 CRM_CHECK(msg != NULL, return TRUE);
349
350 host_to = crm_element_value(msg, PCMK__XA_CRM_HOST_TO);
351 sys_to = crm_element_value(msg, PCMK__XA_CRM_SYS_TO);
352 sys_from = crm_element_value(msg, PCMK__XA_CRM_SYS_FROM);
353 type = crm_element_value(msg, PCMK__XA_T);
354 task = crm_element_value(msg, PCMK__XA_CRM_TASK);
355 ref = crm_element_value(msg, PCMK_XA_REFERENCE);
356
357 broadcast = pcmk__str_empty(host_to);
358
359 if (ref == NULL) {
360 ref = "without reference ID";
361 }
362
363 if (pcmk__str_eq(task, CRM_OP_HELLO, pcmk__str_casei)) {
364 crm_trace("Received hello %s from %s (no processing needed)",
365 ref, pcmk__s(sys_from, "unidentified source"));
366 crm_log_xml_trace(msg, "hello");
367 return TRUE;
368 }
369
370
371 if (!pcmk__str_eq(type, PCMK__VALUE_CRMD, pcmk__str_none)) {
372 crm_warn("Ignoring invalid message %s with type '%s' "
373 "(not '" PCMK__VALUE_CRMD "')",
374 ref, pcmk__s(type, ""));
375 crm_log_xml_trace(msg, "ignored");
376 return TRUE;
377 }
378
379
380 if (sys_to == NULL) {
381 crm_warn("Ignoring invalid message %s with no " PCMK__XA_CRM_SYS_TO,
382 ref);
383 crm_log_xml_trace(msg, "ignored");
384 return TRUE;
385 }
386
387
388 if (pcmk_get_cluster_layer() == pcmk_cluster_layer_corosync) {
389 dest = pcmk__parse_server(sys_to);
390 if (dest == pcmk_ipc_unknown) {
391
392
393
394
395 dest = pcmk_ipc_controld;
396 }
397 }
398
399 is_for_dc = (strcasecmp(CRM_SYSTEM_DC, sys_to) == 0);
400 is_for_dcib = (strcasecmp(CRM_SYSTEM_DCIB, sys_to) == 0);
401 is_for_te = (strcasecmp(CRM_SYSTEM_TENGINE, sys_to) == 0);
402 is_for_cib = (strcasecmp(CRM_SYSTEM_CIB, sys_to) == 0);
403 is_for_crm = (strcasecmp(CRM_SYSTEM_CRMD, sys_to) == 0);
404
405
406 is_local = false;
407 if (broadcast) {
408 if (is_for_dc || is_for_te) {
409 is_local = false;
410
411 } else if (is_for_crm) {
412 if (pcmk__strcase_any_of(task, CRM_OP_NODE_INFO,
413 PCMK__CONTROLD_CMD_NODES, NULL)) {
414
415
416
417
418
419 is_local = true;
420 } else {
421 is_local = !originated_locally;
422 }
423
424 } else {
425 is_local = true;
426 }
427
428 } else if (controld_is_local_node(host_to)) {
429 is_local = true;
430
431 } else if (is_for_crm && pcmk__str_eq(task, CRM_OP_LRM_DELETE, pcmk__str_casei)) {
432 xmlNode *wrapper = pcmk__xe_first_child(msg, PCMK__XE_CRM_XML, NULL,
433 NULL);
434 xmlNode *msg_data = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);
435 const char *mode = crm_element_value(msg_data, PCMK__XA_MODE);
436
437 if (pcmk__str_eq(mode, PCMK__VALUE_CIB, pcmk__str_none)) {
438
439 is_local = true;
440 }
441 }
442
443
444 if (is_for_dc && pcmk__str_eq(task, CRM_OP_PING, pcmk__str_casei)
445 && (controld_globals.dc_name == NULL)) {
446
447 xmlNode *reply = create_ping_reply(msg);
448 sys_to = crm_element_value(reply, PCMK__XA_CRM_SYS_TO);
449
450 send_msg_via_ipc(reply, sys_to, NULL);
451 pcmk__xml_free(reply);
452 return TRUE;
453 }
454
455
456
457 if (is_for_dc || is_for_dcib || is_for_te) {
458 if (AM_I_DC) {
459 if (is_for_te) {
460 crm_trace("Route message %s locally as transition request",
461 ref);
462 crm_log_xml_trace(msg, sys_to);
463 send_msg_via_ipc(msg, sys_to, controld_globals.cluster->priv->node_name);
464
465 return TRUE;
466 }
467 crm_trace("Route message %s locally as DC request", ref);
468 return FALSE;
469 }
470
471 if (originated_locally
472 && !pcmk__strcase_any_of(sys_from, CRM_SYSTEM_PENGINE,
473 CRM_SYSTEM_TENGINE, NULL)) {
474 crm_trace("Relay message %s to DC (via %s)",
475 ref, pcmk__s(host_to, "broadcast"));
476 crm_log_xml_trace(msg, "relayed");
477 if (!broadcast) {
478 node_to = pcmk__get_node(0, host_to, NULL,
479 pcmk__node_search_cluster_member);
480 }
481 pcmk__cluster_send_message(node_to, dest, msg);
482 return TRUE;
483 }
484
485
486
487
488 crm_trace("Ignoring message %s because we are no longer DC", ref);
489 crm_log_xml_trace(msg, "ignored");
490 return TRUE;
491 }
492
493 if (is_local) {
494 if (is_for_crm || is_for_cib) {
495 crm_trace("Route message %s locally as controller request", ref);
496 return FALSE;
497 }
498 crm_trace("Relay message %s locally to %s", ref, sys_to);
499 crm_log_xml_trace(msg, "IPC-relay");
500 send_msg_via_ipc(msg, sys_to, controld_globals.cluster->priv->node_name);
501 return TRUE;
502 }
503
504 if (!broadcast) {
505 node_to = pcmk__search_node_caches(0, host_to,
506 pcmk__node_search_cluster_member);
507 if (node_to == NULL) {
508 crm_warn("Ignoring message %s because node %s is unknown",
509 ref, host_to);
510 crm_log_xml_trace(msg, "ignored");
511 return TRUE;
512 }
513 }
514
515 crm_trace("Relay message %s to %s",
516 ref, pcmk__s(host_to, "all peers"));
517 crm_log_xml_trace(msg, "relayed");
518 pcmk__cluster_send_message(node_to, dest, msg);
519 return TRUE;
520 }
521
522
523 static bool
524 authorize_version(xmlNode *message_data, const char *field,
525 const char *client_name, const char *ref, const char *uuid)
526 {
527 const char *version = crm_element_value(message_data, field);
528 long long version_num;
529
530 if ((pcmk__scan_ll(version, &version_num, -1LL) != pcmk_rc_ok)
531 || (version_num < 0LL)) {
532
533 crm_warn("Rejected IPC hello from %s: '%s' is not a valid protocol %s "
534 QB_XS " ref=%s uuid=%s",
535 client_name, ((version == NULL)? "" : version),
536 field, (ref? ref : "none"), uuid);
537 return false;
538 }
539 return true;
540 }
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557 bool
558 controld_authorize_ipc_message(const xmlNode *client_msg, pcmk__client_t *curr_client,
559 const char *proxy_session)
560 {
561 xmlNode *wrapper = NULL;
562 xmlNode *message_data = NULL;
563 const char *client_name = NULL;
564 const char *op = crm_element_value(client_msg, PCMK__XA_CRM_TASK);
565 const char *ref = crm_element_value(client_msg, PCMK_XA_REFERENCE);
566 const char *uuid = (curr_client? curr_client->id : proxy_session);
567
568 if (uuid == NULL) {
569 crm_warn("IPC message from client rejected: No client identifier "
570 QB_XS " ref=%s", (ref? ref : "none"));
571 goto rejected;
572 }
573
574 if (!pcmk__str_eq(CRM_OP_HELLO, op, pcmk__str_casei)) {
575
576 return true;
577 }
578
579 wrapper = pcmk__xe_first_child(client_msg, PCMK__XE_CRM_XML, NULL, NULL);
580 message_data = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);
581
582 client_name = crm_element_value(message_data, PCMK__XA_CLIENT_NAME);
583 if (pcmk__str_empty(client_name)) {
584 crm_warn("IPC hello from client rejected: No client name",
585 QB_XS " ref=%s uuid=%s", (ref? ref : "none"), uuid);
586 goto rejected;
587 }
588 if (!authorize_version(message_data, PCMK__XA_MAJOR_VERSION, client_name,
589 ref, uuid)) {
590 goto rejected;
591 }
592 if (!authorize_version(message_data, PCMK__XA_MINOR_VERSION, client_name,
593 ref, uuid)) {
594 goto rejected;
595 }
596
597 crm_trace("Validated IPC hello from client %s", client_name);
598 crm_log_xml_trace(client_msg, "hello");
599 if (curr_client) {
600 curr_client->userdata = pcmk__str_copy(client_name);
601 }
602 controld_trigger_fsa();
603 return false;
604
605 rejected:
606 crm_log_xml_trace(client_msg, "rejected");
607 if (curr_client) {
608 qb_ipcs_disconnect(curr_client->ipcs);
609 }
610 return false;
611 }
612
613 static enum crmd_fsa_input
614 handle_message(xmlNode *msg, enum crmd_fsa_cause cause)
615 {
616 const char *type = NULL;
617
618 CRM_CHECK(msg != NULL, return I_NULL);
619
620 type = crm_element_value(msg, PCMK__XA_SUBT);
621 if (pcmk__str_eq(type, PCMK__VALUE_REQUEST, pcmk__str_none)) {
622 return handle_request(msg, cause);
623 }
624
625 if (pcmk__str_eq(type, PCMK__VALUE_RESPONSE, pcmk__str_none)) {
626 handle_response(msg);
627 return I_NULL;
628 }
629
630 crm_warn("Ignoring message with unknown " PCMK__XA_SUBT" '%s'",
631 pcmk__s(type, ""));
632 crm_log_xml_trace(msg, "bad");
633 return I_NULL;
634 }
635
636 static enum crmd_fsa_input
637 handle_failcount_op(xmlNode * stored_msg)
638 {
639 const char *rsc = NULL;
640 const char *uname = NULL;
641 const char *op = NULL;
642 char *interval_spec = NULL;
643 guint interval_ms = 0;
644 gboolean is_remote_node = FALSE;
645
646 xmlNode *wrapper = pcmk__xe_first_child(stored_msg, PCMK__XE_CRM_XML, NULL,
647 NULL);
648 xmlNode *xml_op = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);
649
650 if (xml_op) {
651 xmlNode *xml_rsc = pcmk__xe_first_child(xml_op, PCMK_XE_PRIMITIVE, NULL,
652 NULL);
653 xmlNode *xml_attrs = pcmk__xe_first_child(xml_op, PCMK__XE_ATTRIBUTES,
654 NULL, NULL);
655
656 if (xml_rsc) {
657 rsc = pcmk__xe_id(xml_rsc);
658 }
659 if (xml_attrs) {
660 op = crm_element_value(xml_attrs,
661 CRM_META "_" PCMK__META_CLEAR_FAILURE_OP);
662 crm_element_value_ms(xml_attrs,
663 CRM_META "_" PCMK__META_CLEAR_FAILURE_INTERVAL,
664 &interval_ms);
665 }
666 }
667 uname = crm_element_value(xml_op, PCMK__META_ON_NODE);
668
669 if ((rsc == NULL) || (uname == NULL)) {
670 crm_log_xml_warn(stored_msg, "invalid failcount op");
671 return I_NULL;
672 }
673
674 if (crm_element_value(xml_op, PCMK__XA_ROUTER_NODE)) {
675 is_remote_node = TRUE;
676 }
677
678 crm_debug("Clearing failures for %s-interval %s on %s "
679 "from attribute manager, CIB, and executor state",
680 pcmk__readable_interval(interval_ms), rsc, uname);
681
682 if (interval_ms) {
683 interval_spec = crm_strdup_printf("%ums", interval_ms);
684 }
685 update_attrd_clear_failures(uname, rsc, op, interval_spec, is_remote_node);
686 free(interval_spec);
687
688 controld_cib_delete_last_failure(rsc, uname, op, interval_ms);
689
690 lrm_clear_last_failure(rsc, uname, op, interval_ms);
691
692 return I_NULL;
693 }
694
695 static enum crmd_fsa_input
696 handle_lrm_delete(xmlNode *stored_msg)
697 {
698 const char *mode = NULL;
699 xmlNode *wrapper = pcmk__xe_first_child(stored_msg, PCMK__XE_CRM_XML, NULL,
700 NULL);
701 xmlNode *msg_data = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);
702
703 CRM_CHECK(msg_data != NULL, return I_NULL);
704
705
706
707
708
709
710
711
712
713
714
715 mode = crm_element_value(msg_data, PCMK__XA_MODE);
716 if (!pcmk__str_eq(mode, PCMK__VALUE_CIB, pcmk__str_none)) {
717
718 crm_xml_add(stored_msg, PCMK__XA_CRM_SYS_TO, CRM_SYSTEM_LRMD);
719 return I_ROUTER;
720
721 } else {
722
723 const char *from_sys = NULL;
724 const char *user_name = NULL;
725 const char *rsc_id = NULL;
726 const char *node = NULL;
727 xmlNode *rsc_xml = NULL;
728 int rc = pcmk_rc_ok;
729
730 rsc_xml = pcmk__xe_first_child(msg_data, PCMK_XE_PRIMITIVE, NULL, NULL);
731 CRM_CHECK(rsc_xml != NULL, return I_NULL);
732
733 rsc_id = pcmk__xe_id(rsc_xml);
734 from_sys = crm_element_value(stored_msg, PCMK__XA_CRM_SYS_FROM);
735 node = crm_element_value(msg_data, PCMK__META_ON_NODE);
736 user_name = pcmk__update_acl_user(stored_msg, PCMK__XA_CRM_USER, NULL);
737 crm_debug("Handling " CRM_OP_LRM_DELETE " for %s on %s locally%s%s "
738 "(clearing CIB resource history only)", rsc_id, node,
739 (user_name? " for user " : ""), (user_name? user_name : ""));
740 rc = controld_delete_resource_history(rsc_id, node, user_name,
741 cib_dryrun|cib_sync_call);
742 if (rc == pcmk_rc_ok) {
743 rc = controld_delete_resource_history(rsc_id, node, user_name,
744 crmd_cib_smart_opt());
745 }
746
747
748
749
750 if (from_sys) {
751 lrmd_event_data_t *op = NULL;
752 const char *from_host = crm_element_value(stored_msg, PCMK__XA_SRC);
753 const char *transition;
754
755 if (strcmp(from_sys, CRM_SYSTEM_TENGINE)) {
756 transition = crm_element_value(msg_data,
757 PCMK__XA_TRANSITION_KEY);
758 } else {
759 transition = crm_element_value(stored_msg,
760 PCMK__XA_TRANSITION_KEY);
761 }
762
763 crm_info("Notifying %s on %s that %s was%s deleted",
764 from_sys, (from_host? from_host : "local node"), rsc_id,
765 ((rc == pcmk_rc_ok)? "" : " not"));
766 op = lrmd_new_event(rsc_id, PCMK_ACTION_DELETE, 0);
767 op->type = lrmd_event_exec_complete;
768 op->user_data = pcmk__str_copy(pcmk__s(transition, FAKE_TE_ID));
769 op->params = pcmk__strkey_table(free, free);
770 pcmk__insert_dup(op->params, PCMK_XA_CRM_FEATURE_SET,
771 CRM_FEATURE_SET);
772 controld_rc2event(op, rc);
773 controld_ack_event_directly(from_host, from_sys, NULL, op, rsc_id);
774 lrmd_free_event(op);
775 controld_trigger_delete_refresh(from_sys, rsc_id);
776 }
777 return I_NULL;
778 }
779 }
780
781
782
783
784
785
786
787
788 static enum crmd_fsa_input
789 handle_remote_state(const xmlNode *msg)
790 {
791 const char *conn_host = NULL;
792 const char *remote_uname = pcmk__xe_id(msg);
793 pcmk__node_status_t *remote_peer;
794 bool remote_is_up = false;
795 int rc = pcmk_rc_ok;
796
797 rc = pcmk__xe_get_bool_attr(msg, PCMK__XA_IN_CCM, &remote_is_up);
798
799 CRM_CHECK(remote_uname && rc == pcmk_rc_ok, return I_NULL);
800
801 remote_peer = pcmk__cluster_lookup_remote_node(remote_uname);
802 CRM_CHECK(remote_peer, return I_NULL);
803
804 pcmk__update_peer_state(__func__, remote_peer,
805 remote_is_up ? PCMK_VALUE_MEMBER : PCMK__VALUE_LOST,
806 0);
807
808 conn_host = crm_element_value(msg, PCMK__XA_CONNECTION_HOST);
809 if (conn_host) {
810 pcmk__str_update(&remote_peer->conn_host, conn_host);
811 } else if (remote_peer->conn_host) {
812 free(remote_peer->conn_host);
813 remote_peer->conn_host = NULL;
814 }
815
816 return I_NULL;
817 }
818
819
820
821
822
823
824
825
826 static xmlNode*
827 create_ping_reply(const xmlNode *msg)
828 {
829 const char *value = NULL;
830 xmlNode *ping = NULL;
831 xmlNode *reply = NULL;
832
833
834
835 ping = pcmk__xe_create(NULL, PCMK__XE_PING_RESPONSE);
836 value = crm_element_value(msg, PCMK__XA_CRM_SYS_TO);
837 crm_xml_add(ping, PCMK__XA_CRM_SUBSYSTEM, value);
838
839
840 value = fsa_state2string(controld_globals.fsa_state);
841 crm_xml_add(ping, PCMK__XA_CRMD_STATE, value);
842 crm_notice("Current ping state: %s", value);
843
844
845
846 crm_xml_add(ping, PCMK_XA_RESULT, "ok");
847
848 reply = pcmk__new_reply(msg, ping);
849 pcmk__xml_free(ping);
850 return reply;
851 }
852
853 static enum crmd_fsa_input
854 handle_ping(const xmlNode *msg)
855 {
856 xmlNode *reply = create_ping_reply(msg);
857 if (reply != NULL) {
858 (void) relay_message(reply, TRUE);
859 pcmk__xml_free(reply);
860 }
861
862
863 return I_NULL;
864 }
865
866
867
868
869
870
871
872
873 static enum crmd_fsa_input
874 handle_node_list(const xmlNode *request)
875 {
876 GHashTableIter iter;
877 pcmk__node_status_t *node = NULL;
878 xmlNode *reply = NULL;
879 xmlNode *reply_data = NULL;
880
881
882 reply_data = pcmk__xe_create(NULL, PCMK_XE_NODES);
883 g_hash_table_iter_init(&iter, pcmk__peer_cache);
884 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
885 xmlNode *xml = pcmk__xe_create(reply_data, PCMK_XE_NODE);
886
887 crm_xml_add_ll(xml, PCMK_XA_ID,
888 (long long) node->cluster_layer_id);
889 crm_xml_add(xml, PCMK_XA_UNAME, node->name);
890 crm_xml_add(xml, PCMK__XA_IN_CCM, node->state);
891 }
892
893
894 reply = pcmk__new_reply(request, reply_data);
895 pcmk__xml_free(reply_data);
896 if (reply) {
897 (void) relay_message(reply, TRUE);
898 pcmk__xml_free(reply);
899 }
900
901
902 return I_NULL;
903 }
904
905
906
907
908
909
910
911
912 static enum crmd_fsa_input
913 handle_node_info_request(const xmlNode *msg)
914 {
915 const char *value = NULL;
916 pcmk__node_status_t *node = NULL;
917 int node_id = 0;
918 xmlNode *reply = NULL;
919 xmlNode *reply_data = NULL;
920
921
922
923 reply_data = pcmk__xe_create(NULL, PCMK_XE_NODE);
924 crm_xml_add(reply_data, PCMK__XA_CRM_SUBSYSTEM, CRM_SYSTEM_CRMD);
925
926
927 pcmk__xe_set_bool_attr(reply_data, PCMK_XA_HAVE_QUORUM,
928 pcmk_is_set(controld_globals.flags,
929 controld_has_quorum));
930
931
932
933
934
935
936 crm_element_value_int(msg, PCMK_XA_ID, &node_id);
937 if (node_id < 0) {
938 node_id = 0;
939 }
940 value = crm_element_value(msg, PCMK_XA_UNAME);
941
942
943 if ((node_id == 0) && (value == NULL)) {
944 value = controld_globals.cluster->priv->node_name;
945 }
946
947 node = pcmk__search_node_caches(node_id, value, pcmk__node_search_any);
948 if (node) {
949 crm_xml_add(reply_data, PCMK_XA_ID, node->xml_id);
950 crm_xml_add(reply_data, PCMK_XA_UNAME, node->name);
951 crm_xml_add(reply_data, PCMK_XA_CRMD, node->state);
952 pcmk__xe_set_bool_attr(reply_data, PCMK_XA_REMOTE_NODE,
953 pcmk_is_set(node->flags,
954 pcmk__node_status_remote));
955 }
956
957
958 reply = pcmk__new_reply(msg, reply_data);
959 pcmk__xml_free(reply_data);
960 if (reply != NULL) {
961 (void) relay_message(reply, TRUE);
962 pcmk__xml_free(reply);
963 }
964
965
966 return I_NULL;
967 }
968
969 static void
970 verify_feature_set(xmlNode *msg)
971 {
972 const char *dc_version = crm_element_value(msg, PCMK_XA_CRM_FEATURE_SET);
973
974 if (dc_version == NULL) {
975
976
977
978 dc_version = "3.0.14";
979 }
980
981 if (feature_set_compatible(dc_version, CRM_FEATURE_SET)) {
982 crm_trace("Local feature set (%s) is compatible with DC's (%s)",
983 CRM_FEATURE_SET, dc_version);
984 } else {
985 crm_err("Local feature set (%s) is incompatible with DC's (%s)",
986 CRM_FEATURE_SET, dc_version);
987
988
989 controld_set_fsa_input_flags(R_STAYDOWN);
990 crmd_exit(CRM_EX_FATAL);
991 }
992 }
993
994
995 static enum crmd_fsa_input
996 handle_shutdown_self_ack(xmlNode *stored_msg)
997 {
998 const char *host_from = crm_element_value(stored_msg, PCMK__XA_SRC);
999
1000 if (pcmk_is_set(controld_globals.fsa_input_register, R_SHUTDOWN)) {
1001
1002 crm_info("Shutting down controller");
1003 return I_STOP;
1004 }
1005
1006 if (pcmk__str_eq(host_from, controld_globals.dc_name, pcmk__str_casei)) {
1007
1008 crm_err("Shutting down controller immediately due to "
1009 "unexpected shutdown confirmation");
1010 return I_TERMINATE;
1011 }
1012
1013 if (controld_globals.fsa_state != S_STOPPING) {
1014
1015 crm_err("Starting new DC election because %s is "
1016 "confirming shutdown we did not request",
1017 (host_from? host_from : "another node"));
1018 return I_ELECTION;
1019 }
1020
1021
1022 crm_debug("Ignoring unexpected shutdown confirmation from %s",
1023 (host_from? host_from : "another node"));
1024 return I_NULL;
1025 }
1026
1027
1028 static enum crmd_fsa_input
1029 handle_shutdown_ack(xmlNode *stored_msg)
1030 {
1031 const char *host_from = crm_element_value(stored_msg, PCMK__XA_SRC);
1032
1033 if (host_from == NULL) {
1034 crm_warn("Ignoring shutdown request without origin specified");
1035 return I_NULL;
1036 }
1037
1038 if (pcmk__str_eq(host_from, controld_globals.dc_name,
1039 pcmk__str_null_matches|pcmk__str_casei)) {
1040
1041 if (pcmk_is_set(controld_globals.fsa_input_register, R_SHUTDOWN)) {
1042 crm_info("Shutting down controller after confirmation from %s",
1043 host_from);
1044 } else {
1045 crm_err("Shutting down controller after unexpected "
1046 "shutdown request from %s", host_from);
1047 controld_set_fsa_input_flags(R_STAYDOWN);
1048 }
1049 return I_STOP;
1050 }
1051
1052 crm_warn("Ignoring shutdown request from %s because DC is %s",
1053 host_from, controld_globals.dc_name);
1054 return I_NULL;
1055 }
1056
1057 static enum crmd_fsa_input
1058 handle_request(xmlNode *stored_msg, enum crmd_fsa_cause cause)
1059 {
1060 xmlNode *msg = NULL;
1061 const char *op = crm_element_value(stored_msg, PCMK__XA_CRM_TASK);
1062
1063
1064
1065 crm_log_xml_trace(stored_msg, "request");
1066 if (op == NULL) {
1067 crm_warn("Ignoring request without " PCMK__XA_CRM_TASK);
1068 return I_NULL;
1069 }
1070
1071 if (strcmp(op, CRM_OP_SHUTDOWN_REQ) == 0) {
1072 const char *from = crm_element_value(stored_msg, PCMK__XA_SRC);
1073 pcmk__node_status_t *node =
1074 pcmk__search_node_caches(0, from, pcmk__node_search_cluster_member);
1075
1076 pcmk__update_peer_expected(__func__, node, CRMD_JOINSTATE_DOWN);
1077 if(AM_I_DC == FALSE) {
1078 return I_NULL;
1079 }
1080 }
1081
1082
1083 if (AM_I_DC) {
1084 if (strcmp(op, CRM_OP_JOIN_ANNOUNCE) == 0) {
1085 return I_NODE_JOIN;
1086
1087 } else if (strcmp(op, CRM_OP_JOIN_REQUEST) == 0) {
1088 return I_JOIN_REQUEST;
1089
1090 } else if (strcmp(op, CRM_OP_JOIN_CONFIRM) == 0) {
1091 return I_JOIN_RESULT;
1092
1093 } else if (strcmp(op, CRM_OP_SHUTDOWN) == 0) {
1094 return handle_shutdown_self_ack(stored_msg);
1095
1096 } else if (strcmp(op, CRM_OP_SHUTDOWN_REQ) == 0) {
1097
1098 return handle_shutdown_request(stored_msg);
1099 }
1100 }
1101
1102
1103 if (strcmp(op, CRM_OP_NOVOTE) == 0) {
1104 ha_msg_input_t fsa_input;
1105
1106 fsa_input.msg = stored_msg;
1107 register_fsa_input_adv(C_HA_MESSAGE, I_NULL, &fsa_input,
1108 A_ELECTION_COUNT | A_ELECTION_CHECK, FALSE,
1109 __func__);
1110
1111 } else if (strcmp(op, CRM_OP_REMOTE_STATE) == 0) {
1112
1113 return handle_remote_state(stored_msg);
1114
1115 } else if (strcmp(op, CRM_OP_THROTTLE) == 0) {
1116 throttle_update(stored_msg);
1117 if (AM_I_DC && (controld_globals.transition_graph != NULL)
1118 && !controld_globals.transition_graph->complete) {
1119
1120 crm_debug("The throttle changed. Trigger a graph.");
1121 trigger_graph();
1122 }
1123 return I_NULL;
1124
1125 } else if (strcmp(op, CRM_OP_CLEAR_FAILCOUNT) == 0) {
1126 return handle_failcount_op(stored_msg);
1127
1128 } else if (strcmp(op, CRM_OP_VOTE) == 0) {
1129
1130 ha_msg_input_t fsa_input;
1131
1132 fsa_input.msg = stored_msg;
1133 register_fsa_input_adv(C_HA_MESSAGE, I_NULL, &fsa_input,
1134 A_ELECTION_COUNT | A_ELECTION_CHECK, FALSE,
1135 __func__);
1136
1137
1138 if (controld_globals.fsa_state == S_HALT) {
1139 crm_debug("Forcing an election from S_HALT");
1140 return I_ELECTION;
1141 }
1142
1143 } else if (strcmp(op, CRM_OP_JOIN_OFFER) == 0) {
1144 verify_feature_set(stored_msg);
1145 crm_debug("Raising I_JOIN_OFFER: join-%s",
1146 crm_element_value(stored_msg, PCMK__XA_JOIN_ID));
1147 return I_JOIN_OFFER;
1148
1149 } else if (strcmp(op, CRM_OP_JOIN_ACKNAK) == 0) {
1150 crm_debug("Raising I_JOIN_RESULT: join-%s",
1151 crm_element_value(stored_msg, PCMK__XA_JOIN_ID));
1152 return I_JOIN_RESULT;
1153
1154 } else if (strcmp(op, CRM_OP_LRM_DELETE) == 0) {
1155 return handle_lrm_delete(stored_msg);
1156
1157 } else if ((strcmp(op, CRM_OP_LRM_FAIL) == 0)
1158 || (strcmp(op, CRM_OP_REPROBE) == 0)) {
1159
1160 crm_xml_add(stored_msg, PCMK__XA_CRM_SYS_TO, CRM_SYSTEM_LRMD);
1161 return I_ROUTER;
1162
1163 } else if (strcmp(op, CRM_OP_NOOP) == 0) {
1164 return I_NULL;
1165
1166 } else if (strcmp(op, CRM_OP_PING) == 0) {
1167 return handle_ping(stored_msg);
1168
1169 } else if (strcmp(op, CRM_OP_NODE_INFO) == 0) {
1170 return handle_node_info_request(stored_msg);
1171
1172 } else if (strcmp(op, CRM_OP_RM_NODE_CACHE) == 0) {
1173 int id = 0;
1174 const char *name = NULL;
1175
1176 crm_element_value_int(stored_msg, PCMK_XA_ID, &id);
1177 name = crm_element_value(stored_msg, PCMK_XA_UNAME);
1178
1179 if(cause == C_IPC_MESSAGE) {
1180 msg = pcmk__new_request(pcmk_ipc_controld, CRM_SYSTEM_CRMD, NULL,
1181 CRM_SYSTEM_CRMD, CRM_OP_RM_NODE_CACHE,
1182 NULL);
1183 if (!pcmk__cluster_send_message(NULL, pcmk_ipc_controld, msg)) {
1184 crm_err("Could not instruct peers to remove references to node %s/%u", name, id);
1185 } else {
1186 crm_notice("Instructing peers to remove references to node %s/%u", name, id);
1187 }
1188 pcmk__xml_free(msg);
1189
1190 } else {
1191 pcmk__cluster_forget_cluster_node(id, name);
1192
1193
1194
1195
1196
1197 st_fail_count_reset(name);
1198 }
1199
1200 } else if (strcmp(op, CRM_OP_MAINTENANCE_NODES) == 0) {
1201 xmlNode *wrapper = pcmk__xe_first_child(stored_msg, PCMK__XE_CRM_XML,
1202 NULL, NULL);
1203 xmlNode *xml = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);
1204
1205 remote_ra_process_maintenance_nodes(xml);
1206
1207 } else if (strcmp(op, PCMK__CONTROLD_CMD_NODES) == 0) {
1208 return handle_node_list(stored_msg);
1209
1210
1211 } else if (!AM_I_DC) {
1212
1213 if (strcmp(op, CRM_OP_SHUTDOWN) == 0) {
1214 return handle_shutdown_ack(stored_msg);
1215 }
1216
1217 } else {
1218 crm_err("Unexpected request (%s) sent to %s", op, AM_I_DC ? "the DC" : "non-DC node");
1219 crm_log_xml_err(stored_msg, "Unexpected");
1220 }
1221
1222 return I_NULL;
1223 }
1224
1225 static void
1226 handle_response(xmlNode *stored_msg)
1227 {
1228 const char *op = crm_element_value(stored_msg, PCMK__XA_CRM_TASK);
1229
1230 crm_log_xml_trace(stored_msg, "reply");
1231 if (op == NULL) {
1232 crm_warn("Ignoring reply without " PCMK__XA_CRM_TASK);
1233
1234 } else if (AM_I_DC && strcmp(op, CRM_OP_PECALC) == 0) {
1235
1236 const char *msg_ref = crm_element_value(stored_msg, PCMK_XA_REFERENCE);
1237
1238 if (msg_ref == NULL) {
1239 crm_err("%s - Ignoring calculation with no reference", op);
1240
1241 } else if (pcmk__str_eq(msg_ref, controld_globals.fsa_pe_ref,
1242 pcmk__str_none)) {
1243 ha_msg_input_t fsa_input;
1244
1245 controld_stop_sched_timer();
1246 fsa_input.msg = stored_msg;
1247 register_fsa_input_later(C_IPC_MESSAGE, I_PE_SUCCESS, &fsa_input);
1248
1249 } else {
1250 crm_info("%s calculation %s is obsolete", op, msg_ref);
1251 }
1252
1253 } else if (strcmp(op, CRM_OP_VOTE) == 0
1254 || strcmp(op, CRM_OP_SHUTDOWN_REQ) == 0 || strcmp(op, CRM_OP_SHUTDOWN) == 0) {
1255
1256 } else {
1257 const char *host_from = crm_element_value(stored_msg, PCMK__XA_SRC);
1258
1259 crm_err("Unexpected response (op=%s, src=%s) sent to the %s",
1260 op, host_from, AM_I_DC ? "DC" : "controller");
1261 }
1262 }
1263
1264 static enum crmd_fsa_input
1265 handle_shutdown_request(xmlNode * stored_msg)
1266 {
1267
1268
1269
1270
1271
1272
1273
1274 char *now_s = NULL;
1275 const char *host_from = crm_element_value(stored_msg, PCMK__XA_SRC);
1276
1277 if (host_from == NULL) {
1278
1279 host_from = controld_globals.cluster->priv->node_name;
1280 }
1281
1282 crm_info("Creating shutdown request for %s (state=%s)", host_from,
1283 fsa_state2string(controld_globals.fsa_state));
1284 crm_log_xml_trace(stored_msg, "message");
1285
1286 now_s = pcmk__ttoa(time(NULL));
1287 update_attrd(host_from, PCMK__NODE_ATTR_SHUTDOWN, now_s, NULL, FALSE);
1288 free(now_s);
1289
1290
1291 return I_NULL;
1292 }
1293
1294 static void
1295 send_msg_via_ipc(xmlNode * msg, const char *sys, const char *src)
1296 {
1297 pcmk__client_t *client_channel = NULL;
1298
1299 CRM_CHECK(sys != NULL, return);
1300
1301 client_channel = pcmk__find_client_by_id(sys);
1302
1303 if (crm_element_value(msg, PCMK__XA_SRC) == NULL) {
1304 crm_xml_add(msg, PCMK__XA_SRC, src);
1305 }
1306
1307 if (client_channel != NULL) {
1308
1309 pcmk__ipc_send_xml(client_channel, 0, msg, crm_ipc_server_event);
1310
1311 } else if (pcmk__str_eq(sys, CRM_SYSTEM_TENGINE, pcmk__str_none)) {
1312 xmlNode *wrapper = pcmk__xe_first_child(msg, PCMK__XE_CRM_XML, NULL,
1313 NULL);
1314 xmlNode *data = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);
1315
1316 process_te_message(msg, data);
1317
1318 } else if (pcmk__str_eq(sys, CRM_SYSTEM_LRMD, pcmk__str_none)) {
1319 fsa_data_t fsa_data;
1320 ha_msg_input_t fsa_input;
1321 xmlNode *wrapper = NULL;
1322
1323 fsa_input.msg = msg;
1324
1325 wrapper = pcmk__xe_first_child(msg, PCMK__XE_CRM_XML, NULL, NULL);
1326 fsa_input.xml = pcmk__xe_first_child(wrapper, NULL, NULL, NULL);
1327
1328 fsa_data.id = 0;
1329 fsa_data.actions = 0;
1330 fsa_data.data = &fsa_input;
1331 fsa_data.fsa_input = I_MESSAGE;
1332 fsa_data.fsa_cause = C_IPC_MESSAGE;
1333 fsa_data.origin = __func__;
1334 fsa_data.data_type = fsa_dt_ha_msg;
1335
1336 do_lrm_invoke(A_LRM_INVOKE, C_IPC_MESSAGE, controld_globals.fsa_state,
1337 I_MESSAGE, &fsa_data);
1338
1339 } else if (crmd_is_proxy_session(sys)) {
1340 crmd_proxy_send(sys, msg);
1341
1342 } else {
1343 crm_info("Received invalid request: unknown subsystem '%s'", sys);
1344 }
1345 }
1346
1347 void
1348 delete_ha_msg_input(ha_msg_input_t * orig)
1349 {
1350 if (orig == NULL) {
1351 return;
1352 }
1353 pcmk__xml_free(orig->msg);
1354 free(orig);
1355 }
1356
1357
1358
1359
1360
1361
1362
1363
1364 void
1365 broadcast_remote_state_message(const char *node_name, bool node_up)
1366 {
1367 xmlNode *msg = pcmk__new_request(pcmk_ipc_controld, CRM_SYSTEM_CRMD, NULL,
1368 CRM_SYSTEM_CRMD, CRM_OP_REMOTE_STATE,
1369 NULL);
1370
1371 crm_info("Notifying cluster of Pacemaker Remote node %s %s",
1372 node_name, node_up? "coming up" : "going down");
1373
1374 crm_xml_add(msg, PCMK_XA_ID, node_name);
1375 pcmk__xe_set_bool_attr(msg, PCMK__XA_IN_CCM, node_up);
1376
1377 if (node_up) {
1378 crm_xml_add(msg, PCMK__XA_CONNECTION_HOST,
1379 controld_globals.cluster->priv->node_name);
1380 }
1381
1382 pcmk__cluster_send_message(NULL, pcmk_ipc_controld, msg);
1383 pcmk__xml_free(msg);
1384 }
1385