55 #include <sys/types.h> 57 #include <sys/socket.h> 60 #include <sys/ioctl.h> 61 #include <sys/param.h> 62 #include <netinet/in.h> 63 #include <arpa/inet.h> 76 #include <qb/qblist.h> 77 #include <qb/qbdefs.h> 78 #include <qb/qbutil.h> 79 #include <qb/qbloop.h> 84 #define LOGSYS_UTILS_ONLY 1 92 #define LOCALHOST_IP inet_addr("127.0.0.1") 93 #define QUEUE_RTR_ITEMS_SIZE_MAX 16384 94 #define RETRANS_MESSAGE_QUEUE_SIZE_MAX 16384 95 #define RECEIVED_MESSAGE_QUEUE_SIZE_MAX 500 97 #define RETRANSMIT_ENTRIES_MAX 30 98 #define TOKEN_SIZE_MAX 64000 99 #define LEAVE_DUMMY_NODEID 0 118 #define SEQNO_START_MSG 0x0 119 #define SEQNO_START_TOKEN 0x0 141 #define ENDIAN_LOCAL 0xff22 167 struct qb_list_head list;
266 unsigned int msg_len;
374 struct sq regular_sort_queue;
376 struct sq recovery_sort_queue;
385 struct qb_list_head token_callback_received_listhead;
387 struct qb_list_head token_callback_sent_listhead;
435 void (*totemsrp_log_printf) (
438 const char *
function,
441 const char *format, ...)
__attribute__((format(printf, 6, 7)));;
451 void (*totemsrp_deliver_fn) (
454 unsigned int msg_len,
455 int endian_conversion_required);
457 void (*totemsrp_confchg_fn) (
459 const unsigned int *member_list,
size_t member_list_entries,
460 const unsigned int *left_list,
size_t left_list_entries,
461 const unsigned int *joined_list,
size_t joined_list_entries,
464 void (*totemsrp_service_ready_fn) (void);
466 void (*totemsrp_waiting_trans_ack_cb_fn) (
467 int waiting_trans_ack);
469 void (*memb_ring_id_create_or_load) (
473 void (*memb_ring_id_store) (
474 const struct memb_ring_id *memb_ring_id,
527 char commit_token_storage[40000];
532 int (*handler_functions[6]) (
536 int endian_conversion_needed);
581 static int message_handler_orf_token (
585 int endian_conversion_needed);
587 static int message_handler_mcast (
591 int endian_conversion_needed);
593 static int message_handler_memb_merge_detect (
597 int endian_conversion_needed);
599 static int message_handler_memb_join (
603 int endian_conversion_needed);
605 static int message_handler_memb_commit_token (
609 int endian_conversion_needed);
611 static int message_handler_token_hold_cancel (
615 int endian_conversion_needed);
619 static void srp_addr_copy (
struct srp_addr *dest,
const struct srp_addr *src);
621 static void srp_addr_to_nodeid (
623 unsigned int *nodeid_out,
625 unsigned int entries);
627 static int srp_addr_equal (
const struct srp_addr *a,
const struct srp_addr *b);
633 static void messages_deliver_to_app (
struct totemsrp_instance *instance,
int skip,
unsigned int end_point);
635 int fcc_mcasts_allowed);
636 static void messages_free (
struct totemsrp_instance *instance,
unsigned int token_aru);
640 static void target_set_completed (
void *context);
642 static void memb_state_commit_token_target_set (
struct totemsrp_instance *instance);
647 static void orf_token_endian_convert (
const struct orf_token *in,
struct orf_token *out);
648 static void memb_commit_token_endian_convert (
const struct memb_commit_token *in,
struct memb_commit_token *out);
649 static void memb_join_endian_convert (
const struct memb_join *in,
struct memb_join *out);
650 static void mcast_endian_convert (
const struct mcast *in,
struct mcast *out);
651 static void memb_merge_detect_endian_convert (
654 static void srp_addr_copy_endian_convert (
struct srp_addr *out,
const struct srp_addr *in);
655 static void timer_function_orf_token_timeout (
void *data);
656 static void timer_function_orf_token_warning (
void *data);
657 static void timer_function_pause_timeout (
void *data);
658 static void timer_function_heartbeat_timeout (
void *data);
659 static void timer_function_token_retransmit_timeout (
void *data);
660 static void timer_function_token_hold_retransmit_timeout (
void *data);
661 static void timer_function_merge_detect_timeout (
void *data);
663 static void totemsrp_buffer_release (
struct totemsrp_instance *instance,
void *ptr);
669 unsigned int msg_len,
675 unsigned int iface_no);
680 message_handler_orf_token,
681 message_handler_mcast,
682 message_handler_memb_merge_detect,
683 message_handler_memb_join,
684 message_handler_memb_commit_token,
685 message_handler_token_hold_cancel
689 #define log_printf(level, format, args...) \ 691 instance->totemsrp_log_printf ( \ 692 level, instance->totemsrp_subsys_id, \ 693 __FUNCTION__, __FILE__, __LINE__, \ 696 #define LOGSYS_PERROR(err_num, level, fmt, args...) \ 698 char _error_str[LOGSYS_MAX_PERROR_MSG_LEN]; \ 699 const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str)); \ 700 instance->totemsrp_log_printf ( \ 701 level, instance->totemsrp_subsys_id, \ 702 __FUNCTION__, __FILE__, __LINE__, \ 703 fmt ": %s (%d)\n", ##args, _error_ptr, err_num); \ 709 return gather_state_from_desc[gsfrom];
750 uint64_t timestamp_msec;
753 now_msec = (qb_util_nano_current_get () / QB_TIME_NS_IN_MSEC);
758 "Process pause detected for %d ms, flushing membership messages.", (
unsigned int)(now_msec - timestamp_msec));
773 unsigned long long nano_secs = qb_util_nano_current_get ();
775 time_now = (nano_secs / QB_TIME_NS_IN_MSEC);
804 static void totempg_mtu_changed(
void *context,
int net_mtu)
811 "Net MTU changed to %d, new value is %d",
819 qb_loop_t *poll_handle,
827 unsigned int msg_len,
828 int endian_conversion_required),
832 const unsigned int *member_list,
size_t member_list_entries,
833 const unsigned int *left_list,
size_t left_list_entries,
834 const unsigned int *joined_list,
size_t joined_list_entries,
836 void (*waiting_trans_ack_cb_fn) (
837 int waiting_trans_ack))
843 if (instance == NULL) {
847 totemsrp_instance_initialize (instance);
885 "Token Timeout (%d ms) retransmit timeout (%d ms)",
890 "Token warning every %d ms (%d%% of Token Timeout)",
892 if (token_warning_ms < totem_config->token_retransmit_timeout)
894 "The token warning interval (%d ms) is less than the token retransmit timeout (%d ms) " 895 "which can lead to spurious token warnings. Consider increasing the token_warning parameter.",
899 "Token warnings disabled");
902 "token hold (%d ms) retransmits before loss (%d retrans)",
905 "join (%d ms) send_join (%d ms) consensus (%d ms) merge (%d ms)",
912 "downcheck (%d ms) fail to recv const (%d msgs)",
918 "window size per rotation (%d messages) maximum messages per rotation (%d messages)",
922 "missed count const (%d messages)",
926 "send threads (%d threads)", totem_config->
threads);
950 timer_function_pause_timeout (instance);
954 "HeartBeat is Disabled. To enable set heartbeat_failures_allowed > 0");
965 "total heartbeat_timeout (%d ms) is not less than token timeout (%d ms)",
969 "heartbeat_timeout = heartbeat_failures_allowed * token_retransmit_timeout + max_network_delay");
971 "heartbeat timeout should be less than the token timeout. Heartbeat is disabled!!");
987 main_iface_change_fn,
989 target_set_completed);
1011 token_event_stats_collector,
1017 token_event_stats_collector,
1019 *srp_context = instance;
1031 memb_leave_message_send (instance);
1051 unsigned int nodeid,
1052 unsigned int *interface_id,
1054 unsigned int interfaces_size,
1056 unsigned int *iface_count)
1072 interface_id[num_ifs] = i;
1074 if (++num_ifs > interfaces_size) {
1083 *iface_count = num_ifs;
1089 const char *cipher_type,
1090 const char *hash_type)
1127 static int srp_addr_equal (
const struct srp_addr *a,
const struct srp_addr *b)
1135 static void srp_addr_copy (
struct srp_addr *dest,
const struct srp_addr *src)
1140 static void srp_addr_to_nodeid (
1142 unsigned int *nodeid_out,
1144 unsigned int entries)
1148 for (i = 0; i < entries; i++) {
1149 nodeid_out[i] = srp_addr_in[i].
nodeid;
1153 static void srp_addr_copy_endian_convert (
struct srp_addr *out,
const struct srp_addr *in)
1163 static void memb_set_subtract (
1164 struct srp_addr *out_list,
int *out_list_entries,
1165 struct srp_addr *one_list,
int one_list_entries,
1166 struct srp_addr *two_list,
int two_list_entries)
1172 *out_list_entries = 0;
1174 for (i = 0; i < one_list_entries; i++) {
1175 for (j = 0; j < two_list_entries; j++) {
1176 if (srp_addr_equal (&one_list[i], &two_list[j])) {
1182 srp_addr_copy (&out_list[*out_list_entries], &one_list[i]);
1183 *out_list_entries = *out_list_entries + 1;
1192 static void memb_consensus_set (
1216 static int memb_consensus_isset (
1233 static int memb_consensus_agreed (
1236 struct srp_addr token_memb[PROCESSOR_COUNT_MAX];
1237 int token_memb_entries = 0;
1241 memb_set_subtract (token_memb, &token_memb_entries,
1245 for (i = 0; i < token_memb_entries; i++) {
1246 if (memb_consensus_isset (instance, &token_memb[i]) == 0) {
1261 assert (token_memb_entries >= 1);
1266 static void memb_consensus_notset (
1268 struct srp_addr *no_consensus_list,
1269 int *no_consensus_list_entries,
1271 int comparison_list_entries)
1275 *no_consensus_list_entries = 0;
1278 if (memb_consensus_isset (instance, &instance->
my_proc_list[i]) == 0) {
1279 srp_addr_copy (&no_consensus_list[*no_consensus_list_entries], &instance->
my_proc_list[i]);
1280 *no_consensus_list_entries = *no_consensus_list_entries + 1;
1288 static int memb_set_equal (
1289 struct srp_addr *set1,
int set1_entries,
1290 struct srp_addr *set2,
int set2_entries)
1297 if (set1_entries != set2_entries) {
1300 for (i = 0; i < set2_entries; i++) {
1301 for (j = 0; j < set1_entries; j++) {
1302 if (srp_addr_equal (&set1[j], &set2[i])) {
1318 static int memb_set_subset (
1319 const struct srp_addr *subset,
int subset_entries,
1320 const struct srp_addr *fullset,
int fullset_entries)
1326 if (subset_entries > fullset_entries) {
1329 for (i = 0; i < subset_entries; i++) {
1330 for (j = 0; j < fullset_entries; j++) {
1331 if (srp_addr_equal (&subset[i], &fullset[j])) {
1345 static void memb_set_merge (
1346 const struct srp_addr *subset,
int subset_entries,
1347 struct srp_addr *fullset,
int *fullset_entries)
1353 for (i = 0; i < subset_entries; i++) {
1354 for (j = 0; j < *fullset_entries; j++) {
1355 if (srp_addr_equal (&fullset[j], &subset[i])) {
1361 srp_addr_copy (&fullset[*fullset_entries], &subset[i]);
1362 *fullset_entries = *fullset_entries + 1;
1369 static void memb_set_and_with_ring_id (
1385 for (i = 0; i < set2_entries; i++) {
1386 for (j = 0; j < set1_entries; j++) {
1387 if (srp_addr_equal (&set1[j], &set2[i])) {
1388 if (memcmp (&set1_ring_ids[j], old_ring_id,
sizeof (
struct memb_ring_id)) == 0) {
1395 srp_addr_copy (&and[*and_entries], &set1[j]);
1396 *and_entries = *and_entries + 1;
1403 static void memb_set_log(
1414 memset(list_str, 0,
sizeof(list_str));
1416 for (i = 0; i < list_entries; i++) {
1418 snprintf(int_buf,
sizeof(int_buf),
CS_PRI_NODE_ID, list[i].nodeid);
1420 snprintf(int_buf,
sizeof(int_buf),
"," CS_PRI_NODE_ID, list[i].nodeid);
1423 if (strlen(list_str) + strlen(int_buf) >=
sizeof(list_str)) {
1426 strcat(list_str, int_buf);
1429 log_printf(level,
"List '%s' contains %d entries: %s",
string, list_entries, list_str);
1432 static void my_leave_memb_clear(
1439 static unsigned int my_leave_memb_match(
1441 unsigned int nodeid)
1444 unsigned int ret = 0;
1455 static void my_leave_memb_set(
1457 unsigned int nodeid)
1481 assert (instance != NULL);
1485 static void totemsrp_buffer_release (
struct totemsrp_instance *instance,
void *ptr)
1487 assert (instance != NULL);
1501 timer_function_token_retransmit_timeout,
1504 log_printf(instance->totemsrp_log_level_error,
"reset_token_retransmit_timeout - qb_loop_timer_add error : %d", res);
1518 timer_function_merge_detect_timeout,
1521 log_printf(instance->totemsrp_log_level_error,
"start_merge_detect_timeout - qb_loop_timer_add error : %d", res);
1524 instance->my_merge_detect_timeout_outstanding = 1;
1547 "Saving state aru %x high seq received %x",
1557 "Restoring instance->my_aru %x my high seq received %x",
1564 "Resetting old ring state");
1577 timer_function_pause_timeout,
1580 log_printf(instance->totemsrp_log_level_error,
"reset_pause_timeout - qb_loop_timer_add error : %d", res);
1592 timer_function_orf_token_warning,
1595 log_printf(instance->totemsrp_log_level_error,
"reset_token_warning - qb_loop_timer_add error : %d", res);
1607 timer_function_orf_token_timeout,
1610 log_printf(instance->totemsrp_log_level_error,
"reset_token_timeout - qb_loop_timer_add error : %d", res);
1613 if (instance->totem_config->token_warning)
1614 reset_token_warning(instance);
1625 timer_function_heartbeat_timeout,
1628 log_printf(instance->totemsrp_log_level_error,
"reset_heartbeat_timeout - qb_loop_timer_add error : %d", res);
1641 cancel_token_warning(instance);
1648 static void cancel_token_retransmit_timeout (
struct totemsrp_instance *instance)
1653 static void start_token_hold_retransmit_timeout (
struct totemsrp_instance *instance)
1661 timer_function_token_hold_retransmit_timeout,
1664 log_printf(instance->totemsrp_log_level_error,
"start_token_hold_retransmit_timeout - qb_loop_timer_add error : %d", res);
1668 static void cancel_token_hold_retransmit_timeout (
struct totemsrp_instance *instance)
1674 static void memb_state_consensus_timeout_expired (
1677 struct srp_addr no_consensus_list[PROCESSOR_COUNT_MAX];
1678 int no_consensus_list_entries;
1681 if (memb_consensus_agreed (instance)) {
1682 memb_consensus_reset (instance);
1684 memb_consensus_set (instance, &instance->
my_id);
1686 reset_token_timeout (instance);
1688 memb_consensus_notset (
1691 &no_consensus_list_entries,
1695 memb_set_merge (no_consensus_list, no_consensus_list_entries,
1708 static void timer_function_pause_timeout (
void *data)
1713 reset_pause_timeout (instance);
1718 old_ring_state_restore (instance);
1723 static void timer_function_orf_token_warning (
void *data)
1730 tv_diff = qb_util_nano_current_get () / QB_TIME_NS_IN_MSEC -
1733 "Token has not been received in %d ms ", (
unsigned int) tv_diff);
1734 reset_token_warning(instance);
1736 cancel_token_warning(instance);
1740 static void timer_function_orf_token_timeout (
void *data)
1747 "The token was lost in the OPERATIONAL state.");
1749 "A processor failed, forming new configuration.");
1757 "The consensus timeout expired.");
1758 memb_state_consensus_timeout_expired (instance);
1765 "The token was lost in the COMMIT state.");
1772 "The token was lost in the RECOVERY state.");
1773 memb_recovery_state_token_loss (instance);
1779 static void timer_function_heartbeat_timeout (
void *data)
1783 "HeartBeat Timer expired Invoking token loss mechanism in state %d ", instance->
memb_state);
1784 timer_function_orf_token_timeout(data);
1787 static void memb_timer_function_state_gather (
void *data)
1799 memb_join_message_send (instance);
1810 memb_timer_function_state_gather,
1811 &instance->memb_timer_state_gather_join_timeout);
1814 log_printf(instance->totemsrp_log_level_error,
"memb_timer_function_state_gather - qb_loop_timer_add error : %d", res);
1820 static void memb_timer_function_gather_consensus_timeout (
void *data)
1823 memb_state_consensus_timeout_expired (instance);
1826 static void deliver_messages_from_recovery_to_regular (
struct totemsrp_instance *instance)
1831 unsigned int range = 0;
1844 for (i = 1; i <= range; i++) {
1850 recovery_message_item = ptr;
1855 mcast = recovery_message_item->
mcast;
1861 regular_message_item.
mcast =
1862 (
struct mcast *)(((
char *)recovery_message_item->
mcast) +
sizeof (
struct mcast));
1863 regular_message_item.
msg_len =
1864 recovery_message_item->
msg_len -
sizeof (
struct mcast);
1865 mcast = regular_message_item.
mcast;
1875 (uint64_t)mcast->
seq);
1888 ®ular_message_item, mcast->
seq);
1905 struct srp_addr joined_list[PROCESSOR_COUNT_MAX];
1906 int joined_list_entries = 0;
1907 unsigned int aru_save;
1914 char left_node_msg[1024];
1915 char joined_node_msg[1024];
1916 char failed_node_msg[1024];
1920 memb_consensus_reset (instance);
1922 old_ring_state_reset (instance);
1924 deliver_messages_from_recovery_to_regular (instance);
1927 "Delivering to app %x to %x",
1930 aru_save = instance->
my_aru;
1943 memb_set_subtract (joined_list, &joined_list_entries,
1961 srp_addr_to_nodeid (instance, trans_memb_list_totemip,
1974 instance->
my_aru = aru_save;
1979 srp_addr_to_nodeid (instance, new_memb_list_totemip,
1981 srp_addr_to_nodeid (instance, joined_list_totemip, joined_list,
1982 joined_list_entries);
1986 joined_list_totemip, joined_list_entries, &instance->
my_ring_id);
2048 regular_message = ptr;
2049 free (regular_message->
mcast);
2055 if (joined_list_entries) {
2057 sptr += snprintf(joined_node_msg,
sizeof(joined_node_msg)-sptr,
" joined:");
2058 for (i=0; i< joined_list_entries; i++) {
2059 sptr += snprintf(joined_node_msg+sptr,
sizeof(joined_node_msg)-sptr,
" " CS_PRI_NODE_ID, joined_list_totemip[i]);
2063 joined_node_msg[0] =
'\0';
2069 sptr += snprintf(left_node_msg,
sizeof(left_node_msg)-sptr,
" left:");
2071 sptr += snprintf(left_node_msg+sptr,
sizeof(left_node_msg)-sptr,
" " CS_PRI_NODE_ID, left_list[i]);
2074 if (my_leave_memb_match(instance, left_list[i]) == 0) {
2076 sptr2 += snprintf(failed_node_msg,
sizeof(failed_node_msg)-sptr2,
" failed:");
2078 sptr2 += snprintf(failed_node_msg+sptr2,
sizeof(left_node_msg)-sptr2,
" " CS_PRI_NODE_ID, left_list[i]);
2082 failed_node_msg[0] =
'\0';
2086 left_node_msg[0] =
'\0';
2087 failed_node_msg[0] =
'\0';
2090 my_leave_memb_clear(instance);
2093 "entering OPERATIONAL state.");
2101 if (strlen(failed_node_msg)) {
2103 "Failed to receive the leave message.%s",
2114 reset_pause_timeout (instance);
2127 static void memb_state_gather_enter (
2138 &instance->
my_id, 1,
2141 memb_join_message_send (instance);
2152 memb_timer_function_state_gather,
2153 &instance->memb_timer_state_gather_join_timeout);
2155 log_printf(instance->totemsrp_log_level_error,
"memb_state_gather_enter - qb_loop_timer_add error(1) : %d", res);
2161 qb_loop_timer_del (instance->totemsrp_poll_handle,
2162 instance->memb_timer_state_gather_consensus_timeout);
2164 res = qb_loop_timer_add (instance->totemsrp_poll_handle,
2166 instance->totem_config->consensus_timeout*QB_TIME_NS_IN_MSEC,
2168 memb_timer_function_gather_consensus_timeout,
2169 &instance->memb_timer_state_gather_consensus_timeout);
2171 log_printf(instance->totemsrp_log_level_error,
"memb_state_gather_enter - qb_loop_timer_add error(2) : %d", res);
2177 cancel_token_retransmit_timeout (instance);
2178 cancel_token_timeout (instance);
2179 cancel_merge_detect_timeout (instance);
2181 memb_consensus_reset (instance);
2183 memb_consensus_set (instance, &instance->my_id);
2185 log_printf (instance->totemsrp_log_level_debug,
2186 "entering GATHER state from %d(%s).",
2187 gather_from, gsfrom_to_msg(gather_from));
2190 instance->stats.gather_entered++;
2196 instance->stats.continuous_gather++;
2202 static void timer_function_token_retransmit_timeout (
void *data);
2204 static void target_set_completed (
2209 memb_state_commit_token_send (instance);
2213 static void memb_state_commit_enter (
2216 old_ring_state_save (instance);
2218 memb_state_commit_token_update (instance);
2220 memb_state_commit_token_target_set (instance);
2237 "entering COMMIT state.");
2240 reset_token_retransmit_timeout (instance);
2241 reset_token_timeout (instance);
2257 static void memb_state_recovery_enter (
2262 int local_received_flg = 1;
2263 unsigned int low_ring_aru;
2264 unsigned int range = 0;
2265 unsigned int messages_originated = 0;
2268 struct memb_ring_id my_new_memb_ring_id_list[PROCESSOR_COUNT_MAX];
2274 "entering RECOVERY state.");
2285 memb_state_commit_token_send_recovery (instance, commit_token);
2300 memcpy (&my_new_memb_ring_id_list[i],
2301 &memb_list[i].ring_id,
2304 memb_set_and_with_ring_id (
2306 my_new_memb_ring_id_list,
2326 "aru %x high delivered %x received flag %d",
2344 local_received_flg = 0;
2348 if (local_received_flg == 1) {
2364 if (sq_lt_compare (memb_list[i].
aru, low_ring_aru)) {
2366 low_ring_aru = memb_list[i].
aru;
2387 "copying all old ring messages from %x-%x.",
2390 for (i = 1; i <= range; i++) {
2397 low_ring_aru + i, &ptr);
2401 sort_queue_item = ptr;
2402 messages_originated++;
2403 memset (&message_item, 0,
sizeof (
struct message_item));
2405 message_item.
mcast = totemsrp_buffer_alloc (instance);
2406 assert (message_item.
mcast);
2418 memcpy (((
char *)message_item.
mcast) + sizeof (
struct mcast),
2419 sort_queue_item->
mcast,
2424 "Originated %d messages in RECOVERY.", messages_originated);
2429 "Did not need to originate any messages in recovery.");
2439 reset_token_timeout (instance);
2440 reset_token_retransmit_timeout (instance);
2453 token_hold_cancel_send (instance);
2460 struct iovec *iovec,
2461 unsigned int iov_len,
2468 unsigned int addr_idx;
2477 if (cs_queue_is_full (queue_use)) {
2482 memset (&message_item, 0,
sizeof (
struct message_item));
2487 message_item.
mcast = totemsrp_buffer_alloc (instance);
2488 if (message_item.
mcast == 0) {
2495 memset(message_item.
mcast, 0, sizeof (
struct mcast));
2507 addr = (
char *)message_item.
mcast;
2508 addr_idx = sizeof (
struct mcast);
2509 for (i = 0; i < iov_len; i++) {
2510 memcpy (&addr[addr_idx], iovec[i].iov_base, iovec[i].iov_len);
2511 addr_idx += iovec[i].iov_len;
2514 message_item.
msg_len = addr_idx;
2518 cs_queue_item_add (queue_use, &message_item);
2540 cs_queue_avail (queue_use, &avail);
2551 static int orf_token_remcast (
2559 struct sq *sort_queue;
2567 res = sq_in_range (sort_queue, seq);
2576 res = sq_item_get (sort_queue, seq, &ptr);
2581 sort_queue_item = ptr;
2585 sort_queue_item->
mcast,
2595 static void messages_free (
2597 unsigned int token_aru)
2602 int log_release = 0;
2603 unsigned int release_to;
2604 unsigned int range = 0;
2606 release_to = token_aru;
2607 if (sq_lt_compare (instance->
my_last_aru, release_to)) {
2627 for (i = 1; i <= range; i++) {
2633 regular_message = ptr;
2634 totemsrp_buffer_release (instance, regular_message->
mcast);
2645 "releasing messages up to and including %x", release_to);
2649 static void update_aru (
2654 struct sq *sort_queue;
2656 unsigned int my_aru_saved = 0;
2666 my_aru_saved = instance->
my_aru;
2667 for (i = 1; i <= range; i++) {
2671 res = sq_item_get (sort_queue, my_aru_saved + i, &ptr);
2679 instance->
my_aru += i - 1;
2685 static int orf_token_mcast (
2688 int fcc_mcasts_allowed)
2692 struct sq *sort_queue;
2695 unsigned int fcc_mcast_current;
2700 reset_token_retransmit_timeout (instance);
2711 for (fcc_mcast_current = 0; fcc_mcast_current < fcc_mcasts_allowed; fcc_mcast_current++) {
2712 if (cs_queue_is_empty (mcast_queue)) {
2715 message_item = (
struct message_item *)cs_queue_item_get (mcast_queue);
2723 memset (&sort_queue_item, 0,
sizeof (
struct sort_queue_item));
2727 mcast = sort_queue_item.
mcast;
2734 sq_item_add (sort_queue, &sort_queue_item, message_item->
mcast->
seq);
2738 message_item->
mcast,
2744 cs_queue_item_remove (mcast_queue);
2752 update_aru (instance);
2757 return (fcc_mcast_current);
2764 static int orf_token_rtr (
2767 unsigned int *fcc_allowed)
2772 struct sq *sort_queue;
2774 unsigned int range = 0;
2775 char retransmit_msg[1024];
2784 rtr_list = &orf_token->
rtr_list[0];
2786 strcpy (retransmit_msg,
"Retransmit List: ");
2791 sprintf (value,
"%x ", rtr_list[i].seq);
2792 strcat (retransmit_msg, value);
2794 strcat (retransmit_msg,
"");
2796 "%s", retransmit_msg);
2809 if (memcmp (&rtr_list[i].ring_id, &instance->
my_ring_id,
2816 res = orf_token_remcast (instance, rtr_list[i].seq);
2823 memmove (&rtr_list[i], &rtr_list[i + 1],
2839 range = orf_token->
seq - instance->
my_aru;
2843 (i <= range); i++) {
2848 res = sq_in_range (sort_queue, instance->
my_aru + i);
2856 res = sq_item_inuse (sort_queue, instance->
my_aru + i);
2867 res = sq_item_miss_count (sort_queue, instance->
my_aru + i);
2877 if (instance->
my_aru + i == rtr_list[j].
seq) {
2907 static void timer_function_token_retransmit_timeout (
void *data)
2917 token_retransmit (instance);
2918 reset_token_retransmit_timeout (instance);
2923 static void timer_function_token_hold_retransmit_timeout (
void *data)
2934 token_retransmit (instance);
2939 static void timer_function_merge_detect_timeout(
void *data)
2948 memb_merge_detect_transmit (instance);
2961 static int token_send (
2963 struct orf_token *orf_token,
2967 unsigned int orf_token_size;
2969 orf_token_size =
sizeof (
struct orf_token) +
2970 (orf_token->rtr_list_entries *
sizeof (
struct rtr_item));
2977 if (forward_token == 0) {
3015 sizeof (
struct token_hold_cancel));
3022 struct orf_token orf_token;
3055 res = token_send (instance, &orf_token, 1);
3060 static void memb_state_commit_token_update (
3065 unsigned int high_aru;
3101 if (sq_lt_compare (high_aru, memb_list[i].
aru)) {
3102 high_aru = memb_list[i].
aru;
3112 if (sq_lt_compare (memb_list[i].
aru, high_aru)) {
3127 static void memb_state_commit_token_target_set (
3141 static int memb_state_commit_token_send_recovery (
3143 struct memb_commit_token *commit_token)
3145 unsigned int commit_token_size;
3149 commit_token_size =
sizeof (
struct memb_commit_token) +
3150 ((sizeof (struct srp_addr) +
3151 sizeof (struct memb_commit_token_memb_entry)) * commit_token->
addr_entries);
3167 reset_token_retransmit_timeout (instance);
3171 static int memb_state_commit_token_send (
3174 unsigned int commit_token_size;
3178 commit_token_size =
sizeof (
struct memb_commit_token) +
3179 ((sizeof (struct srp_addr) +
3196 reset_token_retransmit_timeout (instance);
3203 struct srp_addr token_memb[PROCESSOR_COUNT_MAX];
3204 int token_memb_entries = 0;
3206 unsigned int lowest_nodeid;
3208 memb_set_subtract (token_memb, &token_memb_entries,
3215 assert(token_memb_entries > 0);
3217 lowest_nodeid = token_memb[0].
nodeid;
3218 for (i = 1; i < token_memb_entries; i++) {
3219 if (lowest_nodeid > token_memb[i].nodeid) {
3220 lowest_nodeid = token_memb[i].
nodeid;
3226 static int srp_addr_compare (
const void *a,
const void *b)
3240 static void memb_state_commit_token_create (
3243 struct srp_addr token_memb[PROCESSOR_COUNT_MAX];
3246 int token_memb_entries = 0;
3249 "Creating commit token because I am the rep.");
3251 memb_set_subtract (token_memb, &token_memb_entries,
3255 memset (instance->
commit_token, 0, sizeof (
struct memb_commit_token));
3270 qsort (token_memb, token_memb_entries,
sizeof (
struct srp_addr),
3279 memcpy (addr, token_memb,
3280 token_memb_entries *
sizeof (
struct srp_addr));
3281 memset (memb_list, 0,
3287 char memb_join_data[40000];
3290 unsigned int addr_idx;
3300 msg_len =
sizeof(
struct memb_join) +
3301 ((instance->my_proc_list_entries + instance->my_failed_list_entries) *
sizeof(
struct srp_addr));
3303 if (msg_len >
sizeof(memb_join_data)) {
3304 log_printf (instance->totemsrp_log_level_error,
3305 "memb_join_message too long. Ignoring message.");
3310 memb_join->
ring_seq = instance->my_ring_id.seq;
3313 srp_addr_copy (&memb_join->
system_from, &instance->my_id);
3319 addr = (
char *)memb_join;
3320 addr_idx =
sizeof (
struct memb_join);
3321 memcpy (&addr[addr_idx],
3322 instance->my_proc_list,
3323 instance->my_proc_list_entries *
3326 instance->my_proc_list_entries *
3328 memcpy (&addr[addr_idx],
3329 instance->my_failed_list,
3330 instance->my_failed_list_entries *
3333 instance->my_failed_list_entries *
3336 if (instance->totem_config->send_join_timeout) {
3337 usleep (random() % (instance->totem_config->send_join_timeout * 1000));
3340 instance->stats.memb_join_tx++;
3343 instance->totemnet_context,
3350 char memb_join_data[40000];
3353 unsigned int addr_idx;
3354 int active_memb_entries;
3355 struct srp_addr active_memb[PROCESSOR_COUNT_MAX];
3359 "sending join/leave message");
3366 &instance->
my_id, 1,
3369 memb_set_subtract (active_memb, &active_memb_entries,
3371 &instance->
my_id, 1);
3373 msg_len =
sizeof(
struct memb_join) +
3374 ((active_memb_entries + instance->my_failed_list_entries) *
sizeof(
struct srp_addr));
3376 if (msg_len >
sizeof(memb_join_data)) {
3377 log_printf (instance->totemsrp_log_level_error,
3378 "memb_leave message too long. Ignoring message.");
3389 memb_join->
ring_seq = instance->my_ring_id.seq;
3392 srp_addr_copy (&memb_join->
system_from, &instance->my_id);
3399 addr = (
char *)memb_join;
3400 addr_idx =
sizeof (
struct memb_join);
3401 memcpy (&addr[addr_idx],
3403 active_memb_entries *
3406 active_memb_entries *
3408 memcpy (&addr[addr_idx],
3409 instance->my_failed_list,
3410 instance->my_failed_list_entries *
3413 instance->my_failed_list_entries *
3417 if (instance->totem_config->send_join_timeout) {
3418 usleep (random() % (instance->totem_config->send_join_timeout * 1000));
3420 instance->stats.memb_join_tx++;
3423 instance->totemnet_context,
3445 sizeof (
struct memb_merge_detect));
3448 static void memb_ring_id_set (
3467 token_hold_cancel_send (instance);
3470 if (callback_handle == 0) {
3473 *handle_out = (
void *)callback_handle;
3474 qb_list_init (&callback_handle->
list);
3476 callback_handle->
data = (
void *) data;
3478 callback_handle->
delete =
delete;
3497 qb_list_del (&h->
list);
3504 static void token_callbacks_execute (
3508 struct qb_list_head *list, *tmp_iter;
3509 struct qb_list_head *callback_listhead = 0;
3525 qb_list_for_each_safe(list, tmp_iter, callback_listhead) {
3526 token_callback_instance = qb_list_entry (list,
struct token_callback_instance, list);
3527 del = token_callback_instance->
delete;
3534 token_callback_instance->
data);
3538 if (res == -1 && del == 1) {
3539 qb_list_add (list, callback_listhead);
3541 free (token_callback_instance);
3565 if (queue_use != NULL) {
3566 backlog = cs_queue_used (queue_use);
3573 static int fcc_calculate (
3575 struct orf_token *token)
3577 unsigned int transmits_allowed;
3578 unsigned int backlog_calc;
3586 instance->
my_cbl = backlog_get (instance);
3595 if (backlog_calc > 0 && transmits_allowed > backlog_calc) {
3596 transmits_allowed = backlog_calc;
3600 return (transmits_allowed);
3606 static void fcc_rtr_limit (
3608 struct orf_token *token,
3609 unsigned int *transmits_allowed)
3613 assert (check >= 0);
3620 *transmits_allowed = 0;
3624 static void fcc_token_update (
3626 struct orf_token *token,
3627 unsigned int msgs_transmitted)
3629 token->
fcc += msgs_transmitted - instance->
my_trc;
3631 instance->
my_trc = msgs_transmitted;
3638 static int check_orf_token_sanity(
3642 int endian_conversion_needed)
3645 const struct orf_token *token = (
const struct orf_token *)msg;
3646 size_t required_len;
3648 if (msg_len <
sizeof(
struct orf_token)) {
3650 "Received orf_token message is too short... ignoring.");
3655 if (endian_conversion_needed) {
3661 required_len =
sizeof(
struct orf_token) + rtr_entries *
sizeof(
struct rtr_item);
3662 if (msg_len < required_len) {
3664 "Received orf_token message is too short... ignoring.");
3672 static int check_mcast_sanity(
3676 int endian_conversion_needed)
3679 if (msg_len <
sizeof(
struct mcast)) {
3681 "Received mcast message is too short... ignoring.");
3689 static int check_memb_merge_detect_sanity(
3693 int endian_conversion_needed)
3698 "Received memb_merge_detect message is too short... ignoring.");
3706 static int check_memb_join_sanity(
3710 int endian_conversion_needed)
3715 size_t required_len;
3717 if (msg_len <
sizeof(
struct memb_join)) {
3719 "Received memb_join message is too short... ignoring.");
3727 if (endian_conversion_needed) {
3728 proc_list_entries =
swab32(proc_list_entries);
3729 failed_list_entries =
swab32(failed_list_entries);
3732 required_len =
sizeof(
struct memb_join) + ((proc_list_entries + failed_list_entries) *
sizeof(
struct srp_addr));
3733 if (msg_len < required_len) {
3735 "Received memb_join message is too short... ignoring.");
3743 static int check_memb_commit_token_sanity(
3747 int endian_conversion_needed)
3749 const struct memb_commit_token *mct_msg = (
const struct memb_commit_token *)msg;
3751 size_t required_len;
3753 if (msg_len <
sizeof(
struct memb_commit_token)) {
3755 "Received memb_commit_token message is too short... ignoring.");
3761 if (endian_conversion_needed) {
3762 addr_entries =
swab32(addr_entries);
3765 required_len =
sizeof(
struct memb_commit_token) +
3766 (addr_entries * (
sizeof(
struct srp_addr) + sizeof(struct memb_commit_token_memb_entry)));
3767 if (msg_len < required_len) {
3769 "Received memb_commit_token message is too short... ignoring.");
3777 static int check_token_hold_cancel_sanity(
3781 int endian_conversion_needed)
3786 "Received token_hold_cancel message is too short... ignoring.");
3802 static int message_handler_orf_token (
3806 int endian_conversion_needed)
3808 char token_storage[1500];
3809 char token_convert[1500];
3810 struct orf_token *token = NULL;
3812 unsigned int transmits_allowed;
3813 unsigned int mcasted_retransmit;
3814 unsigned int mcasted_regular;
3815 unsigned int last_aru;
3818 unsigned long long tv_current;
3819 unsigned long long tv_diff;
3821 tv_current = qb_util_nano_current_get ();
3822 tv_diff = tv_current -
tv_old;
3823 tv_old = tv_current;
3826 "Time since last token %0.4f ms", ((
float)tv_diff) / 1000000.0);
3829 if (check_orf_token_sanity(instance, msg, msg_len, endian_conversion_needed) == -1) {
3836 #ifdef TEST_DROP_ORF_TOKEN_PERCENTAGE 3837 if (random()%100 < TEST_DROP_ORF_TOKEN_PERCENTAGE) {
3842 if (endian_conversion_needed) {
3843 orf_token_endian_convert ((
struct orf_token *)msg,
3844 (
struct orf_token *)token_convert);
3845 msg = (
struct orf_token *)token_convert;
3852 token = (
struct orf_token *)token_storage;
3853 memcpy (token, msg,
sizeof (
struct orf_token));
3854 memcpy (&token->
rtr_list[0], (
char *)msg + sizeof (
struct orf_token),
3862 start_merge_detect_timeout (instance);
3865 cancel_merge_detect_timeout (instance);
3866 cancel_token_hold_retransmit_timeout (instance);
3872 #ifdef TEST_RECOVERY_MSG_COUNT 3914 messages_free (instance, token->
aru);
3933 reset_heartbeat_timeout(instance);
3936 cancel_heartbeat_timeout(instance);
3951 transmits_allowed = fcc_calculate (instance, token);
3952 mcasted_retransmit = orf_token_rtr (instance, token, &transmits_allowed);
3960 fcc_rtr_limit (instance, token, &transmits_allowed);
3961 mcasted_regular = orf_token_mcast (instance, token, transmits_allowed);
3968 fcc_token_update (instance, token, mcasted_retransmit +
3971 if (sq_lt_compare (instance->
my_aru, token->
aru) ||
3976 if (token->
aru == token->
seq) {
3982 if (token->
aru == last_aru && token->
aru_addr != 0) {
3997 "FAILED TO RECEIVE");
4001 memb_set_merge (&instance->
my_id, 1,
4028 "token retrans flag is %d my set retrans flag%d retrans queue empty %d count %d, aru %x",
4041 "install seq %x aru %x high seq received %x",
4059 "retrans flag count %x token aru %x install seq %x aru %x %x",
4063 memb_state_operational_enter (instance);
4070 token_send (instance, token, forward_token);
4073 tv_current = qb_util_nano_current_get ();
4074 tv_diff = tv_current -
tv_old;
4075 tv_old = tv_current;
4078 ((
float)tv_diff) / 1000000.0);
4081 messages_deliver_to_app (instance, 0,
4089 reset_token_timeout (instance);
4090 reset_token_retransmit_timeout (instance);
4094 start_token_hold_retransmit_timeout (instance);
4104 reset_heartbeat_timeout(instance);
4107 cancel_heartbeat_timeout(instance);
4113 static void messages_deliver_to_app (
4116 unsigned int end_point)
4121 struct mcast *mcast_in;
4122 struct mcast mcast_header;
4123 unsigned int range = 0;
4124 int endian_conversion_required;
4125 unsigned int my_high_delivered_stored = 0;
4141 for (i = 1; i <= range; i++) {
4149 my_high_delivered_stored + i);
4155 my_high_delivered_stored + i, &ptr);
4159 if (res != 0 && skip == 0) {
4170 sort_queue_item_p = ptr;
4172 mcast_in = sort_queue_item_p->
mcast;
4173 assert (mcast_in != (
struct mcast *)0xdeadbeef);
4175 endian_conversion_required = 0;
4177 endian_conversion_required = 1;
4178 mcast_endian_convert (mcast_in, &mcast_header);
4180 memcpy (&mcast_header, mcast_in,
sizeof (
struct mcast));
4201 "Delivering MCAST message with seq %x to pending delivery queue",
4209 ((
char *)sort_queue_item_p->
mcast) + sizeof (
struct mcast),
4211 endian_conversion_required);
4218 static int message_handler_mcast (
4222 int endian_conversion_needed)
4225 struct sq *sort_queue;
4226 struct mcast mcast_header;
4228 if (check_mcast_sanity(instance, msg, msg_len, endian_conversion_needed) == -1) {
4232 if (endian_conversion_needed) {
4233 mcast_endian_convert (msg, &mcast_header);
4235 memcpy (&mcast_header, msg,
sizeof (
struct mcast));
4246 #ifdef TEST_DROP_MCAST_PERCENTAGE 4247 if (random()%100 < TEST_DROP_MCAST_PERCENTAGE) {
4267 if (!memb_set_subset (
4304 sq_in_range (sort_queue, mcast_header.
seq) &&
4305 sq_item_inuse (sort_queue, mcast_header.
seq) == 0) {
4311 sort_queue_item.
mcast = totemsrp_buffer_alloc (instance);
4312 if (sort_queue_item.
mcast == NULL) {
4315 memcpy (sort_queue_item.
mcast, msg, msg_len);
4316 sort_queue_item.
msg_len = msg_len;
4319 mcast_header.
seq)) {
4323 sq_item_add (sort_queue, &sort_queue_item, mcast_header.
seq);
4326 update_aru (instance);
4335 static int message_handler_memb_merge_detect (
4339 int endian_conversion_needed)
4343 if (check_memb_merge_detect_sanity(instance, msg, msg_len, endian_conversion_needed) == -1) {
4347 if (endian_conversion_needed) {
4348 memb_merge_detect_endian_convert (msg, &memb_merge_detect);
4350 memcpy (&memb_merge_detect, msg,
4351 sizeof (
struct memb_merge_detect));
4368 memb_set_merge (&memb_merge_detect.
system_from, 1,
4374 if (!memb_set_subset (
4380 memb_set_merge (&memb_merge_detect.
system_from, 1,
4398 static void memb_join_process (
4404 int gather_entered = 0;
4405 int fail_minus_memb_entries = 0;
4406 struct srp_addr fail_minus_memb[PROCESSOR_COUNT_MAX];
4447 if (memb_set_equal (proc_list,
4452 memb_set_equal (failed_list,
4458 memb_consensus_set (instance, &memb_join->
system_from);
4461 if (memb_consensus_agreed (instance) && instance->
failed_to_recv == 1) {
4468 memb_state_commit_token_create (instance);
4470 memb_state_commit_enter (instance);
4473 if (memb_consensus_agreed (instance) &&
4474 memb_lowest_in_config (instance)) {
4476 memb_state_commit_token_create (instance);
4478 memb_state_commit_enter (instance);
4483 if (memb_set_subset (proc_list,
4488 memb_set_subset (failed_list,
4500 memb_set_merge (proc_list,
4504 if (memb_set_subset (
4505 &instance->
my_id, 1,
4512 if (memb_set_subset (
4517 if (memb_set_subset (
4522 memb_set_merge (failed_list,
4526 memb_set_subtract (fail_minus_memb,
4527 &fail_minus_memb_entries,
4533 memb_set_merge (fail_minus_memb,
4534 fail_minus_memb_entries,
4545 if (gather_entered == 0 &&
4552 static void memb_join_endian_convert (
const struct memb_join *in,
struct memb_join *out)
4575 srp_addr_copy_endian_convert (&out_proc_list[i], &in_proc_list[i]);
4578 srp_addr_copy_endian_convert (&out_failed_list[i], &in_failed_list[i]);
4582 static void memb_commit_token_endian_convert (
const struct memb_commit_token *in,
struct memb_commit_token *out)
4604 srp_addr_copy_endian_convert (&out_addr[i], &in_addr[i]);
4609 if (in_memb_list[i].ring_id.
rep != 0) {
4621 static void orf_token_endian_convert (
const struct orf_token *in,
struct orf_token *out)
4646 static void mcast_endian_convert (
const struct mcast *in,
struct mcast *out)
4663 static void memb_merge_detect_endian_convert (
4676 static int ignore_join_under_operational (
4678 const struct memb_join *memb_join)
4688 if (memb_set_subset (&instance->
my_id, 1,
4706 static int message_handler_memb_join (
4710 int endian_conversion_needed)
4712 const struct memb_join *memb_join;
4713 struct memb_join *memb_join_convert = alloca (msg_len);
4715 if (check_memb_join_sanity(instance, msg, msg_len, endian_conversion_needed) == -1) {
4719 if (endian_conversion_needed) {
4720 memb_join = memb_join_convert;
4721 memb_join_endian_convert (msg, memb_join_convert);
4731 if (pause_flush (instance)) {
4740 if (!ignore_join_under_operational (instance, memb_join)) {
4741 memb_join_process (instance, memb_join);
4746 memb_join_process (instance, memb_join);
4757 memb_join_process (instance, memb_join);
4770 memb_join_process (instance, memb_join);
4771 memb_recovery_state_token_loss (instance);
4779 static int message_handler_memb_commit_token (
4783 int endian_conversion_needed)
4785 struct memb_commit_token *memb_commit_token_convert = alloca (msg_len);
4786 struct memb_commit_token *memb_commit_token;
4787 struct srp_addr sub[PROCESSOR_COUNT_MAX];
4793 "got commit token");
4795 if (check_memb_commit_token_sanity(instance, msg, msg_len, endian_conversion_needed) == -1) {
4799 if (endian_conversion_needed) {
4800 memb_commit_token_endian_convert (msg, memb_commit_token_convert);
4802 memcpy (memb_commit_token_convert, msg, msg_len);
4804 memb_commit_token = memb_commit_token_convert;
4807 #ifdef TEST_DROP_COMMIT_TOKEN_PERCENTAGE
4808 if (random()%100 < TEST_DROP_COMMIT_TOKEN_PERCENTAGE) {
4818 memb_set_subtract (sub, &sub_entries,
4822 if (memb_set_equal (addr,
4828 memcpy (instance->
commit_token, memb_commit_token, msg_len);
4829 memb_state_commit_enter (instance);
4843 memb_state_recovery_enter (instance, memb_commit_token);
4858 "Sending initial ORF token");
4861 orf_token_send_initial (instance);
4862 reset_token_timeout (instance);
4863 reset_token_retransmit_timeout (instance);
4870 static int message_handler_token_hold_cancel (
4874 int endian_conversion_needed)
4878 if (check_token_hold_cancel_sanity(instance, msg, msg_len, endian_conversion_needed) == -1) {
4887 timer_function_token_retransmit_timeout (instance);
4893 static int check_message_header_validity(
4896 unsigned int msg_len,
4897 const struct sockaddr_storage *system_from)
4901 const char *guessed_str;
4902 const char *msg_byte = msg;
4906 "Message received from %s is too short... Ignoring %u.",
4920 if (message_header->
magic == 0xFFFF) {
4924 guessed_str =
"Corosync 2.2";
4925 }
else if (message_header->
magic == 0xFEFE) {
4929 guessed_str =
"Corosync 2.3+";
4930 }
else if (msg_byte[0] == 0x01) {
4934 guessed_str =
"unencrypted Kronosnet";
4935 }
else if (msg_byte[0] >= 0 && msg_byte[0] <= 5) {
4940 guessed_str =
"unencrypted Corosync 2.0/2.1/1.x/OpenAIS";
4951 guessed_str =
"encrypted Kronosnet/Corosync 2.0/2.1/1.x/OpenAIS or unknown";
4955 "Message received from %s has bad magic number (probably sent by %s).. Ignoring",
4964 "Message received from %s has unsupported version %u... Ignoring",
4978 unsigned int msg_len,
4979 const struct sockaddr_storage *system_from)
4984 if (check_message_header_validity(context, msg, msg_len, system_from) == -1) {
4988 switch (message_header->
type) {
5009 "Message received from %s has wrong type... ignoring %d.\n",
5011 (
int)message_header->
type);
5029 unsigned short ip_port,
5030 unsigned int iface_no)
5050 unsigned int iface_no)
5066 "Created or loaded sequence id " CS_PRI_RING_ID " for this ring.",
5100 void (*totem_service_ready) (
void))
5170 timer_function_orf_token_timeout(context);
void(* totemsrp_service_ready_fn)(void)
void(* totemsrp_deliver_fn)(unsigned int nodeid, const void *msg, unsigned int msg_len, int endian_conversion_required)
void(*) enum memb_stat memb_state)
int totemsrp_reconfigure(void *context, struct totem_config *totem_config)
struct totem_message_header header
int totemsrp_iface_set(void *context, const struct totem_ip_address *interface_addr, unsigned short ip_port, unsigned int iface_no)
void main_iface_change_fn(void *context, const struct totem_ip_address *iface_address, unsigned int iface_no)
struct srp_addr system_from
struct memb_ring_id ring_id
int totemnet_mcast_flush_send(void *net_context, const void *msg, unsigned int msg_len)
uint32_t waiting_trans_ack
struct srp_addr system_from
struct memb_ring_id ring_id
int totemsrp_log_level_debug
struct memb_ring_id my_ring_id
Totem Single Ring Protocol.
uint64_t memb_commit_token_rx
qb_loop_timer_handle timer_orf_token_warning
int my_leave_memb_entries
unsigned int old_ring_state_high_seq_received
unsigned int proc_list_entries
struct totem_interface * interfaces
int totemsrp_my_family_get(void *srp_context)
void(* memb_ring_id_create_or_load)(struct memb_ring_id *memb_ring_id, unsigned int nodeid)
void(* totemsrp_confchg_fn)(enum totem_configuration_type configuration_type, const unsigned int *member_list, size_t member_list_entries, const unsigned int *left_list, size_t left_list_entries, const unsigned int *joined_list, size_t joined_list_entries, const struct memb_ring_id *ring_id)
The totem_ip_address struct.
totemsrp_token_stats_t token[TOTEM_TOKEN_STATS_MAX]
int totemsrp_log_level_error
#define LEAVE_DUMMY_NODEID
struct memb_ring_id ring_id
qb_loop_timer_handle timer_heartbeat_timeout
unsigned int failed_list_entries
unsigned char end_of_memb_join[0]
unsigned long long int tv_old
int totemsrp_member_add(void *context, const struct totem_ip_address *member, int iface_no)
#define SEQNO_START_TOKEN
void totemnet_stats_clear(void *net_context)
unsigned int token_hold_timeout
struct memb_ring_id ring_id
struct totem_ip_address member_list[PROCESSOR_COUNT_MAX]
void * token_sent_event_handle
struct srp_addr system_from
totem_configuration_type
The totem_configuration_type enum.
int totemsrp_log_level_notice
unsigned int proc_list_entries
unsigned int totemsrp_my_nodeid_get(void *srp_context)
void(* totem_memb_ring_id_create_or_load)(struct memb_ring_id *memb_ring_id, unsigned int nodeid)
int totemnet_member_remove(void *net_context, const struct totem_ip_address *member, int ring_no)
#define TOTEM_TOKEN_STATS_MAX
void totemsrp_net_mtu_adjust(struct totem_config *totem_config)
int totemsrp_log_level_warning
int totemsrp_crypto_set(void *srp_context, const char *cipher_type, const char *hash_type)
int totemsrp_member_remove(void *context, const struct totem_ip_address *member, int iface_no)
uint64_t memb_merge_detect_rx
struct cs_queue new_message_queue_trans
unsigned char end_of_commit_token[0]
unsigned char addr[TOTEMIP_ADDRLEN]
char commit_token_storage[40000]
struct cs_queue new_message_queue
struct srp_addr my_deliver_memb_list[PROCESSOR_COUNT_MAX]
void totemsrp_callback_token_destroy(void *srp_context, void **handle_out)
uint64_t gather_token_lost
#define CS_PRI_RING_ID_SEQ
int totemsrp_log_level_trace
void totemip_copy(struct totem_ip_address *addr1, const struct totem_ip_address *addr2)
struct memb_ring_id my_old_ring_id
unsigned int downcheck_timeout
struct qb_list_head token_callback_received_listhead
struct srp_addr my_new_memb_list[PROCESSOR_COUNT_MAX]
uint64_t memb_commit_token_tx
int my_deliver_memb_entries
unsigned int max_network_delay
unsigned int heartbeat_failures_allowed
#define swab64(x)
The swab64 macro.
struct message_item __attribute__
unsigned long long token_ring_id_seq
struct totem_ip_address mcast_address
void(* totemsrp_log_printf)(int level, int subsys, const char *function, const char *file, int line, const char *format,...) __attribute__((format(printf
int totemsrp_callback_token_create(void *srp_context, void **handle_out, enum totem_callback_token_type type, int delete, int(*callback_fn)(enum totem_callback_token_type type, const void *), const void *data)
unsigned int send_join_timeout
void totemsrp_service_ready_register(void *context, void(*totem_service_ready)(void))
struct srp_addr my_memb_list[PROCESSOR_COUNT_MAX]
uint64_t operational_entered
void(*) in log_level_security)
unsigned long long ring_seq
int totemsrp_mcast(void *srp_context, struct iovec *iovec, unsigned int iov_len, int guarantee)
Multicast a message.
uint64_t operational_token_lost
unsigned int received_flg
uint64_t consensus_timeouts
Totem Network interface - also does encryption/decryption.
unsigned int my_high_delivered
struct message_handlers totemsrp_message_handlers
qb_loop_timer_handle memb_timer_state_gather_consensus_timeout
uint64_t recovery_token_lost
int totemnet_recv_flush(void *net_context)
int totemnet_token_target_set(void *net_context, unsigned int nodeid)
int totemnet_ifaces_get(void *net_context, char ***status, unsigned int *iface_count)
unsigned char end_of_memb_join[0]
unsigned int token_retransmits_before_loss_const
struct rtr_item rtr_list[0]
struct memb_ring_id ring_id
unsigned int seqno_unchanged_const
uint64_t commit_token_lost
unsigned int miss_count_const
uint64_t token_hold_cancel_rx
int totemnet_crypto_set(void *net_context, const char *cipher_type, const char *hash_type)
unsigned int join_timeout
uint32_t originated_orf_token
void * totemnet_buffer_alloc(void *net_context)
struct totem_ip_address mcast_addr
#define MESSAGE_QUEUE_MAX
int totemnet_recv_mcast_empty(void *net_context)
unsigned int received_flg
unsigned int last_released
int orf_token_retransmit_size
int totemsrp_avail(void *srp_context)
Return number of available messages that can be queued.
int totemnet_initialize(qb_loop_t *loop_pt, void **net_context, struct totem_config *totem_config, totemsrp_stats_t *stats, void *context, void(*deliver_fn)(void *context, const void *msg, unsigned int msg_len, const struct sockaddr_storage *system_from), void(*iface_change_fn)(void *context, const struct totem_ip_address *iface_address, unsigned int ring_no), void(*mtu_changed)(void *context, int net_mtu), void(*target_set_completed)(void *context))
#define RETRANS_MESSAGE_QUEUE_SIZE_MAX
#define LOGSYS_LEVEL_DEBUG
unsigned int fail_to_recv_const
int totemnet_send_flush(void *net_context)
void totemsrp_stats_clear(void *context, int flags)
int totemnet_mcast_noflush_send(void *net_context, const void *msg, unsigned int msg_len)
void * token_recv_event_handle
struct totem_ip_address boundto
unsigned int my_high_seq_received
qb_loop_t * totemsrp_poll_handle
int totemnet_finalize(void *net_context)
qb_loop_timer_handle timer_pause_timeout
qb_loop_timer_handle timer_merge_detect_timeout
int my_merge_detect_timeout_outstanding
void(* log_printf)(int level, int subsys, const char *function_name, const char *file_name, int file_line, const char *format,...) __attribute__((format(printf
int totemsrp_log_level_security
qb_loop_timer_handle timer_orf_token_retransmit_timeout
struct totem_config * totem_config
int(* callback_fn)(enum totem_callback_token_type type, const void *)
struct totem_message_header header
#define swab32(x)
The swab32 macro.
qb_loop_timer_handle timer_orf_token_timeout
uint32_t continuous_gather
void main_deliver_fn(void *context, const void *msg, unsigned int msg_len, const struct sockaddr_storage *system_from)
void totemsrp_threaded_mode_enable(void *context)
int totemnet_token_send(void *net_context, const void *msg, unsigned int msg_len)
int totemsrp_ifaces_get(void *srp_context, unsigned int nodeid, unsigned int *interface_id, struct totem_ip_address *interfaces, unsigned int interfaces_size, char ***status, unsigned int *iface_count)
int totemsrp_initialize(qb_loop_t *poll_handle, void **srp_context, struct totem_config *totem_config, totempg_stats_t *stats, void(*deliver_fn)(unsigned int nodeid, const void *msg, unsigned int msg_len, int endian_conversion_required), void(*confchg_fn)(enum totem_configuration_type configuration_type, const unsigned int *member_list, size_t member_list_entries, const unsigned int *left_list, size_t left_list_entries, const unsigned int *joined_list, size_t joined_list_entries, const struct memb_ring_id *ring_id), void(*waiting_trans_ack_cb_fn)(int waiting_trans_ack))
Create a protocol instance.
struct totem_message_header header
void totemsrp_event_signal(void *srp_context, enum totem_event_type type, int value)
void(* totem_memb_ring_id_store)(const struct memb_ring_id *memb_ring_id, unsigned int nodeid)
uint32_t orf_token_discard
int my_failed_list_entries
struct srp_addr my_left_memb_list[PROCESSOR_COUNT_MAX]
uint64_t token_hold_cancel_tx
const char * totemip_sa_print(const struct sockaddr *sa)
unsigned int token_timeout
struct totem_message_header header
unsigned int high_delivered
unsigned int consensus_timeout
void totemsrp_force_gather(void *context)
#define PROCESSOR_COUNT_MAX
struct totem_ip_address my_addrs[INTERFACE_MAX]
char orf_token_retransmit[TOKEN_SIZE_MAX]
unsigned int token_warning
struct sq regular_sort_queue
#define swab16(x)
The swab16 macro.
struct totem_message_header header
void totemsrp_finalize(void *srp_context)
struct totem_message_header header
#define QUEUE_RTR_ITEMS_SIZE_MAX
struct srp_addr my_failed_list[PROCESSOR_COUNT_MAX]
struct cs_queue retrans_message_queue
const char * gather_state_from_desc[]
qb_loop_timer_handle memb_timer_state_gather_join_timeout
int my_trans_memb_entries
void(* totemsrp_waiting_trans_ack_cb_fn)(int waiting_trans_ack)
uint64_t memb_merge_detect_tx
unsigned int high_delivered
struct rtr_item rtr_list[0]
int consensus_list_entries
int totemnet_member_add(void *net_context, const struct totem_ip_address *local, const struct totem_ip_address *member, int ring_no)
unsigned char end_of_commit_token[0]
uint32_t threaded_mode_enabled
enum totem_callback_token_type callback_type
unsigned long long ring_seq
struct totem_message_header header
struct totem_logging_configuration totem_logging_configuration
struct memb_ring_id ring_id
#define log_printf(level, format, args...)
void totemsrp_trans_ack(void *context)
unsigned int max_messages
uint64_t recovery_entered
qb_loop_timer_handle memb_timer_state_commit_timeout
void totemnet_buffer_release(void *net_context, void *ptr)
int totemnet_reconfigure(void *net_context, struct totem_config *totem_config)
struct memb_commit_token * commit_token
struct consensus_list_item consensus_list[PROCESSOR_COUNT_MAX]
struct srp_addr system_from
struct srp_addr my_proc_list[PROCESSOR_COUNT_MAX]
void(* memb_ring_id_store)(const struct memb_ring_id *memb_ring_id, unsigned int nodeid)
int(* handler_functions[6])(struct totemsrp_instance *instance, const void *msg, size_t msg_len, int endian_conversion_needed)
unsigned int merge_timeout
unsigned int use_heartbeat
int totemnet_iface_check(void *net_context)
unsigned int token_retransmit_timeout
struct qb_list_head token_callback_sent_listhead
struct srp_addr my_trans_memb_list[PROCESSOR_COUNT_MAX]
#define RETRANSMIT_ENTRIES_MAX
unsigned int my_token_seq
struct memb_ring_id ring_id
unsigned int my_leave_memb_list[PROCESSOR_COUNT_MAX]
qb_loop_timer_handle timer_orf_token_hold_retransmit_timeout
int totemnet_iface_set(void *net_context, const struct totem_ip_address *interface_addr, unsigned short ip_port, unsigned int iface_no)
struct memb_ring_id ring_id
unsigned int my_install_seq
unsigned int failed_list_entries
struct sq recovery_sort_queue
#define TOTEMPG_STATS_CLEAR_TRANSPORT
totem_callback_token_type
The totem_callback_token_type enum.
unsigned int my_high_ring_delivered
int totemnet_processor_count_set(void *net_context, int processor_count)