corosync  3.1.0
lib/cfg.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2005 MontaVista Software, Inc.
3  * Copyright (c) 2006-2020 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 <stdio.h>
39 #include <string.h>
40 #include <stdlib.h>
41 #include <unistd.h>
42 #include <errno.h>
43 #include <pthread.h>
44 #include <limits.h>
45 #include <sys/types.h>
46 #include <sys/socket.h>
47 #include <sys/select.h>
48 #include <sys/un.h>
49 #include <sys/uio.h>
50 
51 #include <qb/qbipcc.h>
52 
53 #include <corosync/corotypes.h>
54 #include <corosync/corodefs.h>
55 #include <corosync/hdb.h>
56 
57 #include <corosync/cfg.h>
58 #include <corosync/ipc_cfg.h>
59 
60 #include "util.h"
61 
62 /*
63  * Data structure for instance data
64  */
65 struct cfg_inst {
66  qb_ipcc_connection_t *c;
70  int finalize;
71 };
72 
73 /*
74  * All instances in one database
75  */
76 static void cfg_inst_free (void *inst);
77 
78 DECLARE_HDB_DATABASE (cfg_hdb, cfg_inst_free);
79 
80 /*
81  * Implementation
82  */
83 
86  corosync_cfg_handle_t *cfg_handle,
87  const corosync_cfg_callbacks_t *cfg_callbacks)
88 {
89  struct cfg_inst *cfg_inst;
90  cs_error_t error = CS_OK;
91 
92  error = hdb_error_to_cs (hdb_handle_create (&cfg_hdb, sizeof (struct cfg_inst), cfg_handle));
93  if (error != CS_OK) {
94  goto error_no_destroy;
95  }
96 
97  error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, *cfg_handle, (void *)&cfg_inst));
98  if (error != CS_OK) {
99  goto error_destroy;
100  }
101 
102  cfg_inst->finalize = 0;
103  cfg_inst->c = qb_ipcc_connect ("cfg", IPC_REQUEST_SIZE);
104  if (cfg_inst->c == NULL) {
105  error = qb_to_cs_error(-errno);
106  goto error_put_destroy;
107  }
108 
109  if (cfg_callbacks) {
110  memcpy (&cfg_inst->callbacks, cfg_callbacks, sizeof (corosync_cfg_callbacks_t));
111  }
112 
113  (void)hdb_handle_put (&cfg_hdb, *cfg_handle);
114 
115  return (CS_OK);
116 
117 error_put_destroy:
118  (void)hdb_handle_put (&cfg_hdb, *cfg_handle);
119 error_destroy:
120  (void)hdb_handle_destroy (&cfg_hdb, *cfg_handle);
121 error_no_destroy:
122  return (error);
123 }
124 
127  corosync_cfg_handle_t cfg_handle,
128  int32_t *selection_fd)
129 {
130  struct cfg_inst *cfg_inst;
131  cs_error_t error;
132 
133  error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
134  if (error != CS_OK) {
135  return (error);
136  }
137 
138  error = qb_to_cs_error (qb_ipcc_fd_get (cfg_inst->c, selection_fd));
139 
140  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
141  return (error);
142 }
143 
146  corosync_cfg_handle_t cfg_handle,
147  cs_dispatch_flags_t dispatch_flags)
148 {
149  int timeout = -1;
150  cs_error_t error;
151  int cont = 1; /* always continue do loop except when set to 0 */
152  struct cfg_inst *cfg_inst;
155  struct qb_ipc_response_header *dispatch_data;
156  char dispatch_buf[IPC_DISPATCH_SIZE];
157 
158  error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
159  (void *)&cfg_inst));
160  if (error != CS_OK) {
161  return (error);
162  }
163 
164  /*
165  * Timeout instantly for CS_DISPATCH_ONE_NONBLOCKING or CS_DISPATCH_ALL and
166  * wait indefinately for CS_DISPATCH_ONE or CS_DISPATCH_BLOCKING
167  */
168  if (dispatch_flags == CS_DISPATCH_ALL || dispatch_flags == CS_DISPATCH_ONE_NONBLOCKING) {
169  timeout = 0;
170  }
171 
172  dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
173  do {
174  error = qb_to_cs_error (qb_ipcc_event_recv (
175  cfg_inst->c,
176  dispatch_buf,
178  timeout));
179  if (error == CS_ERR_BAD_HANDLE) {
180  error = CS_OK;
181  goto error_put;
182  }
183  if (error == CS_ERR_TRY_AGAIN) {
184  if (dispatch_flags == CS_DISPATCH_ONE_NONBLOCKING) {
185  /*
186  * Don't mask error
187  */
188  goto error_put;
189  }
190  error = CS_OK;
191  if (dispatch_flags == CS_DISPATCH_ALL) {
192  break; /* exit do while cont is 1 loop */
193  } else {
194  continue; /* next poll */
195  }
196  }
197  if (error != CS_OK) {
198  goto error_put;
199  }
200 
201  /*
202  * Make copy of callbacks, message data, unlock instance, and call callback
203  * A risk of this dispatch method is that the callback routines may
204  * operate at the same time that cfgFinalize has been called in another thread.
205  */
206  memcpy (&callbacks, &cfg_inst->callbacks, sizeof (corosync_cfg_callbacks_t));
207 
208  /*
209  * Dispatch incoming response
210  */
211  switch (dispatch_data->id) {
213  if (callbacks.corosync_cfg_shutdown_callback == NULL) {
214  break;
215  }
216 
217  res_lib_cfg_testshutdown = (struct res_lib_cfg_testshutdown *)dispatch_data;
218  callbacks.corosync_cfg_shutdown_callback(cfg_handle, res_lib_cfg_testshutdown->flags);
219  break;
220  default:
221  error = CS_ERR_LIBRARY;
222  goto error_nounlock;
223  break;
224  }
225  if (cfg_inst->finalize) {
226  /*
227  * If the finalize has been called then get out of the dispatch.
228  */
229  error = CS_ERR_BAD_HANDLE;
230  goto error_put;
231  }
232 
233  /*
234  * Determine if more messages should be processed
235  */
236  if (dispatch_flags == CS_DISPATCH_ONE || dispatch_flags == CS_DISPATCH_ONE_NONBLOCKING) {
237  cont = 0;
238  }
239  } while (cont);
240 
241 error_put:
242  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
243 error_nounlock:
244  return (error);
245 }
246 
247 static void cfg_inst_free (void *inst)
248 {
249  struct cfg_inst *cfg_inst = (struct cfg_inst *)inst;
250  qb_ipcc_disconnect(cfg_inst->c);
251 }
252 
255  corosync_cfg_handle_t cfg_handle)
256 {
257  struct cfg_inst *cfg_inst;
258  cs_error_t error;
259 
260  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
261  if (error != CS_OK) {
262  return (error);
263  }
264 
265  /*
266  * Another thread has already started finalizing
267  */
268  if (cfg_inst->finalize) {
269  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
270  return (CS_ERR_BAD_HANDLE);
271  }
272 
273  cfg_inst->finalize = 1;
274 
275  (void)hdb_handle_destroy (&cfg_hdb, cfg_handle);
276 
277  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
278 
279  return (error);
280 }
281 
284  corosync_cfg_handle_t cfg_handle,
285  char ***interface_names,
286  char ***status,
287  unsigned int *interface_count)
288 {
289  struct cfg_inst *cfg_inst;
290  struct req_lib_cfg_ringstatusget req_lib_cfg_ringstatusget;
291  struct res_lib_cfg_ringstatusget res_lib_cfg_ringstatusget;
292  unsigned int i, j;
293  cs_error_t error;
294  struct iovec iov;
295 
296  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
297  if (error != CS_OK) {
298  return (error);
299  }
300 
301  req_lib_cfg_ringstatusget.header.size = sizeof (struct req_lib_cfg_ringstatusget);
302  req_lib_cfg_ringstatusget.header.id = MESSAGE_REQ_CFG_RINGSTATUSGET;
303 
304  iov.iov_base = (void *)&req_lib_cfg_ringstatusget,
305  iov.iov_len = sizeof (struct req_lib_cfg_ringstatusget),
306 
307  error = qb_to_cs_error (qb_ipcc_sendv_recv(cfg_inst->c,
308  &iov,
309  1,
310  &res_lib_cfg_ringstatusget,
311  sizeof (struct res_lib_cfg_ringstatusget), CS_IPC_TIMEOUT_MS));
312 
313  if (error != CS_OK) {
314  goto exit_handle_put;
315  }
316 
317  *interface_count = res_lib_cfg_ringstatusget.interface_count;
318  *interface_names = malloc (sizeof (char *) * *interface_count);
319  if (*interface_names == NULL) {
320  return (CS_ERR_NO_MEMORY);
321  }
322  memset (*interface_names, 0, sizeof (char *) * *interface_count);
323 
324  *status = malloc (sizeof (char *) * *interface_count);
325  if (*status == NULL) {
326  error = CS_ERR_NO_MEMORY;
327  goto error_free_interface_names_array;
328  }
329  memset (*status, 0, sizeof (char *) * *interface_count);
330 
331  for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
332  (*(interface_names))[i] = strdup (res_lib_cfg_ringstatusget.interface_name[i]);
333  if ((*(interface_names))[i] == NULL) {
334  error = CS_ERR_NO_MEMORY;
335  goto error_free_interface_names;
336  }
337  }
338 
339  for (i = 0; i < res_lib_cfg_ringstatusget.interface_count; i++) {
340  (*(status))[i] = strdup (res_lib_cfg_ringstatusget.interface_status[i]);
341  if ((*(status))[i] == NULL) {
342  error = CS_ERR_NO_MEMORY;
343  goto error_free_status;
344  }
345  }
346  goto exit_handle_put;
347 
348 error_free_status:
349  for (j = 0; j < i; j++) {
350  free ((*(status))[j]);
351  }
352  i = *interface_count;
353 
354 error_free_interface_names:
355  for (j = 0; j < i; j++) {
356  free ((*(interface_names))[j]);
357  }
358 
359  free (*status);
360 
361 error_free_interface_names_array:
362  free (*interface_names);
363 
364 exit_handle_put:
365  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
366 
367  return (error);
368 }
369 
372  corosync_cfg_handle_t cfg_handle,
373  unsigned int nodeid,
375  void *node_status)
376 {
377  struct cfg_inst *cfg_inst;
378  struct req_lib_cfg_nodestatusget req_lib_cfg_nodestatusget;
379  cs_error_t error;
380  struct iovec iov;
381  size_t cfg_node_status_size;
382  void *res_lib_cfg_nodestatuget_ptr;
383  struct res_lib_cfg_nodestatusget_v1 res_lib_cfg_nodestatusget_v1;
385 
386  if (!node_status) {
387  return (CS_ERR_INVALID_PARAM);
388  }
389 
390  switch (version) {
391  case CFG_NODE_STATUS_V1:
392  cfg_node_status_size = sizeof(struct res_lib_cfg_nodestatusget_v1);
393  res_lib_cfg_nodestatuget_ptr = &res_lib_cfg_nodestatusget_v1;
394 
395  break;
396  default:
397  return (CS_ERR_INVALID_PARAM);
398  break;
399  }
400 
401  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
402  if (error != CS_OK) {
403  return (error);
404  }
405 
406  req_lib_cfg_nodestatusget.header.size = sizeof (struct req_lib_cfg_nodestatusget);
407  req_lib_cfg_nodestatusget.header.id = MESSAGE_REQ_CFG_NODESTATUSGET;
408  req_lib_cfg_nodestatusget.nodeid = nodeid;
409  req_lib_cfg_nodestatusget.version = version;
410 
411  iov.iov_base = (void *)&req_lib_cfg_nodestatusget,
412  iov.iov_len = sizeof (struct req_lib_cfg_nodestatusget),
413 
414  error = qb_to_cs_error (qb_ipcc_sendv_recv(cfg_inst->c,
415  &iov,
416  1,
417  res_lib_cfg_nodestatuget_ptr,
418  cfg_node_status_size, CS_IPC_TIMEOUT_MS));
419  if (error != CS_OK) {
420  goto error_put;
421  }
422 
423  res_lib_cfg_nodestatusget_version = res_lib_cfg_nodestatuget_ptr;
424  error = res_lib_cfg_nodestatusget_version->header.error;
425  if (error != CS_OK) {
426  goto error_put;
427  }
428 
429  if (res_lib_cfg_nodestatusget_version->version != version) {
430  /*
431  * corosync sent us something we don't really understand.
432  */
433  error = CS_ERR_NOT_SUPPORTED;
434  goto error_put;
435  }
436 
437  switch (version) {
438  case CFG_NODE_STATUS_V1:
439  memcpy(node_status, &res_lib_cfg_nodestatusget_v1.node_status,
440  sizeof(struct corosync_cfg_node_status_v1));
441  break;
442  }
443 
444 error_put:
445  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
446 
447  return (error);
448 }
449 
452  corosync_cfg_handle_t cfg_handle,
453  unsigned int nodeid,
454  const char *reason)
455 {
456  struct cfg_inst *cfg_inst;
457  struct req_lib_cfg_killnode req_lib_cfg_killnode;
458  struct res_lib_cfg_killnode res_lib_cfg_killnode;
459  cs_error_t error;
460  struct iovec iov;
461 
462  if (strlen(reason) >= CS_MAX_NAME_LENGTH)
463  return CS_ERR_NAME_TOO_LONG;
464 
465  error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
466  (void *)&cfg_inst));
467  if (error != CS_OK) {
468  return (error);
469  }
470 
471  req_lib_cfg_killnode.header.id = MESSAGE_REQ_CFG_KILLNODE;
472  req_lib_cfg_killnode.header.size = sizeof (struct req_lib_cfg_killnode);
473  req_lib_cfg_killnode.nodeid = nodeid;
474  strcpy((char *)req_lib_cfg_killnode.reason.value, reason);
475  req_lib_cfg_killnode.reason.length = strlen(reason)+1;
476 
477  iov.iov_base = (void *)&req_lib_cfg_killnode;
478  iov.iov_len = sizeof (struct req_lib_cfg_killnode);
479 
480  error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
481  &iov,
482  1,
483  &res_lib_cfg_killnode,
484  sizeof (struct res_lib_cfg_killnode), CS_IPC_TIMEOUT_MS));
485 
486  error = res_lib_cfg_killnode.header.error;
487 
488  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
489 
490  return (error == CS_OK ? res_lib_cfg_killnode.header.error : error);
491 }
492 
495  corosync_cfg_handle_t cfg_handle,
497 {
498  struct cfg_inst *cfg_inst;
499  struct req_lib_cfg_tryshutdown req_lib_cfg_tryshutdown;
500  struct res_lib_cfg_tryshutdown res_lib_cfg_tryshutdown;
501  cs_error_t error;
502  struct iovec iov;
503 
504  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
505  (void *)&cfg_inst));
506  if (error != CS_OK) {
507  return (error);
508  }
509 
510  req_lib_cfg_tryshutdown.header.id = MESSAGE_REQ_CFG_TRYSHUTDOWN;
511  req_lib_cfg_tryshutdown.header.size = sizeof (struct req_lib_cfg_tryshutdown);
512  req_lib_cfg_tryshutdown.flags = flags;
513 
514  iov.iov_base = (void *)&req_lib_cfg_tryshutdown;
515  iov.iov_len = sizeof (req_lib_cfg_tryshutdown);
516 
517  error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
518  &iov,
519  1,
520  &res_lib_cfg_tryshutdown,
521  sizeof (struct res_lib_cfg_tryshutdown), CS_IPC_TIMEOUT_MS));
522 
523  (void)hdb_handle_put (&cfg_hdb, cfg_handle);
524 
525  return (error == CS_OK ? res_lib_cfg_tryshutdown.header.error : error);
526 }
527 
530  corosync_cfg_handle_t cfg_handle,
532 {
533  struct cfg_inst *cfg_inst;
534  struct req_lib_cfg_replytoshutdown req_lib_cfg_replytoshutdown;
535  struct res_lib_cfg_replytoshutdown res_lib_cfg_replytoshutdown;
536  struct iovec iov;
537  cs_error_t error;
538 
539  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
540  (void *)&cfg_inst));
541  if (error != CS_OK) {
542  return (error);
543  }
544 
545  req_lib_cfg_replytoshutdown.header.id = MESSAGE_REQ_CFG_REPLYTOSHUTDOWN;
546  req_lib_cfg_replytoshutdown.header.size = sizeof (struct req_lib_cfg_replytoshutdown);
547  req_lib_cfg_replytoshutdown.response = response;
548 
549  iov.iov_base = (void *)&req_lib_cfg_replytoshutdown;
550  iov.iov_len = sizeof (struct req_lib_cfg_replytoshutdown);
551 
552  error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
553  &iov,
554  1,
555  &res_lib_cfg_replytoshutdown,
556  sizeof (struct res_lib_cfg_replytoshutdown), CS_IPC_TIMEOUT_MS));
557 
558  return (error);
559 }
560 
562  corosync_cfg_handle_t cfg_handle,
563  unsigned int nodeid,
564  size_t max_addrs,
565  int *num_addrs,
567 {
568  cs_error_t error;
569  struct req_lib_cfg_get_node_addrs req_lib_cfg_get_node_addrs;
571  struct cfg_inst *cfg_inst;
572  int addrlen = 0;
573  int i;
574  struct iovec iov;
575  const char *addr_buf;
576  char response_buf[IPC_RESPONSE_SIZE];
577  char zeroes[sizeof(struct sockaddr_storage)];
578 
579  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
580  (void *)&cfg_inst));
581  if (error != CS_OK) {
582  return (error);
583  }
584  memset(zeroes, 0, sizeof(zeroes));
585 
586  req_lib_cfg_get_node_addrs.header.size = sizeof (req_lib_cfg_get_node_addrs);
587  req_lib_cfg_get_node_addrs.header.id = MESSAGE_REQ_CFG_GET_NODE_ADDRS;
588  req_lib_cfg_get_node_addrs.nodeid = nodeid;
589 
590  iov.iov_base = (char *)&req_lib_cfg_get_node_addrs;
591  iov.iov_len = sizeof (req_lib_cfg_get_node_addrs);
592 
593  error = qb_to_cs_error (qb_ipcc_sendv_recv (
594  cfg_inst->c,
595  &iov, 1,
596  response_buf, IPC_RESPONSE_SIZE, CS_IPC_TIMEOUT_MS));
597  res_lib_cfg_get_node_addrs = (struct res_lib_cfg_get_node_addrs *)response_buf;
598 
599  if (error != CS_OK) {
600  goto error_put;
601  }
602 
603  if (res_lib_cfg_get_node_addrs->family == AF_INET)
604  addrlen = sizeof(struct sockaddr_in);
605  if (res_lib_cfg_get_node_addrs->family == AF_INET6)
606  addrlen = sizeof(struct sockaddr_in6);
607 
608  for (i = 0, addr_buf = (char *)res_lib_cfg_get_node_addrs->addrs;
609  i < max_addrs && i<res_lib_cfg_get_node_addrs->num_addrs;
610  i++, addr_buf += TOTEMIP_ADDRLEN) {
611  struct sockaddr_in *in;
612  struct sockaddr_in6 *in6;
613 
614  addrs[i].address_length = addrlen;
615 
616  if (res_lib_cfg_get_node_addrs->family == AF_INET) {
617  in = (struct sockaddr_in *)addrs[i].address;
618  if (memcmp(addr_buf, zeroes, addrlen) == 0) {
619  in->sin_family = 0;
620  } else {
621  in->sin_family = AF_INET;
622  }
623  memcpy(&in->sin_addr, addr_buf, sizeof(struct in_addr));
624  }
625  if (res_lib_cfg_get_node_addrs->family == AF_INET6) {
626  in6 = (struct sockaddr_in6 *)addrs[i].address;
627 
628  if (memcmp(addr_buf, zeroes, addrlen) == 0) {
629  in6->sin6_family = 0;
630  } else {
631  in6->sin6_family = AF_INET6;
632  }
633  memcpy(&in6->sin6_addr, addr_buf, sizeof(struct in6_addr));
634  }
635 
636  /* Mark it as unused */
637 
638  }
639  *num_addrs = res_lib_cfg_get_node_addrs->num_addrs;
640  errno = error = res_lib_cfg_get_node_addrs->header.error;
641 
642 error_put:
643  hdb_handle_put (&cfg_hdb, cfg_handle);
644 
645  return (error);
646 }
647 
649  corosync_cfg_handle_t handle,
650  unsigned int *local_nodeid)
651 {
652  cs_error_t error;
653  struct cfg_inst *cfg_inst;
654  struct iovec iov;
655  struct req_lib_cfg_local_get req_lib_cfg_local_get;
656  struct res_lib_cfg_local_get res_lib_cfg_local_get;
657 
658  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
659  if (error != CS_OK) {
660  return (error);
661  }
662 
663  req_lib_cfg_local_get.header.size = sizeof (struct qb_ipc_request_header);
664  req_lib_cfg_local_get.header.id = MESSAGE_REQ_CFG_LOCAL_GET;
665 
666  iov.iov_base = (void *)&req_lib_cfg_local_get;
667  iov.iov_len = sizeof (struct req_lib_cfg_local_get);
668 
669  error = qb_to_cs_error (qb_ipcc_sendv_recv (
670  cfg_inst->c,
671  &iov,
672  1,
673  &res_lib_cfg_local_get,
674  sizeof (struct res_lib_cfg_local_get), CS_IPC_TIMEOUT_MS));
675 
676  if (error != CS_OK) {
677  goto error_exit;
678  }
679 
680  error = res_lib_cfg_local_get.header.error;
681 
682  *local_nodeid = res_lib_cfg_local_get.local_nodeid;
683 
684 error_exit:
685  (void)hdb_handle_put (&cfg_hdb, handle);
686 
687  return (error);
688 }
689 
691  corosync_cfg_handle_t handle)
692 {
693  cs_error_t error;
694  struct cfg_inst *cfg_inst;
695  struct iovec iov;
696  struct req_lib_cfg_reload_config req_lib_cfg_reload_config;
697  struct res_lib_cfg_reload_config res_lib_cfg_reload_config;
698 
699  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
700  if (error != CS_OK) {
701  return (error);
702  }
703 
704  req_lib_cfg_reload_config.header.size = sizeof (struct qb_ipc_request_header);
705  req_lib_cfg_reload_config.header.id = MESSAGE_REQ_CFG_RELOAD_CONFIG;
706 
707  iov.iov_base = (void *)&req_lib_cfg_reload_config;
708  iov.iov_len = sizeof (struct req_lib_cfg_reload_config);
709 
710  error = qb_to_cs_error (qb_ipcc_sendv_recv (
711  cfg_inst->c,
712  &iov,
713  1,
714  &res_lib_cfg_reload_config,
715  sizeof (struct res_lib_cfg_reload_config), CS_IPC_TIMEOUT_MS));
716 
717  if (error != CS_OK) {
718  goto error_exit;
719  }
720 
721  error = res_lib_cfg_reload_config.header.error;
722 
723 error_exit:
724  (void)hdb_handle_put (&cfg_hdb, handle);
725 
726  return (error);
727 }
728 
730  corosync_cfg_handle_t handle)
731 {
732  cs_error_t error;
733  struct cfg_inst *cfg_inst;
734  struct iovec iov;
735  struct req_lib_cfg_reopen_log_files req_lib_cfg_reopen_log_files;
736  struct res_lib_cfg_reopen_log_files res_lib_cfg_reopen_log_files;
737 
738  error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
739  if (error != CS_OK) {
740  return (error);
741  }
742 
743  req_lib_cfg_reopen_log_files.header.size = sizeof (struct qb_ipc_request_header);
744  req_lib_cfg_reopen_log_files.header.id = MESSAGE_REQ_CFG_REOPEN_LOG_FILES;
745 
746  iov.iov_base = (void *)&req_lib_cfg_reopen_log_files;
747  iov.iov_len = sizeof (struct req_lib_cfg_reopen_log_files);
748 
749  error = qb_to_cs_error (qb_ipcc_sendv_recv (
750  cfg_inst->c,
751  &iov,
752  1,
753  &res_lib_cfg_reopen_log_files,
754  sizeof (struct res_lib_cfg_reopen_log_files), CS_IPC_TIMEOUT_MS));
755 
756  if (error != CS_OK) {
757  goto error_exit;
758  }
759 
760  error = res_lib_cfg_reopen_log_files.header.error;
761 
762 error_exit:
763  (void)hdb_handle_put (&cfg_hdb, handle);
764 
765  return (error);
766 }
char version
Definition: totem.h:54
qb_ipcc_connection_t * c
Definition: lib/cfg.c:66
The res_lib_cfg_reopen_log_files struct.
Definition: ipc_cfg.h:254
cs_error_t corosync_cfg_kill_node(corosync_cfg_handle_t cfg_handle, unsigned int nodeid, const char *reason)
corosync_cfg_kill_node
Definition: lib/cfg.c:451
cs_error_t hdb_error_to_cs(int res)
The res_lib_cfg_replytoshutdown struct.
Definition: ipc_cfg.h:184
cs_error_t corosync_cfg_local_get(corosync_cfg_handle_t handle, unsigned int *local_nodeid)
corosync_cfg_local_get
Definition: lib/cfg.c:648
struct corosync_cfg_shutdown_callback_t
Definition: cfg.h:81
The res_lib_cfg_testshutdown struct.
Definition: ipc_cfg.h:191
cs_error_t corosync_cfg_ring_status_get(corosync_cfg_handle_t cfg_handle, char ***interface_names, char ***status, unsigned int *interface_count)
corosync_cfg_ring_status_get
Definition: lib/cfg.c:283
cs_name_t comp_name
Definition: lib/cfg.c:68
cs_error_t corosync_cfg_fd_get(corosync_cfg_handle_t cfg_handle, int32_t *selection_fd)
corosync_cfg_fd_get
Definition: lib/cfg.c:126
cs_error_t corosync_cfg_initialize(corosync_cfg_handle_t *cfg_handle, const corosync_cfg_callbacks_t *cfg_callbacks)
corosync_cfg_initialize
Definition: lib/cfg.c:85
The res_lib_cfg_nodestatusget struct.
Definition: ipc_cfg.h:123
The res_lib_cfg_get_node_addrs struct.
Definition: ipc_cfg.h:207
corosync_cfg_callbacks_t callbacks
Definition: lib/cfg.c:67
corosync_cfg_node_status_version_t
Definition: cfg.h:165
A node address.
Definition: cfg.h:95
The req_lib_cfg_get_node_addrs struct.
Definition: ipc_cfg.h:199
corosync_cfg_shutdown_flags_t
Shutdown types.
Definition: cfg.h:46
cs_error_t corosync_cfg_reload_config(corosync_cfg_handle_t handle)
corosync_cfg_reload_config
Definition: lib/cfg.c:690
uint64_t corosync_cfg_handle_t
Definition: cfg.h:41
The req_lib_cfg_reload_config struct.
Definition: ipc_cfg.h:233
#define IPC_RESPONSE_SIZE
Definition: lib/util.h:50
cs_error_t corosync_cfg_finalize(corosync_cfg_handle_t cfg_handle)
corosync_cfg_finalize
Definition: lib/cfg.c:254
#define IPC_DISPATCH_SIZE
Definition: lib/util.h:51
The res_lib_cfg_local_get struct.
Definition: ipc_cfg.h:225
The res_lib_cfg_killnode struct.
Definition: ipc_cfg.h:154
cs_error_t corosync_cfg_replyto_shutdown(corosync_cfg_handle_t cfg_handle, corosync_cfg_shutdown_reply_flags_t response)
corosync_cfg_replyto_shutdown
Definition: lib/cfg.c:529
corosync_cfg_shutdown_callback_t corosync_cfg_shutdown_callback
Definition: cfg.h:82
unsigned int num_addrs
Definition: ipc_cfg.h:210
unsigned int flags
Definition: ipc_cfg.h:193
The req_lib_cfg_tryshutdown struct.
Definition: ipc_cfg.h:161
cs_error_t corosync_cfg_get_node_addrs(corosync_cfg_handle_t cfg_handle, unsigned int nodeid, size_t max_addrs, int *num_addrs, corosync_cfg_node_address_t *addrs)
corosync_cfg_get_node_addrs
Definition: lib/cfg.c:561
cs_error_t corosync_cfg_dispatch(corosync_cfg_handle_t cfg_handle, cs_dispatch_flags_t dispatch_flags)
corosync_cfg_dispatch
Definition: lib/cfg.c:145
int finalize
Definition: lib/cfg.c:70
uint32_t flags
#define IPC_REQUEST_SIZE
Definition: lib/util.h:49
cs_error_t
The cs_error_t enum.
Definition: corotypes.h:97
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
Definition: corotypes.h:83
The req_lib_cfg_replytoshutdown struct.
Definition: ipc_cfg.h:176
The res_lib_cfg_tryshutdown struct.
Definition: ipc_cfg.h:169
DECLARE_HDB_DATABASE(cfg_hdb, cfg_inst_free)
#define TOTEMIP_ADDRLEN
Definition: coroapi.h:86
corosync_cfg_shutdown_reply_flags_t
enum corosync_cfg_shutdown_reply_flags_t
Definition: cfg.h:66
The req_lib_cfg_ringstatusget struct.
Definition: ipc_cfg.h:92
cs_error_t corosync_cfg_try_shutdown(corosync_cfg_handle_t cfg_handle, corosync_cfg_shutdown_flags_t flags)
corosync_cfg_try_shutdown
Definition: lib/cfg.c:494
cs_error_t corosync_cfg_node_status_get(corosync_cfg_handle_t cfg_handle, unsigned int nodeid, corosync_cfg_node_status_version_t version, void *node_status)
corosync_cfg_node_status_get
Definition: lib/cfg.c:371
unsigned int flags
Definition: ipc_cfg.h:163
#define CS_MAX_NAME_LENGTH
Definition: corotypes.h:55
The res_lib_cfg_ringstatusget struct.
Definition: ipc_cfg.h:99
The req_lib_cfg_nodestatusget struct.
Definition: ipc_cfg.h:109
The res_lib_cfg_reload_config struct.
Definition: ipc_cfg.h:240
int comp_registered
Definition: lib/cfg.c:69
The req_lib_cfg_reopen_log_files struct.
Definition: ipc_cfg.h:247
unsigned int nodeid
Definition: coroapi.h:75
#define CS_IPC_TIMEOUT_MS
Definition: corotypes.h:130
cs_error_t qb_to_cs_error(int result)
qb_to_cs_error
cs_error_t corosync_cfg_reopen_log_files(corosync_cfg_handle_t handle)
Reopen logging files.
Definition: lib/cfg.c:729
The req_lib_cfg_killnode struct.
Definition: ipc_cfg.h:145
The cs_name_t struct.
Definition: corotypes.h:65
The req_lib_cfg_local_get struct.
Definition: ipc_cfg.h:218