cpg.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  1. /*
  2. * Copyright (c) 2006-2009 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Christine Caulfield (ccaulfie@redhat.com)
  7. * Author: Jan Friesse (jfriesse@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 CONTIBUTORS "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. #include <config.h>
  36. #ifdef HAVE_ALLOCA_H
  37. #include <alloca.h>
  38. #endif
  39. #include <sys/types.h>
  40. #include <sys/socket.h>
  41. #include <sys/un.h>
  42. #include <sys/ioctl.h>
  43. #include <netinet/in.h>
  44. #include <sys/uio.h>
  45. #include <unistd.h>
  46. #include <fcntl.h>
  47. #include <stdlib.h>
  48. #include <stdio.h>
  49. #include <errno.h>
  50. #include <time.h>
  51. #include <unistd.h>
  52. #include <netinet/in.h>
  53. #include <arpa/inet.h>
  54. #include <corosync/corotypes.h>
  55. #include <corosync/coroipc_types.h>
  56. #include <corosync/corodefs.h>
  57. #include <corosync/list.h>
  58. #include <corosync/jhash.h>
  59. #include <corosync/lcr/lcr_comp.h>
  60. #include <corosync/engine/logsys.h>
  61. #include <corosync/engine/coroapi.h>
  62. #include <corosync/cpg.h>
  63. #include <corosync/ipc_cpg.h>
  64. LOGSYS_DECLARE_SUBSYS ("CPG");
  65. #define GROUP_HASH_SIZE 32
  66. enum cpg_message_req_types {
  67. MESSAGE_REQ_EXEC_CPG_PROCJOIN = 0,
  68. MESSAGE_REQ_EXEC_CPG_PROCLEAVE = 1,
  69. MESSAGE_REQ_EXEC_CPG_JOINLIST = 2,
  70. MESSAGE_REQ_EXEC_CPG_MCAST = 3,
  71. MESSAGE_REQ_EXEC_CPG_DOWNLIST = 4
  72. };
  73. /*
  74. * state` exec deliver
  75. * match group name, pid -> if matched deliver for YES:
  76. * XXX indicates impossible state
  77. *
  78. * join leave mcast
  79. * UNJOINED XXX XXX NO
  80. * LEAVE_STARTED XXX YES(unjoined_enter) YES
  81. * JOIN_STARTED YES(join_started_enter) XXX NO
  82. * JOIN_COMPLETED XXX NO YES
  83. *
  84. * join_started_enter
  85. * set JOIN_COMPLETED
  86. * add entry to process_info list
  87. * unjoined_enter
  88. * set UNJOINED
  89. * delete entry from process_info list
  90. *
  91. *
  92. * library accept join error codes
  93. * UNJOINED YES(CPG_OK) set JOIN_STARTED
  94. * LEAVE_STARTED NO(CPG_ERR_BUSY)
  95. * JOIN_STARTED NO(CPG_ERR_EXIST)
  96. * JOIN_COMPlETED NO(CPG_ERR_EXIST)
  97. *
  98. * library accept leave error codes
  99. * UNJOINED NO(CPG_ERR_NOT_EXIST)
  100. * LEAVE_STARTED NO(CPG_ERR_NOT_EXIST)
  101. * JOIN_STARTED NO(CPG_ERR_BUSY)
  102. * JOIN_COMPLETED YES(CPG_OK) set LEAVE_STARTED
  103. *
  104. * library accept mcast
  105. * UNJOINED NO(CPG_ERR_NOT_EXIST)
  106. * LEAVE_STARTED NO(CPG_ERR_NOT_EXIST)
  107. * JOIN_STARTED YES(CPG_OK)
  108. * JOIN_COMPLETED YES(CPG_OK)
  109. */
  110. enum cpd_state {
  111. CPD_STATE_UNJOINED,
  112. CPD_STATE_LEAVE_STARTED,
  113. CPD_STATE_JOIN_STARTED,
  114. CPD_STATE_JOIN_COMPLETED
  115. };
  116. enum cpg_sync_state {
  117. CPGSYNC_DOWNLIST,
  118. CPGSYNC_JOINLIST
  119. };
  120. struct cpg_pd {
  121. void *conn;
  122. mar_cpg_name_t group_name;
  123. uint32_t pid;
  124. enum cpd_state cpd_state;
  125. struct list_head list;
  126. };
  127. DECLARE_LIST_INIT(cpg_pd_list_head);
  128. static unsigned int my_member_list[PROCESSOR_COUNT_MAX];
  129. static unsigned int my_member_list_entries;
  130. static unsigned int my_old_member_list[PROCESSOR_COUNT_MAX];
  131. static unsigned int my_old_member_list_entries = 0;
  132. static struct corosync_api_v1 *api = NULL;
  133. static enum cpg_sync_state my_sync_state = CPGSYNC_DOWNLIST;
  134. struct process_info {
  135. unsigned int nodeid;
  136. uint32_t pid;
  137. mar_cpg_name_t group;
  138. struct list_head list; /* on the group_info members list */
  139. };
  140. DECLARE_LIST_INIT(process_info_list_head);
  141. struct join_list_entry {
  142. uint32_t pid;
  143. mar_cpg_name_t group_name;
  144. };
  145. /*
  146. * Service Interfaces required by service_message_handler struct
  147. */
  148. static int cpg_exec_init_fn (struct corosync_api_v1 *);
  149. static int cpg_lib_init_fn (void *conn);
  150. static int cpg_lib_exit_fn (void *conn);
  151. static void message_handler_req_exec_cpg_procjoin (
  152. const void *message,
  153. unsigned int nodeid);
  154. static void message_handler_req_exec_cpg_procleave (
  155. const void *message,
  156. unsigned int nodeid);
  157. static void message_handler_req_exec_cpg_joinlist (
  158. const void *message,
  159. unsigned int nodeid);
  160. static void message_handler_req_exec_cpg_mcast (
  161. const void *message,
  162. unsigned int nodeid);
  163. static void message_handler_req_exec_cpg_downlist (
  164. const void *message,
  165. unsigned int nodeid);
  166. static void exec_cpg_procjoin_endian_convert (void *msg);
  167. static void exec_cpg_joinlist_endian_convert (void *msg);
  168. static void exec_cpg_mcast_endian_convert (void *msg);
  169. static void exec_cpg_downlist_endian_convert (void *msg);
  170. static void message_handler_req_lib_cpg_join (void *conn, const void *message);
  171. static void message_handler_req_lib_cpg_leave (void *conn, const void *message);
  172. static void message_handler_req_lib_cpg_mcast (void *conn, const void *message);
  173. static void message_handler_req_lib_cpg_membership (void *conn,
  174. const void *message);
  175. static void message_handler_req_lib_cpg_local_get (void *conn,
  176. const void *message);
  177. static int cpg_node_joinleave_send (unsigned int pid, const mar_cpg_name_t *group_name, int fn, int reason);
  178. static int cpg_exec_send_downlist(void);
  179. static int cpg_exec_send_joinlist(void);
  180. static void cpg_sync_init (
  181. const unsigned int *member_list,
  182. size_t member_list_entries,
  183. const struct memb_ring_id *ring_id);
  184. static int cpg_sync_process (void);
  185. static void cpg_sync_activate (void);
  186. static void cpg_sync_abort (void);
  187. /*
  188. * Library Handler Definition
  189. */
  190. static struct corosync_lib_handler cpg_lib_engine[] =
  191. {
  192. { /* 0 */
  193. .lib_handler_fn = message_handler_req_lib_cpg_join,
  194. .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
  195. },
  196. { /* 1 */
  197. .lib_handler_fn = message_handler_req_lib_cpg_leave,
  198. .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
  199. },
  200. { /* 2 */
  201. .lib_handler_fn = message_handler_req_lib_cpg_mcast,
  202. .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
  203. },
  204. { /* 3 */
  205. .lib_handler_fn = message_handler_req_lib_cpg_membership,
  206. .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED
  207. },
  208. { /* 4 */
  209. .lib_handler_fn = message_handler_req_lib_cpg_local_get,
  210. .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED
  211. }
  212. };
  213. static struct corosync_exec_handler cpg_exec_engine[] =
  214. {
  215. { /* 0 */
  216. .exec_handler_fn = message_handler_req_exec_cpg_procjoin,
  217. .exec_endian_convert_fn = exec_cpg_procjoin_endian_convert
  218. },
  219. { /* 1 */
  220. .exec_handler_fn = message_handler_req_exec_cpg_procleave,
  221. .exec_endian_convert_fn = exec_cpg_procjoin_endian_convert
  222. },
  223. { /* 2 */
  224. .exec_handler_fn = message_handler_req_exec_cpg_joinlist,
  225. .exec_endian_convert_fn = exec_cpg_joinlist_endian_convert
  226. },
  227. { /* 3 */
  228. .exec_handler_fn = message_handler_req_exec_cpg_mcast,
  229. .exec_endian_convert_fn = exec_cpg_mcast_endian_convert
  230. },
  231. { /* 4 */
  232. .exec_handler_fn = message_handler_req_exec_cpg_downlist,
  233. .exec_endian_convert_fn = exec_cpg_downlist_endian_convert
  234. },
  235. };
  236. struct corosync_service_engine cpg_service_engine = {
  237. .name = "corosync cluster closed process group service v1.01",
  238. .id = CPG_SERVICE,
  239. .priority = 1,
  240. .private_data_size = sizeof (struct cpg_pd),
  241. .flow_control = CS_LIB_FLOW_CONTROL_REQUIRED,
  242. .allow_inquorate = CS_LIB_ALLOW_INQUORATE,
  243. .lib_init_fn = cpg_lib_init_fn,
  244. .lib_exit_fn = cpg_lib_exit_fn,
  245. .lib_engine = cpg_lib_engine,
  246. .lib_engine_count = sizeof (cpg_lib_engine) / sizeof (struct corosync_lib_handler),
  247. .exec_init_fn = cpg_exec_init_fn,
  248. .exec_dump_fn = NULL,
  249. .exec_engine = cpg_exec_engine,
  250. .exec_engine_count = sizeof (cpg_exec_engine) / sizeof (struct corosync_exec_handler),
  251. .sync_mode = CS_SYNC_V1,
  252. .sync_init = cpg_sync_init,
  253. .sync_process = cpg_sync_process,
  254. .sync_activate = cpg_sync_activate,
  255. .sync_abort = cpg_sync_abort
  256. };
  257. /*
  258. * Dynamic loader definition
  259. */
  260. static struct corosync_service_engine *cpg_get_service_engine_ver0 (void);
  261. static struct corosync_service_engine_iface_ver0 cpg_service_engine_iface = {
  262. .corosync_get_service_engine_ver0 = cpg_get_service_engine_ver0
  263. };
  264. static struct lcr_iface corosync_cpg_ver0[1] = {
  265. {
  266. .name = "corosync_cpg",
  267. .version = 0,
  268. .versions_replace = 0,
  269. .versions_replace_count = 0,
  270. .dependencies = 0,
  271. .dependency_count = 0,
  272. .constructor = NULL,
  273. .destructor = NULL,
  274. .interfaces = NULL
  275. }
  276. };
  277. static struct lcr_comp cpg_comp_ver0 = {
  278. .iface_count = 1,
  279. .ifaces = corosync_cpg_ver0
  280. };
  281. static struct corosync_service_engine *cpg_get_service_engine_ver0 (void)
  282. {
  283. return (&cpg_service_engine);
  284. }
  285. #ifdef COROSYNC_SOLARIS
  286. void corosync_lcr_component_register (void);
  287. void corosync_lcr_component_register (void) {
  288. #else
  289. __attribute__ ((constructor)) static void corosync_lcr_component_register (void) {
  290. #endif
  291. lcr_interfaces_set (&corosync_cpg_ver0[0], &cpg_service_engine_iface);
  292. lcr_component_register (&cpg_comp_ver0);
  293. }
  294. struct req_exec_cpg_procjoin {
  295. coroipc_request_header_t header __attribute__((aligned(8)));
  296. mar_cpg_name_t group_name __attribute__((aligned(8)));
  297. mar_uint32_t pid __attribute__((aligned(8)));
  298. mar_uint32_t reason __attribute__((aligned(8)));
  299. };
  300. struct req_exec_cpg_mcast {
  301. coroipc_request_header_t header __attribute__((aligned(8)));
  302. mar_cpg_name_t group_name __attribute__((aligned(8)));
  303. mar_uint32_t msglen __attribute__((aligned(8)));
  304. mar_uint32_t pid __attribute__((aligned(8)));
  305. mar_message_source_t source __attribute__((aligned(8)));
  306. mar_uint8_t message[] __attribute__((aligned(8)));
  307. };
  308. struct req_exec_cpg_downlist {
  309. coroipc_request_header_t header __attribute__((aligned(8)));
  310. mar_uint32_t left_nodes __attribute__((aligned(8)));
  311. mar_uint32_t nodeids[PROCESSOR_COUNT_MAX] __attribute__((aligned(8)));
  312. };
  313. static struct req_exec_cpg_downlist g_req_exec_cpg_downlist;
  314. static void cpg_sync_init (
  315. const unsigned int *member_list,
  316. size_t member_list_entries,
  317. const struct memb_ring_id *ring_id)
  318. {
  319. unsigned int lowest_nodeid = 0xffffffff;
  320. int entries;
  321. int i, j;
  322. int found;
  323. my_sync_state = CPGSYNC_DOWNLIST;
  324. memcpy (my_member_list, member_list, member_list_entries *
  325. sizeof (unsigned int));
  326. my_member_list_entries = member_list_entries;
  327. for (i = 0; i < my_member_list_entries; i++) {
  328. if (my_member_list[i] < lowest_nodeid) {
  329. lowest_nodeid = my_member_list[i];
  330. }
  331. }
  332. entries = 0;
  333. if (lowest_nodeid == api->totem_nodeid_get()) {
  334. /*
  335. * Determine list of nodeids for downlist message
  336. */
  337. for (i = 0; i < my_old_member_list_entries; i++) {
  338. found = 0;
  339. for (j = 0; j < my_member_list_entries; j++) {
  340. if (my_old_member_list[i] == my_member_list[j]) {
  341. found = 1;
  342. break;
  343. }
  344. }
  345. if (found == 0) {
  346. g_req_exec_cpg_downlist.nodeids[entries++] =
  347. my_old_member_list[i];
  348. }
  349. }
  350. }
  351. g_req_exec_cpg_downlist.left_nodes = entries;
  352. }
  353. static int cpg_sync_process (void)
  354. {
  355. int res = -1;
  356. if (my_sync_state == CPGSYNC_DOWNLIST) {
  357. res = cpg_exec_send_downlist();
  358. if (res == -1) {
  359. return (-1);
  360. }
  361. my_sync_state = CPGSYNC_JOINLIST;
  362. }
  363. if (my_sync_state == CPGSYNC_JOINLIST) {
  364. res = cpg_exec_send_joinlist();
  365. }
  366. return (res);
  367. }
  368. static void cpg_sync_activate (void)
  369. {
  370. memcpy (my_old_member_list, my_member_list,
  371. my_member_list_entries * sizeof (unsigned int));
  372. my_old_member_list_entries = my_member_list_entries;
  373. }
  374. static void cpg_sync_abort (void)
  375. {
  376. }
  377. static int notify_lib_joinlist(
  378. const mar_cpg_name_t *group_name,
  379. void *conn,
  380. int joined_list_entries,
  381. mar_cpg_address_t *joined_list,
  382. int left_list_entries,
  383. mar_cpg_address_t *left_list,
  384. int id)
  385. {
  386. int size;
  387. char *buf;
  388. struct list_head *iter;
  389. int count;
  390. struct res_lib_cpg_confchg_callback *res;
  391. mar_cpg_address_t *retgi;
  392. count = 0;
  393. for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
  394. struct process_info *pi = list_entry (iter, struct process_info, list);
  395. if (mar_name_compare (&pi->group, group_name) == 0) {
  396. int i;
  397. int founded = 0;
  398. for (i = 0; i < left_list_entries; i++) {
  399. if (left_list[i].nodeid == pi->nodeid && left_list[i].pid == pi->pid) {
  400. founded++;
  401. }
  402. }
  403. if (!founded)
  404. count++;
  405. }
  406. }
  407. size = sizeof(struct res_lib_cpg_confchg_callback) +
  408. sizeof(mar_cpg_address_t) * (count + left_list_entries + joined_list_entries);
  409. buf = alloca(size);
  410. if (!buf)
  411. return CPG_ERR_LIBRARY;
  412. res = (struct res_lib_cpg_confchg_callback *)buf;
  413. res->joined_list_entries = joined_list_entries;
  414. res->left_list_entries = left_list_entries;
  415. res->member_list_entries = count;
  416. retgi = res->member_list;
  417. res->header.size = size;
  418. res->header.id = id;
  419. res->header.error = CS_OK;
  420. memcpy(&res->group_name, group_name, sizeof(mar_cpg_name_t));
  421. for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
  422. struct process_info *pi=list_entry (iter, struct process_info, list);
  423. if (mar_name_compare (&pi->group, group_name) == 0) {
  424. int i;
  425. int founded = 0;
  426. for (i = 0;i < left_list_entries; i++) {
  427. if (left_list[i].nodeid == pi->nodeid && left_list[i].pid == pi->pid) {
  428. founded++;
  429. }
  430. }
  431. if (!founded) {
  432. retgi->nodeid = pi->nodeid;
  433. retgi->pid = pi->pid;
  434. retgi++;
  435. }
  436. }
  437. }
  438. if (left_list_entries) {
  439. memcpy (retgi, left_list, left_list_entries * sizeof(mar_cpg_address_t));
  440. retgi += left_list_entries;
  441. }
  442. if (joined_list_entries) {
  443. memcpy (retgi, joined_list, joined_list_entries * sizeof(mar_cpg_address_t));
  444. retgi += joined_list_entries;
  445. }
  446. if (conn) {
  447. api->ipc_dispatch_send (conn, buf, size);
  448. } else {
  449. for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; iter = iter->next) {
  450. struct cpg_pd *cpd = list_entry (iter, struct cpg_pd, list);
  451. if (mar_name_compare (&cpd->group_name, group_name) == 0) {
  452. assert (left_list_entries <= 1);
  453. assert (joined_list_entries <= 1);
  454. if (joined_list_entries) {
  455. if (joined_list[0].pid == cpd->pid &&
  456. joined_list[0].nodeid == api->totem_nodeid_get()) {
  457. cpd->cpd_state = CPD_STATE_JOIN_COMPLETED;
  458. }
  459. }
  460. if (cpd->cpd_state == CPD_STATE_JOIN_COMPLETED ||
  461. cpd->cpd_state == CPD_STATE_LEAVE_STARTED) {
  462. api->ipc_dispatch_send (cpd->conn, buf, size);
  463. }
  464. if (left_list_entries) {
  465. if (left_list[0].pid == cpd->pid &&
  466. left_list[0].nodeid == api->totem_nodeid_get()) {
  467. cpd->pid = 0;
  468. memset (&cpd->group_name, 0, sizeof(cpd->group_name));
  469. cpd->cpd_state = CPD_STATE_UNJOINED;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. return CPG_OK;
  476. }
  477. static int cpg_exec_init_fn (struct corosync_api_v1 *corosync_api)
  478. {
  479. #ifdef COROSYNC_SOLARIS
  480. logsys_subsys_init();
  481. #endif
  482. api = corosync_api;
  483. return (0);
  484. }
  485. static int cpg_lib_exit_fn (void *conn)
  486. {
  487. struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
  488. log_printf(LOGSYS_LEVEL_DEBUG, "exit_fn for conn=%p\n", conn);
  489. if (cpd->group_name.length > 0) {
  490. cpg_node_joinleave_send (cpd->pid, &cpd->group_name,
  491. MESSAGE_REQ_EXEC_CPG_PROCLEAVE, CONFCHG_CPG_REASON_LEAVE);
  492. }
  493. list_del (&cpd->list);
  494. api->ipc_refcnt_dec (conn);
  495. return (0);
  496. }
  497. static int cpg_node_joinleave_send (unsigned int pid, const mar_cpg_name_t *group_name, int fn, int reason)
  498. {
  499. struct req_exec_cpg_procjoin req_exec_cpg_procjoin;
  500. struct iovec req_exec_cpg_iovec;
  501. int result;
  502. memcpy(&req_exec_cpg_procjoin.group_name, group_name, sizeof(mar_cpg_name_t));
  503. req_exec_cpg_procjoin.pid = pid;
  504. req_exec_cpg_procjoin.reason = reason;
  505. req_exec_cpg_procjoin.header.size = sizeof(req_exec_cpg_procjoin);
  506. req_exec_cpg_procjoin.header.id = SERVICE_ID_MAKE(CPG_SERVICE, fn);
  507. req_exec_cpg_iovec.iov_base = (char *)&req_exec_cpg_procjoin;
  508. req_exec_cpg_iovec.iov_len = sizeof(req_exec_cpg_procjoin);
  509. result = api->totem_mcast (&req_exec_cpg_iovec, 1, TOTEM_AGREED);
  510. return (result);
  511. }
  512. /* Can byteswap join & leave messages */
  513. static void exec_cpg_procjoin_endian_convert (void *msg)
  514. {
  515. struct req_exec_cpg_procjoin *req_exec_cpg_procjoin = msg;
  516. req_exec_cpg_procjoin->pid = swab32(req_exec_cpg_procjoin->pid);
  517. swab_mar_cpg_name_t (&req_exec_cpg_procjoin->group_name);
  518. req_exec_cpg_procjoin->reason = swab32(req_exec_cpg_procjoin->reason);
  519. }
  520. static void exec_cpg_joinlist_endian_convert (void *msg_v)
  521. {
  522. char *msg = msg_v;
  523. coroipc_response_header_t *res = (coroipc_response_header_t *)msg;
  524. struct join_list_entry *jle = (struct join_list_entry *)(msg + sizeof(coroipc_response_header_t));
  525. /* XXX shouldn't mar_res_header be swabbed? */
  526. while ((const char*)jle < msg + res->size) {
  527. jle->pid = swab32(jle->pid);
  528. swab_mar_cpg_name_t (&jle->group_name);
  529. jle++;
  530. }
  531. }
  532. static void exec_cpg_downlist_endian_convert (void *msg)
  533. {
  534. struct req_exec_cpg_downlist *req_exec_cpg_downlist = msg;
  535. unsigned int i;
  536. req_exec_cpg_downlist->left_nodes = swab32(req_exec_cpg_downlist->left_nodes);
  537. for (i = 0; i < req_exec_cpg_downlist->left_nodes; i++) {
  538. req_exec_cpg_downlist->nodeids[i] = swab32(req_exec_cpg_downlist->nodeids[i]);
  539. }
  540. }
  541. static void exec_cpg_mcast_endian_convert (void *msg)
  542. {
  543. struct req_exec_cpg_mcast *req_exec_cpg_mcast = msg;
  544. swab_coroipc_request_header_t (&req_exec_cpg_mcast->header);
  545. swab_mar_cpg_name_t (&req_exec_cpg_mcast->group_name);
  546. req_exec_cpg_mcast->pid = swab32(req_exec_cpg_mcast->pid);
  547. req_exec_cpg_mcast->msglen = swab32(req_exec_cpg_mcast->msglen);
  548. swab_mar_message_source_t (&req_exec_cpg_mcast->source);
  549. }
  550. static struct process_info *process_info_find(const mar_cpg_name_t *group_name, uint32_t pid, unsigned int nodeid) {
  551. struct list_head *iter;
  552. for (iter = process_info_list_head.next; iter != &process_info_list_head; ) {
  553. struct process_info *pi = list_entry (iter, struct process_info, list);
  554. iter = iter->next;
  555. if (pi->pid == pid && pi->nodeid == nodeid &&
  556. mar_name_compare (&pi->group, group_name) == 0) {
  557. return pi;
  558. }
  559. }
  560. return NULL;
  561. }
  562. static void do_proc_join(
  563. const mar_cpg_name_t *name,
  564. uint32_t pid,
  565. unsigned int nodeid,
  566. int reason)
  567. {
  568. struct process_info *pi;
  569. struct process_info *pi_entry;
  570. mar_cpg_address_t notify_info;
  571. struct list_head *list;
  572. struct list_head *list_to_add = NULL;
  573. if (process_info_find (name, pid, nodeid) != NULL) {
  574. return ;
  575. }
  576. pi = malloc (sizeof (struct process_info));
  577. if (!pi) {
  578. log_printf(LOGSYS_LEVEL_WARNING, "Unable to allocate process_info struct");
  579. return;
  580. }
  581. pi->nodeid = nodeid;
  582. pi->pid = pid;
  583. memcpy(&pi->group, name, sizeof(*name));
  584. list_init(&pi->list);
  585. /*
  586. * Insert new process in sorted order so synchronization works properly
  587. */
  588. list_to_add = &process_info_list_head;
  589. for (list = process_info_list_head.next; list != &process_info_list_head; list = list->next) {
  590. pi_entry = list_entry(list, struct process_info, list);
  591. if (pi_entry->nodeid > pi->nodeid ||
  592. (pi_entry->nodeid == pi->nodeid && pi_entry->pid > pi->pid)) {
  593. break;
  594. }
  595. list_to_add = list;
  596. }
  597. list_splice (&pi->list, list_to_add);
  598. notify_info.pid = pi->pid;
  599. notify_info.nodeid = nodeid;
  600. notify_info.reason = reason;
  601. notify_lib_joinlist(&pi->group, NULL,
  602. 1, &notify_info,
  603. 0, NULL,
  604. MESSAGE_RES_CPG_CONFCHG_CALLBACK);
  605. }
  606. static void message_handler_req_exec_cpg_downlist (
  607. const void *message,
  608. unsigned int nodeid)
  609. {
  610. const struct req_exec_cpg_downlist *req_exec_cpg_downlist = message;
  611. int i;
  612. mar_cpg_address_t left_list[1];
  613. struct list_head *iter;
  614. /*
  615. FOR OPTIMALIZATION - Make list of lists
  616. */
  617. log_printf (LOGSYS_LEVEL_DEBUG, "downlist left_list: %d\n", req_exec_cpg_downlist->left_nodes);
  618. for (iter = process_info_list_head.next; iter != &process_info_list_head; ) {
  619. struct process_info *pi = list_entry(iter, struct process_info, list);
  620. iter = iter->next;
  621. for (i = 0; i < req_exec_cpg_downlist->left_nodes; i++) {
  622. if (pi->nodeid == req_exec_cpg_downlist->nodeids[i]) {
  623. left_list[0].nodeid = pi->nodeid;
  624. left_list[0].pid = pi->pid;
  625. left_list[0].reason = CONFCHG_CPG_REASON_NODEDOWN;
  626. notify_lib_joinlist(&pi->group, NULL,
  627. 0, NULL,
  628. 1, left_list,
  629. MESSAGE_RES_CPG_CONFCHG_CALLBACK);
  630. list_del (&pi->list);
  631. free (pi);
  632. }
  633. }
  634. }
  635. }
  636. static void message_handler_req_exec_cpg_procjoin (
  637. const void *message,
  638. unsigned int nodeid)
  639. {
  640. const struct req_exec_cpg_procjoin *req_exec_cpg_procjoin = message;
  641. log_printf(LOGSYS_LEVEL_DEBUG, "got procjoin message from cluster node %d\n", nodeid);
  642. do_proc_join (&req_exec_cpg_procjoin->group_name,
  643. req_exec_cpg_procjoin->pid, nodeid,
  644. CONFCHG_CPG_REASON_JOIN);
  645. }
  646. static void message_handler_req_exec_cpg_procleave (
  647. const void *message,
  648. unsigned int nodeid)
  649. {
  650. const struct req_exec_cpg_procjoin *req_exec_cpg_procjoin = message;
  651. struct process_info *pi;
  652. struct list_head *iter;
  653. mar_cpg_address_t notify_info;
  654. log_printf(LOGSYS_LEVEL_DEBUG, "got procleave message from cluster node %d\n", nodeid);
  655. notify_info.pid = req_exec_cpg_procjoin->pid;
  656. notify_info.nodeid = nodeid;
  657. notify_info.reason = req_exec_cpg_procjoin->reason;
  658. notify_lib_joinlist(&req_exec_cpg_procjoin->group_name, NULL,
  659. 0, NULL,
  660. 1, &notify_info,
  661. MESSAGE_RES_CPG_CONFCHG_CALLBACK);
  662. for (iter = process_info_list_head.next; iter != &process_info_list_head; ) {
  663. pi = list_entry(iter, struct process_info, list);
  664. iter = iter->next;
  665. if (pi->pid == req_exec_cpg_procjoin->pid && pi->nodeid == nodeid &&
  666. mar_name_compare (&pi->group, &req_exec_cpg_procjoin->group_name)==0) {
  667. list_del (&pi->list);
  668. free (pi);
  669. }
  670. }
  671. }
  672. /* Got a proclist from another node */
  673. static void message_handler_req_exec_cpg_joinlist (
  674. const void *message_v,
  675. unsigned int nodeid)
  676. {
  677. const char *message = message_v;
  678. const coroipc_response_header_t *res = (const coroipc_response_header_t *)message;
  679. const struct join_list_entry *jle = (const struct join_list_entry *)(message + sizeof(coroipc_response_header_t));
  680. log_printf(LOGSYS_LEVEL_DEBUG, "got joinlist message from node %x\n",
  681. nodeid);
  682. /* Ignore our own messages */
  683. if (nodeid == api->totem_nodeid_get()) {
  684. return;
  685. }
  686. while ((const char*)jle < message + res->size) {
  687. do_proc_join (&jle->group_name, jle->pid, nodeid,
  688. CONFCHG_CPG_REASON_NODEUP);
  689. jle++;
  690. }
  691. }
  692. static void message_handler_req_exec_cpg_mcast (
  693. const void *message,
  694. unsigned int nodeid)
  695. {
  696. const struct req_exec_cpg_mcast *req_exec_cpg_mcast = message;
  697. struct res_lib_cpg_deliver_callback res_lib_cpg_mcast;
  698. int msglen = req_exec_cpg_mcast->msglen;
  699. struct list_head *iter, *pi_iter;
  700. struct cpg_pd *cpd;
  701. struct iovec iovec[2];
  702. int known_node = 0;
  703. res_lib_cpg_mcast.header.id = MESSAGE_RES_CPG_DELIVER_CALLBACK;
  704. res_lib_cpg_mcast.header.size = sizeof(res_lib_cpg_mcast) + msglen;
  705. res_lib_cpg_mcast.msglen = msglen;
  706. res_lib_cpg_mcast.pid = req_exec_cpg_mcast->pid;
  707. res_lib_cpg_mcast.nodeid = nodeid;
  708. memcpy(&res_lib_cpg_mcast.group_name, &req_exec_cpg_mcast->group_name,
  709. sizeof(mar_cpg_name_t));
  710. iovec[0].iov_base = (void *)&res_lib_cpg_mcast;
  711. iovec[0].iov_len = sizeof (res_lib_cpg_mcast);
  712. iovec[1].iov_base = (char*)message+sizeof(*req_exec_cpg_mcast);
  713. iovec[1].iov_len = msglen;
  714. for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; ) {
  715. cpd = list_entry(iter, struct cpg_pd, list);
  716. iter = iter->next;
  717. if ((cpd->cpd_state == CPD_STATE_LEAVE_STARTED || cpd->cpd_state == CPD_STATE_JOIN_COMPLETED)
  718. && (mar_name_compare (&cpd->group_name, &req_exec_cpg_mcast->group_name) == 0)) {
  719. if (!known_node) {
  720. /* Try to find, if we know the node */
  721. for (pi_iter = process_info_list_head.next;
  722. pi_iter != &process_info_list_head; pi_iter = pi_iter->next) {
  723. struct process_info *pi = list_entry (pi_iter, struct process_info, list);
  724. if (pi->nodeid == nodeid &&
  725. mar_name_compare (&pi->group, &req_exec_cpg_mcast->group_name) == 0) {
  726. known_node = 1;
  727. break;
  728. }
  729. }
  730. }
  731. if (!known_node) {
  732. /* Unknown node -> we will not deliver message */
  733. return ;
  734. }
  735. api->ipc_dispatch_iov_send (cpd->conn, iovec, 2);
  736. }
  737. }
  738. }
  739. static int cpg_exec_send_downlist(void)
  740. {
  741. struct iovec iov;
  742. g_req_exec_cpg_downlist.header.id = SERVICE_ID_MAKE(CPG_SERVICE, MESSAGE_REQ_EXEC_CPG_DOWNLIST);
  743. g_req_exec_cpg_downlist.header.size = sizeof(struct req_exec_cpg_downlist);
  744. iov.iov_base = (void *)&g_req_exec_cpg_downlist;
  745. iov.iov_len = g_req_exec_cpg_downlist.header.size;
  746. return (api->totem_mcast (&iov, 1, TOTEM_AGREED));
  747. }
  748. static int cpg_exec_send_joinlist(void)
  749. {
  750. int count = 0;
  751. struct list_head *iter;
  752. coroipc_response_header_t *res;
  753. char *buf;
  754. struct join_list_entry *jle;
  755. struct iovec req_exec_cpg_iovec;
  756. for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
  757. struct process_info *pi = list_entry (iter, struct process_info, list);
  758. if (pi->nodeid == api->totem_nodeid_get ()) {
  759. count++;
  760. }
  761. }
  762. /* Nothing to send */
  763. if (!count)
  764. return 0;
  765. buf = alloca(sizeof(coroipc_response_header_t) + sizeof(struct join_list_entry) * count);
  766. if (!buf) {
  767. log_printf(LOGSYS_LEVEL_WARNING, "Unable to allocate joinlist buffer");
  768. return -1;
  769. }
  770. jle = (struct join_list_entry *)(buf + sizeof(coroipc_response_header_t));
  771. res = (coroipc_response_header_t *)buf;
  772. for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
  773. struct process_info *pi = list_entry (iter, struct process_info, list);
  774. if (pi->nodeid == api->totem_nodeid_get ()) {
  775. memcpy (&jle->group_name, &pi->group, sizeof (mar_cpg_name_t));
  776. jle->pid = pi->pid;
  777. jle++;
  778. }
  779. }
  780. res->id = SERVICE_ID_MAKE(CPG_SERVICE, MESSAGE_REQ_EXEC_CPG_JOINLIST);
  781. res->size = sizeof(coroipc_response_header_t)+sizeof(struct join_list_entry) * count;
  782. req_exec_cpg_iovec.iov_base = buf;
  783. req_exec_cpg_iovec.iov_len = res->size;
  784. return (api->totem_mcast (&req_exec_cpg_iovec, 1, TOTEM_AGREED));
  785. }
  786. static int cpg_lib_init_fn (void *conn)
  787. {
  788. struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
  789. memset (cpd, 0, sizeof(struct cpg_pd));
  790. cpd->conn = conn;
  791. list_add (&cpd->list, &cpg_pd_list_head);
  792. api->ipc_refcnt_inc (conn);
  793. log_printf(LOGSYS_LEVEL_DEBUG, "lib_init_fn: conn=%p, cpd=%p\n", conn, cpd);
  794. return (0);
  795. }
  796. /* Join message from the library */
  797. static void message_handler_req_lib_cpg_join (void *conn, const void *message)
  798. {
  799. const struct req_lib_cpg_join *req_lib_cpg_join = message;
  800. struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
  801. struct res_lib_cpg_join res_lib_cpg_join;
  802. cs_error_t error = CPG_OK;
  803. struct list_head *iter;
  804. /* Test, if we don't have same pid and group name joined */
  805. for (iter = cpg_pd_list_head.next; iter != &cpg_pd_list_head; iter = iter->next) {
  806. struct cpg_pd *cpd_item = list_entry (iter, struct cpg_pd, list);
  807. if (cpd_item->pid == req_lib_cpg_join->pid &&
  808. mar_name_compare(&req_lib_cpg_join->group_name, &cpd_item->group_name) == 0) {
  809. /* We have same pid and group name joined -> return error */
  810. error = CPG_ERR_EXIST;
  811. goto response_send;
  812. }
  813. }
  814. switch (cpd->cpd_state) {
  815. case CPD_STATE_UNJOINED:
  816. error = CPG_OK;
  817. cpd->cpd_state = CPD_STATE_JOIN_STARTED;
  818. cpd->pid = req_lib_cpg_join->pid;
  819. memcpy (&cpd->group_name, &req_lib_cpg_join->group_name,
  820. sizeof (cpd->group_name));
  821. cpg_node_joinleave_send (req_lib_cpg_join->pid,
  822. &req_lib_cpg_join->group_name,
  823. MESSAGE_REQ_EXEC_CPG_PROCJOIN, CONFCHG_CPG_REASON_JOIN);
  824. break;
  825. case CPD_STATE_LEAVE_STARTED:
  826. error = CPG_ERR_BUSY;
  827. break;
  828. case CPD_STATE_JOIN_STARTED:
  829. error = CPG_ERR_EXIST;
  830. break;
  831. case CPD_STATE_JOIN_COMPLETED:
  832. error = CPG_ERR_EXIST;
  833. break;
  834. }
  835. response_send:
  836. res_lib_cpg_join.header.size = sizeof(res_lib_cpg_join);
  837. res_lib_cpg_join.header.id = MESSAGE_RES_CPG_JOIN;
  838. res_lib_cpg_join.header.error = error;
  839. api->ipc_response_send (conn, &res_lib_cpg_join, sizeof(res_lib_cpg_join));
  840. }
  841. /* Leave message from the library */
  842. static void message_handler_req_lib_cpg_leave (void *conn, const void *message)
  843. {
  844. struct res_lib_cpg_leave res_lib_cpg_leave;
  845. cs_error_t error = CPG_OK;
  846. struct req_lib_cpg_leave *req_lib_cpg_leave = (struct req_lib_cpg_leave *)message;
  847. struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
  848. log_printf(LOGSYS_LEVEL_DEBUG, "got leave request on %p\n", conn);
  849. switch (cpd->cpd_state) {
  850. case CPD_STATE_UNJOINED:
  851. error = CPG_ERR_NOT_EXIST;
  852. break;
  853. case CPD_STATE_LEAVE_STARTED:
  854. error = CPG_ERR_NOT_EXIST;
  855. break;
  856. case CPD_STATE_JOIN_STARTED:
  857. error = CPG_ERR_BUSY;
  858. break;
  859. case CPD_STATE_JOIN_COMPLETED:
  860. error = CPG_OK;
  861. cpd->cpd_state = CPD_STATE_LEAVE_STARTED;
  862. cpg_node_joinleave_send (req_lib_cpg_leave->pid,
  863. &req_lib_cpg_leave->group_name,
  864. MESSAGE_REQ_EXEC_CPG_PROCLEAVE,
  865. CONFCHG_CPG_REASON_LEAVE);
  866. break;
  867. }
  868. /* send return */
  869. res_lib_cpg_leave.header.size = sizeof(res_lib_cpg_leave);
  870. res_lib_cpg_leave.header.id = MESSAGE_RES_CPG_LEAVE;
  871. res_lib_cpg_leave.header.error = error;
  872. api->ipc_response_send(conn, &res_lib_cpg_leave, sizeof(res_lib_cpg_leave));
  873. }
  874. /* Mcast message from the library */
  875. static void message_handler_req_lib_cpg_mcast (void *conn, const void *message)
  876. {
  877. const struct req_lib_cpg_mcast *req_lib_cpg_mcast = message;
  878. struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
  879. mar_cpg_name_t group_name = cpd->group_name;
  880. struct iovec req_exec_cpg_iovec[2];
  881. struct req_exec_cpg_mcast req_exec_cpg_mcast;
  882. struct res_lib_cpg_mcast res_lib_cpg_mcast;
  883. int msglen = req_lib_cpg_mcast->msglen;
  884. int result;
  885. cs_error_t error = CPG_ERR_NOT_EXIST;
  886. log_printf(LOGSYS_LEVEL_DEBUG, "got mcast request on %p\n", conn);
  887. switch (cpd->cpd_state) {
  888. case CPD_STATE_UNJOINED:
  889. error = CPG_ERR_NOT_EXIST;
  890. break;
  891. case CPD_STATE_LEAVE_STARTED:
  892. error = CPG_ERR_NOT_EXIST;
  893. break;
  894. case CPD_STATE_JOIN_STARTED:
  895. error = CPG_OK;
  896. break;
  897. case CPD_STATE_JOIN_COMPLETED:
  898. error = CPG_OK;
  899. break;
  900. }
  901. if (error == CPG_OK) {
  902. req_exec_cpg_mcast.header.size = sizeof(req_exec_cpg_mcast) + msglen;
  903. req_exec_cpg_mcast.header.id = SERVICE_ID_MAKE(CPG_SERVICE,
  904. MESSAGE_REQ_EXEC_CPG_MCAST);
  905. req_exec_cpg_mcast.pid = cpd->pid;
  906. req_exec_cpg_mcast.msglen = msglen;
  907. api->ipc_source_set (&req_exec_cpg_mcast.source, conn);
  908. memcpy(&req_exec_cpg_mcast.group_name, &group_name,
  909. sizeof(mar_cpg_name_t));
  910. req_exec_cpg_iovec[0].iov_base = (char *)&req_exec_cpg_mcast;
  911. req_exec_cpg_iovec[0].iov_len = sizeof(req_exec_cpg_mcast);
  912. req_exec_cpg_iovec[1].iov_base = (char *)&req_lib_cpg_mcast->message;
  913. req_exec_cpg_iovec[1].iov_len = msglen;
  914. result = api->totem_mcast (req_exec_cpg_iovec, 2, TOTEM_AGREED);
  915. assert(result == 0);
  916. }
  917. res_lib_cpg_mcast.header.size = sizeof(res_lib_cpg_mcast);
  918. res_lib_cpg_mcast.header.id = MESSAGE_RES_CPG_MCAST;
  919. res_lib_cpg_mcast.header.error = error;
  920. api->ipc_response_send (conn, &res_lib_cpg_mcast,
  921. sizeof (res_lib_cpg_mcast));
  922. }
  923. static void message_handler_req_lib_cpg_membership (void *conn,
  924. const void *message)
  925. {
  926. struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
  927. cs_error_t error = CPG_ERR_NOT_EXIST;
  928. coroipc_response_header_t res;
  929. switch (cpd->cpd_state) {
  930. case CPD_STATE_UNJOINED:
  931. error = CPG_ERR_NOT_EXIST;
  932. break;
  933. case CPD_STATE_LEAVE_STARTED:
  934. error = CPG_ERR_NOT_EXIST;
  935. break;
  936. case CPD_STATE_JOIN_STARTED:
  937. error = CPG_ERR_BUSY;
  938. break;
  939. case CPD_STATE_JOIN_COMPLETED:
  940. error = CPG_OK;
  941. break;
  942. }
  943. res.size = sizeof (res);
  944. res.id = MESSAGE_RES_CPG_MEMBERSHIP;
  945. res.error = error;
  946. api->ipc_response_send (conn, &res, sizeof(res));
  947. return;
  948. if (error == CPG_OK) {
  949. notify_lib_joinlist (&cpd->group_name, conn, 0, NULL, 0, NULL,
  950. MESSAGE_RES_CPG_MEMBERSHIP);
  951. }
  952. }
  953. static void message_handler_req_lib_cpg_local_get (void *conn,
  954. const void *message)
  955. {
  956. struct res_lib_cpg_local_get res_lib_cpg_local_get;
  957. res_lib_cpg_local_get.header.size = sizeof (res_lib_cpg_local_get);
  958. res_lib_cpg_local_get.header.id = MESSAGE_RES_CPG_LOCAL_GET;
  959. res_lib_cpg_local_get.header.error = CPG_OK;
  960. res_lib_cpg_local_get.local_nodeid = api->totem_nodeid_get ();
  961. api->ipc_response_send (conn, &res_lib_cpg_local_get,
  962. sizeof (res_lib_cpg_local_get));
  963. }