totempg.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  1. /*
  2. * Copyright (c) 2003-2005 MontaVista Software, Inc.
  3. * Copyright (c) 2005 OSDL.
  4. * Copyright (c) 2006-2009 Red Hat, Inc.
  5. *
  6. * All rights reserved.
  7. *
  8. * Author: Steven Dake (sdake@redhat.com)
  9. * Author: Mark Haverkamp (markh@osdl.org)
  10. *
  11. * This software licensed under BSD license, the text of which follows:
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * - Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  22. * contributors may be used to endorse or promote products derived from this
  23. * software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  29. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  35. * THE POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. /*
  38. * FRAGMENTATION AND PACKING ALGORITHM:
  39. *
  40. * Assemble the entire message into one buffer
  41. * if full fragment
  42. * store fragment into lengths list
  43. * for each full fragment
  44. * multicast fragment
  45. * set length and fragment fields of pg mesage
  46. * store remaining multicast into head of fragmentation data and set lens field
  47. *
  48. * If a message exceeds the maximum packet size allowed by the totem
  49. * single ring protocol, the protocol could lose forward progress.
  50. * Statically calculating the allowed data amount doesn't work because
  51. * the amount of data allowed depends on the number of fragments in
  52. * each message. In this implementation, the maximum fragment size
  53. * is dynamically calculated for each fragment added to the message.
  54. * It is possible for a message to be two bytes short of the maximum
  55. * packet size. This occurs when a message or collection of
  56. * messages + the mcast header + the lens are two bytes short of the
  57. * end of the packet. Since another len field consumes two bytes, the
  58. * len field would consume the rest of the packet without room for data.
  59. *
  60. * One optimization would be to forgo the final len field and determine
  61. * it from the size of the udp datagram. Then this condition would no
  62. * longer occur.
  63. */
  64. /*
  65. * ASSEMBLY AND UNPACKING ALGORITHM:
  66. *
  67. * copy incoming packet into assembly data buffer indexed by current
  68. * location of end of fragment
  69. *
  70. * if not fragmented
  71. * deliver all messages in assembly data buffer
  72. * else
  73. * if msg_count > 1 and fragmented
  74. * deliver all messages except last message in assembly data buffer
  75. * copy last fragmented section to start of assembly data buffer
  76. * else
  77. * if msg_count = 1 and fragmented
  78. * do nothing
  79. *
  80. */
  81. #include <config.h>
  82. #ifdef HAVE_ALLOCA_H
  83. #include <alloca.h>
  84. #endif
  85. #include <netinet/in.h>
  86. #include <sys/uio.h>
  87. #include <stdio.h>
  88. #include <stdlib.h>
  89. #include <string.h>
  90. #include <assert.h>
  91. #include <pthread.h>
  92. #include <errno.h>
  93. #include <limits.h>
  94. #include <corosync/swab.h>
  95. #include <corosync/hdb.h>
  96. #include <corosync/list.h>
  97. #include <corosync/totem/coropoll.h>
  98. #include <corosync/totem/totempg.h>
  99. #define LOGSYS_UTILS_ONLY 1
  100. #include <corosync/engine/logsys.h>
  101. #include "totemmrp.h"
  102. #include "totemsrp.h"
  103. #define min(a,b) ((a) < (b)) ? a : b
  104. struct totempg_mcast_header {
  105. short version;
  106. short type;
  107. };
  108. /*
  109. * totempg_mcast structure
  110. *
  111. * header: Identify the mcast.
  112. * fragmented: Set if this message continues into next message
  113. * continuation: Set if this message is a continuation from last message
  114. * msg_count Indicates how many packed messages are contained
  115. * in the mcast.
  116. * Also, the size of each packed message and the messages themselves are
  117. * appended to the end of this structure when sent.
  118. */
  119. struct totempg_mcast {
  120. struct totempg_mcast_header header;
  121. unsigned char fragmented;
  122. unsigned char continuation;
  123. unsigned short msg_count;
  124. /*
  125. * short msg_len[msg_count];
  126. */
  127. /*
  128. * data for messages
  129. */
  130. };
  131. /*
  132. * Maximum packet size for totem pg messages
  133. */
  134. #define TOTEMPG_PACKET_SIZE (totempg_totem_config->net_mtu - \
  135. sizeof (struct totempg_mcast))
  136. /*
  137. * Local variables used for packing small messages
  138. */
  139. static unsigned short mcast_packed_msg_lens[FRAME_SIZE_MAX];
  140. static int mcast_packed_msg_count = 0;
  141. static int totempg_reserved = 0;
  142. /*
  143. * Function and data used to log messages
  144. */
  145. static int totempg_log_level_security;
  146. static int totempg_log_level_error;
  147. static int totempg_log_level_warning;
  148. static int totempg_log_level_notice;
  149. static int totempg_log_level_debug;
  150. static int totempg_subsys_id;
  151. static void (*totempg_log_printf) (
  152. unsigned int rec_ident,
  153. const char *function,
  154. const char *file,
  155. int line,
  156. const char *format, ...) __attribute__((format(printf, 5, 6)));
  157. struct totem_config *totempg_totem_config;
  158. enum throw_away_mode {
  159. THROW_AWAY_INACTIVE,
  160. THROW_AWAY_ACTIVE
  161. };
  162. struct assembly {
  163. unsigned int nodeid;
  164. unsigned char data[MESSAGE_SIZE_MAX];
  165. int index;
  166. unsigned char last_frag_num;
  167. enum throw_away_mode throw_away_mode;
  168. struct list_head list;
  169. };
  170. static void assembly_deref (struct assembly *assembly);
  171. static int callback_token_received_fn (enum totem_callback_token_type type,
  172. const void *data);
  173. DECLARE_LIST_INIT(assembly_list_inuse);
  174. DECLARE_LIST_INIT(assembly_list_free);
  175. /*
  176. * Staging buffer for packed messages. Messages are staged in this buffer
  177. * before sending. Multiple messages may fit which cuts down on the
  178. * number of mcasts sent. If a message doesn't completely fit, then
  179. * the mcast header has a fragment bit set that says that there are more
  180. * data to follow. fragment_size is an index into the buffer. It indicates
  181. * the size of message data and where to place new message data.
  182. * fragment_contuation indicates whether the first packed message in
  183. * the buffer is a continuation of a previously packed fragment.
  184. */
  185. static unsigned char *fragmentation_data;
  186. static int fragment_size = 0;
  187. static int fragment_continuation = 0;
  188. static struct iovec iov_delv;
  189. static unsigned int totempg_max_handle = 0;
  190. struct totempg_group_instance {
  191. void (*deliver_fn) (
  192. unsigned int nodeid,
  193. const void *msg,
  194. unsigned int msg_len,
  195. int endian_conversion_required);
  196. void (*confchg_fn) (
  197. enum totem_configuration_type configuration_type,
  198. const unsigned int *member_list, size_t member_list_entries,
  199. const unsigned int *left_list, size_t left_list_entries,
  200. const unsigned int *joined_list, size_t joined_list_entries,
  201. const struct memb_ring_id *ring_id);
  202. struct totempg_group *groups;
  203. int groups_cnt;
  204. };
  205. DECLARE_HDB_DATABASE (totempg_groups_instance_database,NULL);
  206. static unsigned char next_fragment = 1;
  207. static pthread_mutex_t totempg_mutex = PTHREAD_MUTEX_INITIALIZER;
  208. static pthread_mutex_t callback_token_mutex = PTHREAD_MUTEX_INITIALIZER;
  209. static pthread_mutex_t mcast_msg_mutex = PTHREAD_MUTEX_INITIALIZER;
  210. #define log_printf(level, format, args...) \
  211. do { \
  212. totempg_log_printf ( \
  213. LOGSYS_ENCODE_RECID(level, \
  214. totempg_subsys_id, \
  215. LOGSYS_RECID_LOG), \
  216. __FUNCTION__, __FILE__, __LINE__, \
  217. format, ##args); \
  218. } while (0);
  219. static int msg_count_send_ok (int msg_count);
  220. static int byte_count_send_ok (int byte_count);
  221. static struct assembly *assembly_ref (unsigned int nodeid)
  222. {
  223. struct assembly *assembly;
  224. struct list_head *list;
  225. /*
  226. * Search inuse list for node id and return assembly buffer if found
  227. */
  228. for (list = assembly_list_inuse.next;
  229. list != &assembly_list_inuse;
  230. list = list->next) {
  231. assembly = list_entry (list, struct assembly, list);
  232. if (nodeid == assembly->nodeid) {
  233. return (assembly);
  234. }
  235. }
  236. /*
  237. * Nothing found in inuse list get one from free list if available
  238. */
  239. if (list_empty (&assembly_list_free) == 0) {
  240. assembly = list_entry (assembly_list_free.next, struct assembly, list);
  241. list_del (&assembly->list);
  242. list_add (&assembly->list, &assembly_list_inuse);
  243. assembly->nodeid = nodeid;
  244. assembly->index = 0;
  245. assembly->last_frag_num = 0;
  246. assembly->throw_away_mode = THROW_AWAY_INACTIVE;
  247. return (assembly);
  248. }
  249. /*
  250. * Nothing available in inuse or free list, so allocate a new one
  251. */
  252. assembly = malloc (sizeof (struct assembly));
  253. /*
  254. * TODO handle memory allocation failure here
  255. */
  256. assert (assembly);
  257. assembly->nodeid = nodeid;
  258. assembly->data[0] = 0;
  259. assembly->index = 0;
  260. assembly->last_frag_num = 0;
  261. assembly->throw_away_mode = THROW_AWAY_INACTIVE;
  262. list_init (&assembly->list);
  263. list_add (&assembly->list, &assembly_list_inuse);
  264. return (assembly);
  265. }
  266. static void assembly_deref (struct assembly *assembly)
  267. {
  268. list_del (&assembly->list);
  269. list_add (&assembly->list, &assembly_list_free);
  270. }
  271. static inline void app_confchg_fn (
  272. enum totem_configuration_type configuration_type,
  273. const unsigned int *member_list, size_t member_list_entries,
  274. const unsigned int *left_list, size_t left_list_entries,
  275. const unsigned int *joined_list, size_t joined_list_entries,
  276. const struct memb_ring_id *ring_id)
  277. {
  278. int i;
  279. struct totempg_group_instance *instance;
  280. struct assembly *assembly;
  281. unsigned int res;
  282. /*
  283. * For every leaving processor, add to free list
  284. * This also has the side effect of clearing out the dataset
  285. * In the leaving processor's assembly buffer.
  286. */
  287. for (i = 0; i < left_list_entries; i++) {
  288. assembly = assembly_ref (left_list[i]);
  289. list_del (&assembly->list);
  290. list_add (&assembly->list, &assembly_list_free);
  291. }
  292. for (i = 0; i <= totempg_max_handle; i++) {
  293. res = hdb_handle_get (&totempg_groups_instance_database,
  294. hdb_nocheck_convert (i), (void *)&instance);
  295. if (res == 0) {
  296. if (instance->confchg_fn) {
  297. instance->confchg_fn (
  298. configuration_type,
  299. member_list,
  300. member_list_entries,
  301. left_list,
  302. left_list_entries,
  303. joined_list,
  304. joined_list_entries,
  305. ring_id);
  306. }
  307. hdb_handle_put (&totempg_groups_instance_database,
  308. hdb_nocheck_convert (i));
  309. }
  310. }
  311. }
  312. static inline void group_endian_convert (
  313. void *msg,
  314. int msg_len)
  315. {
  316. unsigned short *group_len;
  317. int i;
  318. char *aligned_msg;
  319. /*
  320. * Align data structure for sparc and ia64
  321. */
  322. if ((size_t)msg % 4 != 0) {
  323. aligned_msg = alloca(msg_len);
  324. memcpy(aligned_msg, msg, msg_len);
  325. } else {
  326. aligned_msg = msg;
  327. }
  328. group_len = (unsigned short *)aligned_msg;
  329. group_len[0] = swab16(group_len[0]);
  330. for (i = 1; i < group_len[0] + 1; i++) {
  331. group_len[i] = swab16(group_len[i]);
  332. }
  333. if (aligned_msg != msg) {
  334. memcpy(msg, aligned_msg, msg_len);
  335. }
  336. }
  337. static inline int group_matches (
  338. struct iovec *iovec,
  339. unsigned int iov_len,
  340. struct totempg_group *groups_b,
  341. unsigned int group_b_cnt,
  342. unsigned int *adjust_iovec)
  343. {
  344. unsigned short *group_len;
  345. char *group_name;
  346. int i;
  347. int j;
  348. struct iovec iovec_aligned = { NULL, 0 };
  349. assert (iov_len == 1);
  350. /*
  351. * Align data structure for sparc and ia64
  352. */
  353. if ((size_t)iovec->iov_base % 4 != 0) {
  354. iovec_aligned.iov_base = alloca(iovec->iov_len);
  355. memcpy(iovec_aligned.iov_base, iovec->iov_base, iovec->iov_len);
  356. iovec_aligned.iov_len = iovec->iov_len;
  357. iovec = &iovec_aligned;
  358. }
  359. group_len = (unsigned short *)iovec->iov_base;
  360. group_name = ((char *)iovec->iov_base) +
  361. sizeof (unsigned short) * (group_len[0] + 1);
  362. /*
  363. * Calculate amount to adjust the iovec by before delivering to app
  364. */
  365. *adjust_iovec = sizeof (unsigned short) * (group_len[0] + 1);
  366. for (i = 1; i < group_len[0] + 1; i++) {
  367. *adjust_iovec += group_len[i];
  368. }
  369. /*
  370. * Determine if this message should be delivered to this instance
  371. */
  372. for (i = 1; i < group_len[0] + 1; i++) {
  373. for (j = 0; j < group_b_cnt; j++) {
  374. if ((group_len[i] == groups_b[j].group_len) &&
  375. (memcmp (groups_b[j].group, group_name, group_len[i]) == 0)) {
  376. return (1);
  377. }
  378. }
  379. group_name += group_len[i];
  380. }
  381. return (0);
  382. }
  383. static inline void app_deliver_fn (
  384. unsigned int nodeid,
  385. void *msg,
  386. unsigned int msg_len,
  387. int endian_conversion_required)
  388. {
  389. int i;
  390. struct totempg_group_instance *instance;
  391. struct iovec stripped_iovec;
  392. unsigned int adjust_iovec;
  393. unsigned int res;
  394. struct iovec *iovec;
  395. struct iovec aligned_iovec = { NULL, 0 };
  396. if (endian_conversion_required) {
  397. group_endian_convert (msg, msg_len);
  398. }
  399. /*
  400. * TODO This function needs to be rewritten for proper alignment to avoid 3+ memory copies
  401. */
  402. /*
  403. * Align data structure for sparc and ia64
  404. */
  405. aligned_iovec.iov_base = alloca(msg_len);
  406. aligned_iovec.iov_len = msg_len;
  407. memcpy(aligned_iovec.iov_base, msg, msg_len);
  408. iovec = &aligned_iovec;
  409. for (i = 0; i <= totempg_max_handle; i++) {
  410. res = hdb_handle_get (&totempg_groups_instance_database,
  411. hdb_nocheck_convert (i), (void *)&instance);
  412. if (res == 0) {
  413. if (group_matches (iovec, 1, instance->groups, instance->groups_cnt, &adjust_iovec)) {
  414. stripped_iovec.iov_len = iovec->iov_len - adjust_iovec;
  415. stripped_iovec.iov_base = (char *)iovec->iov_base + adjust_iovec;
  416. /*
  417. * Align data structure for sparc and ia64
  418. */
  419. if ((char *)iovec->iov_base + adjust_iovec % 4 != 0) {
  420. /*
  421. * Deal with misalignment
  422. */
  423. stripped_iovec.iov_base =
  424. alloca (stripped_iovec.iov_len);
  425. memcpy (stripped_iovec.iov_base,
  426. (char *)iovec->iov_base + adjust_iovec,
  427. stripped_iovec.iov_len);
  428. }
  429. instance->deliver_fn (
  430. nodeid,
  431. stripped_iovec.iov_base,
  432. stripped_iovec.iov_len,
  433. endian_conversion_required);
  434. }
  435. hdb_handle_put (&totempg_groups_instance_database, hdb_nocheck_convert(i));
  436. }
  437. }
  438. }
  439. static void totempg_confchg_fn (
  440. enum totem_configuration_type configuration_type,
  441. const unsigned int *member_list, size_t member_list_entries,
  442. const unsigned int *left_list, size_t left_list_entries,
  443. const unsigned int *joined_list, size_t joined_list_entries,
  444. const struct memb_ring_id *ring_id)
  445. {
  446. // TODO optimize this
  447. app_confchg_fn (configuration_type,
  448. member_list, member_list_entries,
  449. left_list, left_list_entries,
  450. joined_list, joined_list_entries,
  451. ring_id);
  452. }
  453. static void totempg_deliver_fn (
  454. unsigned int nodeid,
  455. const void *msg,
  456. unsigned int msg_len,
  457. int endian_conversion_required)
  458. {
  459. struct totempg_mcast *mcast;
  460. unsigned short *msg_lens;
  461. int i;
  462. struct assembly *assembly;
  463. char header[FRAME_SIZE_MAX];
  464. int msg_count;
  465. int continuation;
  466. int start;
  467. const char *data;
  468. int datasize;
  469. assembly = assembly_ref (nodeid);
  470. assert (assembly);
  471. /*
  472. * Assemble the header into one block of data and
  473. * assemble the packet contents into one block of data to simplify delivery
  474. */
  475. mcast = (struct totempg_mcast *)msg;
  476. if (endian_conversion_required) {
  477. mcast->msg_count = swab16 (mcast->msg_count);
  478. }
  479. msg_count = mcast->msg_count;
  480. datasize = sizeof (struct totempg_mcast) +
  481. msg_count * sizeof (unsigned short);
  482. memcpy (header, msg, datasize);
  483. data = msg;
  484. msg_lens = (unsigned short *) (header + sizeof (struct totempg_mcast));
  485. if (endian_conversion_required) {
  486. for (i = 0; i < mcast->msg_count; i++) {
  487. msg_lens[i] = swab16 (msg_lens[i]);
  488. }
  489. }
  490. memcpy (&assembly->data[assembly->index], &data[datasize],
  491. msg_len - datasize);
  492. /*
  493. * If the last message in the buffer is a fragment, then we
  494. * can't deliver it. We'll first deliver the full messages
  495. * then adjust the assembly buffer so we can add the rest of the
  496. * fragment when it arrives.
  497. */
  498. msg_count = mcast->fragmented ? mcast->msg_count - 1 : mcast->msg_count;
  499. continuation = mcast->continuation;
  500. iov_delv.iov_base = (void *)&assembly->data[0];
  501. iov_delv.iov_len = assembly->index + msg_lens[0];
  502. /*
  503. * Make sure that if this message is a continuation, that it
  504. * matches the sequence number of the previous fragment.
  505. * Also, if the first packed message is a continuation
  506. * of a previous message, but the assembly buffer
  507. * is empty, then we need to discard it since we can't
  508. * assemble a complete message. Likewise, if this message isn't a
  509. * continuation and the assembly buffer is empty, we have to discard
  510. * the continued message.
  511. */
  512. start = 0;
  513. if (assembly->throw_away_mode == THROW_AWAY_ACTIVE) {
  514. /* Throw away the first msg block */
  515. if (mcast->fragmented == 0 || mcast->fragmented == 1) {
  516. assembly->throw_away_mode = THROW_AWAY_INACTIVE;
  517. assembly->index += msg_lens[0];
  518. iov_delv.iov_base = (void *)&assembly->data[assembly->index];
  519. iov_delv.iov_len = msg_lens[1];
  520. start = 1;
  521. }
  522. } else
  523. if (assembly->throw_away_mode == THROW_AWAY_INACTIVE) {
  524. if (continuation == assembly->last_frag_num) {
  525. assembly->last_frag_num = mcast->fragmented;
  526. for (i = start; i < msg_count; i++) {
  527. app_deliver_fn(nodeid, iov_delv.iov_base, iov_delv.iov_len,
  528. endian_conversion_required);
  529. assembly->index += msg_lens[i];
  530. iov_delv.iov_base = (void *)&assembly->data[assembly->index];
  531. if (i < (msg_count - 1)) {
  532. iov_delv.iov_len = msg_lens[i + 1];
  533. }
  534. }
  535. } else {
  536. assembly->throw_away_mode = THROW_AWAY_ACTIVE;
  537. }
  538. }
  539. if (mcast->fragmented == 0) {
  540. /*
  541. * End of messages, dereference assembly struct
  542. */
  543. assembly->last_frag_num = 0;
  544. assembly->index = 0;
  545. assembly_deref (assembly);
  546. } else {
  547. /*
  548. * Message is fragmented, keep around assembly list
  549. */
  550. if (mcast->msg_count > 1) {
  551. memmove (&assembly->data[0],
  552. &assembly->data[assembly->index],
  553. msg_lens[msg_count]);
  554. assembly->index = 0;
  555. }
  556. assembly->index += msg_lens[msg_count];
  557. }
  558. }
  559. /*
  560. * Totem Process Group Abstraction
  561. * depends on poll abstraction, POSIX, IPV4
  562. */
  563. void *callback_token_received_handle;
  564. int callback_token_received_fn (enum totem_callback_token_type type,
  565. const void *data)
  566. {
  567. struct totempg_mcast mcast;
  568. struct iovec iovecs[3];
  569. int res;
  570. pthread_mutex_lock (&mcast_msg_mutex);
  571. if (mcast_packed_msg_count == 0) {
  572. pthread_mutex_unlock (&mcast_msg_mutex);
  573. return (0);
  574. }
  575. if (totemmrp_avail() == 0) {
  576. pthread_mutex_unlock (&mcast_msg_mutex);
  577. return (0);
  578. }
  579. mcast.header.version = 0;
  580. mcast.fragmented = 0;
  581. /*
  582. * Was the first message in this buffer a continuation of a
  583. * fragmented message?
  584. */
  585. mcast.continuation = fragment_continuation;
  586. fragment_continuation = 0;
  587. mcast.msg_count = mcast_packed_msg_count;
  588. iovecs[0].iov_base = (void *)&mcast;
  589. iovecs[0].iov_len = sizeof (struct totempg_mcast);
  590. iovecs[1].iov_base = (void *)mcast_packed_msg_lens;
  591. iovecs[1].iov_len = mcast_packed_msg_count * sizeof (unsigned short);
  592. iovecs[2].iov_base = (void *)&fragmentation_data[0];
  593. iovecs[2].iov_len = fragment_size;
  594. res = totemmrp_mcast (iovecs, 3, 0);
  595. mcast_packed_msg_count = 0;
  596. fragment_size = 0;
  597. pthread_mutex_unlock (&mcast_msg_mutex);
  598. return (0);
  599. }
  600. /*
  601. * Initialize the totem process group abstraction
  602. */
  603. int totempg_initialize (
  604. hdb_handle_t poll_handle,
  605. struct totem_config *totem_config)
  606. {
  607. int res;
  608. totempg_totem_config = totem_config;
  609. totempg_log_level_security = totem_config->totem_logging_configuration.log_level_security;
  610. totempg_log_level_error = totem_config->totem_logging_configuration.log_level_error;
  611. totempg_log_level_warning = totem_config->totem_logging_configuration.log_level_warning;
  612. totempg_log_level_notice = totem_config->totem_logging_configuration.log_level_notice;
  613. totempg_log_level_debug = totem_config->totem_logging_configuration.log_level_debug;
  614. totempg_log_printf = totem_config->totem_logging_configuration.log_printf;
  615. totempg_subsys_id = totem_config->totem_logging_configuration.log_subsys_id;
  616. fragmentation_data = malloc (TOTEMPG_PACKET_SIZE);
  617. if (fragmentation_data == 0) {
  618. return (-1);
  619. }
  620. res = totemmrp_initialize (
  621. poll_handle,
  622. totem_config,
  623. totempg_deliver_fn,
  624. totempg_confchg_fn);
  625. totemmrp_callback_token_create (
  626. &callback_token_received_handle,
  627. TOTEM_CALLBACK_TOKEN_RECEIVED,
  628. 0,
  629. callback_token_received_fn,
  630. 0);
  631. totemsrp_net_mtu_adjust (totem_config);
  632. return (res);
  633. }
  634. void totempg_finalize (void)
  635. {
  636. pthread_mutex_lock (&totempg_mutex);
  637. totemmrp_finalize ();
  638. pthread_mutex_unlock (&totempg_mutex);
  639. }
  640. /*
  641. * Multicast a message
  642. */
  643. static int mcast_msg (
  644. struct iovec *iovec_in,
  645. unsigned int iov_len,
  646. int guarantee)
  647. {
  648. int res = 0;
  649. struct totempg_mcast mcast;
  650. struct iovec iovecs[3];
  651. struct iovec iovec[64];
  652. int i;
  653. int dest, src;
  654. int max_packet_size = 0;
  655. int copy_len = 0;
  656. int copy_base = 0;
  657. int total_size = 0;
  658. pthread_mutex_lock (&mcast_msg_mutex);
  659. totemmrp_new_msg_signal ();
  660. /*
  661. * Remove zero length iovectors from the list
  662. */
  663. assert (iov_len < 64);
  664. for (dest = 0, src = 0; src < iov_len; src++) {
  665. if (iovec_in[src].iov_len) {
  666. memcpy (&iovec[dest++], &iovec_in[src],
  667. sizeof (struct iovec));
  668. }
  669. }
  670. iov_len = dest;
  671. max_packet_size = TOTEMPG_PACKET_SIZE -
  672. (sizeof (unsigned short) * (mcast_packed_msg_count + 1));
  673. mcast_packed_msg_lens[mcast_packed_msg_count] = 0;
  674. /*
  675. * Check if we would overwrite new message queue
  676. */
  677. for (i = 0; i < iov_len; i++) {
  678. total_size += iovec[i].iov_len;
  679. }
  680. if (byte_count_send_ok (total_size + sizeof(unsigned short) *
  681. (mcast_packed_msg_count+1)) == 0) {
  682. pthread_mutex_unlock (&mcast_msg_mutex);
  683. return(-1);
  684. }
  685. mcast.header.version = 0;
  686. for (i = 0; i < iov_len; ) {
  687. mcast.fragmented = 0;
  688. mcast.continuation = fragment_continuation;
  689. copy_len = iovec[i].iov_len - copy_base;
  690. /*
  691. * If it all fits with room left over, copy it in.
  692. * We need to leave at least sizeof(short) + 1 bytes in the
  693. * fragment_buffer on exit so that max_packet_size + fragment_size
  694. * doesn't exceed the size of the fragment_buffer on the next call.
  695. */
  696. if ((copy_len + fragment_size) <
  697. (max_packet_size - sizeof (unsigned short))) {
  698. memcpy (&fragmentation_data[fragment_size],
  699. (char *)iovec[i].iov_base + copy_base, copy_len);
  700. fragment_size += copy_len;
  701. mcast_packed_msg_lens[mcast_packed_msg_count] += copy_len;
  702. next_fragment = 1;
  703. copy_len = 0;
  704. copy_base = 0;
  705. i++;
  706. continue;
  707. /*
  708. * If it just fits or is too big, then send out what fits.
  709. */
  710. } else {
  711. unsigned char *data_ptr;
  712. copy_len = min(copy_len, max_packet_size - fragment_size);
  713. if( copy_len == max_packet_size )
  714. data_ptr = (unsigned char *)iovec[i].iov_base + copy_base;
  715. else {
  716. data_ptr = fragmentation_data;
  717. memcpy (&fragmentation_data[fragment_size],
  718. (unsigned char *)iovec[i].iov_base + copy_base, copy_len);
  719. }
  720. memcpy (&fragmentation_data[fragment_size],
  721. (unsigned char *)iovec[i].iov_base + copy_base, copy_len);
  722. mcast_packed_msg_lens[mcast_packed_msg_count] += copy_len;
  723. /*
  724. * if we're not on the last iovec or the iovec is too large to
  725. * fit, then indicate a fragment. This also means that the next
  726. * message will have the continuation of this one.
  727. */
  728. if ((i < (iov_len - 1)) ||
  729. ((copy_base + copy_len) < iovec[i].iov_len)) {
  730. if (!next_fragment) {
  731. next_fragment++;
  732. }
  733. fragment_continuation = next_fragment;
  734. mcast.fragmented = next_fragment++;
  735. assert(fragment_continuation != 0);
  736. assert(mcast.fragmented != 0);
  737. } else {
  738. fragment_continuation = 0;
  739. }
  740. /*
  741. * assemble the message and send it
  742. */
  743. mcast.msg_count = ++mcast_packed_msg_count;
  744. iovecs[0].iov_base = (void *)&mcast;
  745. iovecs[0].iov_len = sizeof(struct totempg_mcast);
  746. iovecs[1].iov_base = (void *)mcast_packed_msg_lens;
  747. iovecs[1].iov_len = mcast_packed_msg_count *
  748. sizeof(unsigned short);
  749. iovecs[2].iov_base = (void *)data_ptr;
  750. iovecs[2].iov_len = max_packet_size;
  751. assert (totemmrp_avail() > 0);
  752. res = totemmrp_mcast (iovecs, 3, guarantee);
  753. /*
  754. * Recalculate counts and indexes for the next.
  755. */
  756. mcast_packed_msg_lens[0] = 0;
  757. mcast_packed_msg_count = 0;
  758. fragment_size = 0;
  759. max_packet_size = TOTEMPG_PACKET_SIZE - (sizeof(unsigned short));
  760. /*
  761. * If the iovec all fit, go to the next iovec
  762. */
  763. if ((copy_base + copy_len) == iovec[i].iov_len) {
  764. copy_len = 0;
  765. copy_base = 0;
  766. i++;
  767. /*
  768. * Continue with the rest of the current iovec.
  769. */
  770. } else {
  771. copy_base += copy_len;
  772. }
  773. }
  774. }
  775. /*
  776. * Bump only if we added message data. This may be zero if
  777. * the last buffer just fit into the fragmentation_data buffer
  778. * and we were at the last iovec.
  779. */
  780. if (mcast_packed_msg_lens[mcast_packed_msg_count]) {
  781. mcast_packed_msg_count++;
  782. }
  783. pthread_mutex_unlock (&mcast_msg_mutex);
  784. return (res);
  785. }
  786. /*
  787. * Determine if a message of msg_size could be queued
  788. */
  789. static int msg_count_send_ok (
  790. int msg_count)
  791. {
  792. int avail = 0;
  793. avail = totemmrp_avail () - totempg_reserved - 1;
  794. return (avail > msg_count);
  795. }
  796. static int byte_count_send_ok (
  797. int byte_count)
  798. {
  799. unsigned int msg_count = 0;
  800. int avail = 0;
  801. avail = totemmrp_avail () - 1;
  802. msg_count = (byte_count / (totempg_totem_config->net_mtu - 25)) + 1;
  803. return (avail > msg_count);
  804. }
  805. static int send_reserve (
  806. int msg_size)
  807. {
  808. unsigned int msg_count = 0;
  809. msg_count = (msg_size / (totempg_totem_config->net_mtu - 25)) + 1;
  810. totempg_reserved += msg_count;
  811. return (msg_count);
  812. }
  813. static void send_release (
  814. int msg_count)
  815. {
  816. totempg_reserved -= msg_count;
  817. }
  818. int totempg_callback_token_create (
  819. void **handle_out,
  820. enum totem_callback_token_type type,
  821. int delete,
  822. int (*callback_fn) (enum totem_callback_token_type type, const void *),
  823. const void *data)
  824. {
  825. unsigned int res;
  826. pthread_mutex_lock (&callback_token_mutex);
  827. res = totemmrp_callback_token_create (handle_out, type, delete,
  828. callback_fn, data);
  829. pthread_mutex_unlock (&callback_token_mutex);
  830. return (res);
  831. }
  832. void totempg_callback_token_destroy (
  833. void *handle_out)
  834. {
  835. pthread_mutex_lock (&callback_token_mutex);
  836. totemmrp_callback_token_destroy (handle_out);
  837. pthread_mutex_unlock (&callback_token_mutex);
  838. }
  839. /*
  840. * vi: set autoindent tabstop=4 shiftwidth=4 :
  841. */
  842. int totempg_groups_initialize (
  843. hdb_handle_t *handle,
  844. void (*deliver_fn) (
  845. unsigned int nodeid,
  846. const void *msg,
  847. unsigned int msg_len,
  848. int endian_conversion_required),
  849. void (*confchg_fn) (
  850. enum totem_configuration_type configuration_type,
  851. const unsigned int *member_list, size_t member_list_entries,
  852. const unsigned int *left_list, size_t left_list_entries,
  853. const unsigned int *joined_list, size_t joined_list_entries,
  854. const struct memb_ring_id *ring_id))
  855. {
  856. struct totempg_group_instance *instance;
  857. unsigned int res;
  858. pthread_mutex_lock (&totempg_mutex);
  859. res = hdb_handle_create (&totempg_groups_instance_database,
  860. sizeof (struct totempg_group_instance), handle);
  861. if (res != 0) {
  862. goto error_exit;
  863. }
  864. if (*handle > totempg_max_handle) {
  865. totempg_max_handle = *handle;
  866. }
  867. res = hdb_handle_get (&totempg_groups_instance_database, *handle,
  868. (void *)&instance);
  869. if (res != 0) {
  870. goto error_destroy;
  871. }
  872. instance->deliver_fn = deliver_fn;
  873. instance->confchg_fn = confchg_fn;
  874. instance->groups = 0;
  875. instance->groups_cnt = 0;
  876. hdb_handle_put (&totempg_groups_instance_database, *handle);
  877. pthread_mutex_unlock (&totempg_mutex);
  878. return (0);
  879. error_destroy:
  880. hdb_handle_destroy (&totempg_groups_instance_database, *handle);
  881. error_exit:
  882. pthread_mutex_unlock (&totempg_mutex);
  883. return (-1);
  884. }
  885. int totempg_groups_join (
  886. hdb_handle_t handle,
  887. const struct totempg_group *groups,
  888. size_t group_cnt)
  889. {
  890. struct totempg_group_instance *instance;
  891. struct totempg_group *new_groups;
  892. unsigned int res;
  893. pthread_mutex_lock (&totempg_mutex);
  894. res = hdb_handle_get (&totempg_groups_instance_database, handle,
  895. (void *)&instance);
  896. if (res != 0) {
  897. goto error_exit;
  898. }
  899. new_groups = realloc (instance->groups,
  900. sizeof (struct totempg_group) *
  901. (instance->groups_cnt + group_cnt));
  902. if (new_groups == 0) {
  903. res = ENOMEM;
  904. goto error_exit;
  905. }
  906. memcpy (&new_groups[instance->groups_cnt],
  907. groups, group_cnt * sizeof (struct totempg_group));
  908. instance->groups = new_groups;
  909. instance->groups_cnt += group_cnt;
  910. hdb_handle_put (&totempg_groups_instance_database, handle);
  911. error_exit:
  912. pthread_mutex_unlock (&totempg_mutex);
  913. return (res);
  914. }
  915. int totempg_groups_leave (
  916. hdb_handle_t handle,
  917. const struct totempg_group *groups,
  918. size_t group_cnt)
  919. {
  920. struct totempg_group_instance *instance;
  921. unsigned int res;
  922. pthread_mutex_lock (&totempg_mutex);
  923. res = hdb_handle_get (&totempg_groups_instance_database, handle,
  924. (void *)&instance);
  925. if (res != 0) {
  926. goto error_exit;
  927. }
  928. hdb_handle_put (&totempg_groups_instance_database, handle);
  929. error_exit:
  930. pthread_mutex_unlock (&totempg_mutex);
  931. return (res);
  932. }
  933. #define MAX_IOVECS_FROM_APP 32
  934. #define MAX_GROUPS_PER_MSG 32
  935. int totempg_groups_mcast_joined (
  936. hdb_handle_t handle,
  937. const struct iovec *iovec,
  938. unsigned int iov_len,
  939. int guarantee)
  940. {
  941. struct totempg_group_instance *instance;
  942. unsigned short group_len[MAX_GROUPS_PER_MSG + 1];
  943. struct iovec iovec_mcast[MAX_GROUPS_PER_MSG + 1 + MAX_IOVECS_FROM_APP];
  944. int i;
  945. unsigned int res;
  946. pthread_mutex_lock (&totempg_mutex);
  947. res = hdb_handle_get (&totempg_groups_instance_database, handle,
  948. (void *)&instance);
  949. if (res != 0) {
  950. goto error_exit;
  951. }
  952. /*
  953. * Build group_len structure and the iovec_mcast structure
  954. */
  955. group_len[0] = instance->groups_cnt;
  956. for (i = 0; i < instance->groups_cnt; i++) {
  957. group_len[i + 1] = instance->groups[i].group_len;
  958. iovec_mcast[i + 1].iov_len = instance->groups[i].group_len;
  959. iovec_mcast[i + 1].iov_base = (void *) instance->groups[i].group;
  960. }
  961. iovec_mcast[0].iov_len = (instance->groups_cnt + 1) * sizeof (unsigned short);
  962. iovec_mcast[0].iov_base = group_len;
  963. for (i = 0; i < iov_len; i++) {
  964. iovec_mcast[i + instance->groups_cnt + 1].iov_len = iovec[i].iov_len;
  965. iovec_mcast[i + instance->groups_cnt + 1].iov_base = iovec[i].iov_base;
  966. }
  967. res = mcast_msg (iovec_mcast, iov_len + instance->groups_cnt + 1, guarantee);
  968. hdb_handle_put (&totempg_groups_instance_database, handle);
  969. error_exit:
  970. pthread_mutex_unlock (&totempg_mutex);
  971. return (res);
  972. }
  973. int totempg_groups_joined_reserve (
  974. hdb_handle_t handle,
  975. const struct iovec *iovec,
  976. unsigned int iov_len)
  977. {
  978. struct totempg_group_instance *instance;
  979. unsigned int size = 0;
  980. unsigned int i;
  981. unsigned int res;
  982. unsigned int reserved = 0;
  983. pthread_mutex_lock (&totempg_mutex);
  984. pthread_mutex_lock (&mcast_msg_mutex);
  985. res = hdb_handle_get (&totempg_groups_instance_database, handle,
  986. (void *)&instance);
  987. if (res != 0) {
  988. goto error_exit;
  989. }
  990. for (i = 0; i < instance->groups_cnt; i++) {
  991. size += instance->groups[i].group_len;
  992. }
  993. for (i = 0; i < iov_len; i++) {
  994. size += iovec[i].iov_len;
  995. }
  996. reserved = send_reserve (size);
  997. if (msg_count_send_ok (reserved) == 0) {
  998. send_release (reserved);
  999. reserved = 0;
  1000. }
  1001. hdb_handle_put (&totempg_groups_instance_database, handle);
  1002. error_exit:
  1003. pthread_mutex_unlock (&mcast_msg_mutex);
  1004. pthread_mutex_unlock (&totempg_mutex);
  1005. return (reserved);
  1006. }
  1007. int totempg_groups_joined_release (int msg_count)
  1008. {
  1009. pthread_mutex_lock (&totempg_mutex);
  1010. pthread_mutex_lock (&mcast_msg_mutex);
  1011. send_release (msg_count);
  1012. pthread_mutex_unlock (&mcast_msg_mutex);
  1013. pthread_mutex_unlock (&totempg_mutex);
  1014. return 0;
  1015. }
  1016. int totempg_groups_mcast_groups (
  1017. hdb_handle_t handle,
  1018. int guarantee,
  1019. const struct totempg_group *groups,
  1020. size_t groups_cnt,
  1021. const struct iovec *iovec,
  1022. unsigned int iov_len)
  1023. {
  1024. struct totempg_group_instance *instance;
  1025. unsigned short group_len[MAX_GROUPS_PER_MSG + 1];
  1026. struct iovec iovec_mcast[MAX_GROUPS_PER_MSG + 1 + MAX_IOVECS_FROM_APP];
  1027. int i;
  1028. unsigned int res;
  1029. pthread_mutex_lock (&totempg_mutex);
  1030. res = hdb_handle_get (&totempg_groups_instance_database, handle,
  1031. (void *)&instance);
  1032. if (res != 0) {
  1033. goto error_exit;
  1034. }
  1035. /*
  1036. * Build group_len structure and the iovec_mcast structure
  1037. */
  1038. group_len[0] = groups_cnt;
  1039. for (i = 0; i < groups_cnt; i++) {
  1040. group_len[i + 1] = groups[i].group_len;
  1041. iovec_mcast[i + 1].iov_len = groups[i].group_len;
  1042. iovec_mcast[i + 1].iov_base = (void *) groups[i].group;
  1043. }
  1044. iovec_mcast[0].iov_len = (groups_cnt + 1) * sizeof (unsigned short);
  1045. iovec_mcast[0].iov_base = group_len;
  1046. for (i = 0; i < iov_len; i++) {
  1047. iovec_mcast[i + groups_cnt + 1].iov_len = iovec[i].iov_len;
  1048. iovec_mcast[i + groups_cnt + 1].iov_base = iovec[i].iov_base;
  1049. }
  1050. res = mcast_msg (iovec_mcast, iov_len + groups_cnt + 1, guarantee);
  1051. hdb_handle_put (&totempg_groups_instance_database, handle);
  1052. error_exit:
  1053. pthread_mutex_unlock (&totempg_mutex);
  1054. return (res);
  1055. }
  1056. /*
  1057. * Returns -1 if error, 0 if can't send, 1 if can send the message
  1058. */
  1059. int totempg_groups_send_ok_groups (
  1060. hdb_handle_t handle,
  1061. const struct totempg_group *groups,
  1062. size_t groups_cnt,
  1063. const struct iovec *iovec,
  1064. unsigned int iov_len)
  1065. {
  1066. struct totempg_group_instance *instance;
  1067. unsigned int size = 0;
  1068. unsigned int i;
  1069. unsigned int res;
  1070. pthread_mutex_lock (&totempg_mutex);
  1071. res = hdb_handle_get (&totempg_groups_instance_database, handle,
  1072. (void *)&instance);
  1073. if (res != 0) {
  1074. goto error_exit;
  1075. }
  1076. for (i = 0; i < groups_cnt; i++) {
  1077. size += groups[i].group_len;
  1078. }
  1079. for (i = 0; i < iov_len; i++) {
  1080. size += iovec[i].iov_len;
  1081. }
  1082. res = msg_count_send_ok (size);
  1083. hdb_handle_put (&totempg_groups_instance_database, handle);
  1084. error_exit:
  1085. pthread_mutex_unlock (&totempg_mutex);
  1086. return (res);
  1087. }
  1088. int totempg_ifaces_get (
  1089. unsigned int nodeid,
  1090. struct totem_ip_address *interfaces,
  1091. char ***status,
  1092. unsigned int *iface_count)
  1093. {
  1094. int res;
  1095. res = totemmrp_ifaces_get (
  1096. nodeid,
  1097. interfaces,
  1098. status,
  1099. iface_count);
  1100. return (res);
  1101. }
  1102. int totempg_crypto_set (
  1103. unsigned int type)
  1104. {
  1105. int res;
  1106. res = totemmrp_crypto_set (
  1107. type);
  1108. return (res);
  1109. }
  1110. int totempg_ring_reenable (void)
  1111. {
  1112. int res;
  1113. res = totemmrp_ring_reenable ();
  1114. return (res);
  1115. }
  1116. const char *totempg_ifaces_print (unsigned int nodeid)
  1117. {
  1118. static char iface_string[256 * INTERFACE_MAX];
  1119. char one_iface[64];
  1120. struct totem_ip_address interfaces[INTERFACE_MAX];
  1121. char **status;
  1122. unsigned int iface_count;
  1123. unsigned int i;
  1124. int res;
  1125. iface_string[0] = '\0';
  1126. res = totempg_ifaces_get (nodeid, interfaces, &status, &iface_count);
  1127. if (res == -1) {
  1128. return ("no interface found for nodeid");
  1129. }
  1130. for (i = 0; i < iface_count; i++) {
  1131. sprintf (one_iface, "r(%d) ip(%s) ",
  1132. i, totemip_print (&interfaces[i]));
  1133. strcat (iface_string, one_iface);
  1134. }
  1135. return (iface_string);
  1136. }
  1137. unsigned int totempg_my_nodeid_get (void)
  1138. {
  1139. return (totemmrp_my_nodeid_get());
  1140. }
  1141. int totempg_my_family_get (void)
  1142. {
  1143. return (totemmrp_my_family_get());
  1144. }