totempg.c 34 KB

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