41#include <sys/socket.h>
46#include <netinet/in.h>
86static int setup_nozzle(
void *knet_context);
90#define CFG_INTERFACE_STATUS_MAX_LEN 512
108 unsigned int msg_len,
114 unsigned int link_no);
142 const char *function,
200static int totemknet_configure_compression (
204static void totemknet_start_merge_detect_timeout(
207static void totemknet_stop_merge_detect_timeout(
210static void log_flush_messages (
218 res = pthread_mutex_init(&instance->
log_mutex, NULL);
225#define knet_log_printf_lock(level, subsys, function, file, line, format, args...) \
227 (void)pthread_mutex_lock(&instance->log_mutex); \
228 instance->totemknet_log_printf ( \
229 level, subsys, function, file, line, \
230 (const char *)format, ##args); \
231 (void)pthread_mutex_unlock(&instance->log_mutex); \
234#define knet_log_printf(level, format, args...) \
236 knet_log_printf_lock ( \
237 level, instance->totemknet_subsys_id, \
238 __FUNCTION__, __FILE__, __LINE__, \
239 (const char *)format, ##args); \
242#define libknet_log_printf(level, format, args...) \
244 knet_log_printf_lock ( \
245 level, instance->knet_subsys_id, \
246 __FUNCTION__, "libknet.h", __LINE__, \
247 (const char *)format, ##args); \
250#define KNET_LOGSYS_PERROR(err_num, level, fmt, args...) \
252 char _error_str[LOGSYS_MAX_PERROR_MSG_LEN]; \
253 const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str)); \
254 instance->totemknet_log_printf ( \
255 level, instance->totemknet_subsys_id, \
256 __FUNCTION__, __FILE__, __LINE__, \
257 fmt ": %s (%d)", ##args, _error_ptr, err_num); \
262static inline uint8_t *ether_get_dst_mac(
const unsigned char *packet, ssize_t packet_len)
267 if (packet_len < 6) {
280 return (uint8_t *)packet;
283static inline int is_ether_addr_multicast(
const uint8_t *
addr)
285 return (
addr[0] & 0x01);
287static inline int is_ether_addr_zero(
const uint8_t *
addr)
292static int ether_host_filter_fn(
void *private_data,
293 const unsigned char *outdata,
296 knet_node_id_t this_host_id,
297 knet_node_id_t src_host_id,
299 knet_node_id_t *dst_host_ids,
300 size_t *dst_host_ids_entries)
302 uint8_t *dst_mac = ether_get_dst_mac(outdata, outdata_len);
303 uint16_t dst_host_id;
305 if (dst_mac == NULL) {
309 if (is_ether_addr_zero(dst_mac))
312 if (is_ether_addr_multicast(dst_mac)) {
316 memmove(&dst_host_id, &dst_mac[4], 2);
318 dst_host_ids[0] = ntohs(dst_host_id);
319 *dst_host_ids_entries = 1;
325static int dst_host_filter_callback_fn(
void *private_data,
326 const unsigned char *outdata,
329 knet_node_id_t this_host_id,
330 knet_node_id_t src_host_id,
332 knet_node_id_t *dst_host_ids,
333 size_t *dst_host_ids_entries)
340 return ether_host_filter_fn(private_data,
341 outdata, outdata_len,
343 this_host_id, src_host_id,
346 dst_host_ids_entries);
349 if (
header->target_nodeid) {
350 dst_host_ids[0] =
header->target_nodeid;
351 *dst_host_ids_entries = 1;
355 *dst_host_ids_entries = 0;
361static void socket_error_callback_fn(
void *private_data,
int datafd, int8_t channel, uint8_t tx_rx,
int error,
int errorno)
366 if ((error == -1 && errorno != EAGAIN) || (error == 0)) {
367 knet_handle_remove_datafd(instance->
knet_handle, datafd);
371static void host_change_callback_fn(
void *private_data, knet_node_id_t host_id, uint8_t reachable, uint8_t remote, uint8_t external)
379static void pmtu_change_callback_fn(
void *private_data,
unsigned int data_mtu)
390 const char *cipher_type,
391 const char *hash_type)
397static inline void ucast_sendmsg (
401 unsigned int msg_len)
405 struct msghdr msg_ucast;
410 iovec.iov_base = (
void *)msg;
411 iovec.iov_len = msg_len;
416 memset(&msg_ucast, 0,
sizeof(msg_ucast));
417 msg_ucast.msg_iov = (
void *)&iovec;
418 msg_ucast.msg_iovlen = 1;
428 "sendmsg(ucast) failed (non-critical)");
432static inline void mcast_sendmsg (
435 unsigned int msg_len,
440 struct msghdr msg_mcast;
443 iovec.iov_base = (
void *)msg;
444 iovec.iov_len = msg_len;
446 header->target_nodeid = 0;
451 memset(&msg_mcast, 0,
sizeof(msg_mcast));
452 msg_mcast.msg_iov = (
void *)&iovec;
453 msg_mcast.msg_iovlen = 1;
471static int node_compare(
const void *aptr,
const void *bptr)
475 a = *(uint16_t *)aptr;
476 b = *(uint16_t *)bptr;
481#ifndef OWN_INDEX_NONE
482#define OWN_INDEX_NONE -1
492 struct knet_link_status link_status;
494 struct knet_host_status knet_host_status;
495 uint8_t link_list[KNET_MAX_LINK];
514 node_status->
reachable = knet_host_status.reachable;
515 node_status->
remote = knet_host_status.remote;
516 node_status->
external = knet_host_status.external;
518#ifdef HAVE_KNET_ONWIRE_VER
519 res = knet_handle_get_onwire_ver(instance->
knet_handle,
530 res = knet_link_get_link_list(instance->
knet_handle,
531 nodeid, link_list, &num_links);
538 for (i=0; i < num_links; i++) {
546 sizeof(link_status));
548 node_status->
link_status[link_list[i]].enabled = link_status.enabled;
549 node_status->
link_status[link_list[i]].connected = link_status.connected;
550 node_status->
link_status[link_list[i]].dynconnected = link_status.dynconnected;
551 node_status->
link_status[link_list[i]].mtu = link_status.mtu;
552 memcpy(node_status->
link_status[link_list[i]].src_ipaddr, link_status.src_ipaddr, KNET_MAX_HOST_LEN);
553 memcpy(node_status->
link_status[link_list[i]].dst_ipaddr, link_status.dst_ipaddr, KNET_MAX_HOST_LEN);
565 unsigned int *iface_count)
568 struct knet_link_status link_status;
569 knet_node_id_t host_list[KNET_MAX_HOST];
570 uint8_t link_list[KNET_MAX_LINK];
585 res = knet_host_get_host_list(instance->
knet_handle,
586 host_list, &num_hosts);
590 qsort(host_list, num_hosts,
sizeof(uint16_t), node_compare);
592 for (j=0; j<num_hosts; j++) {
610 for (j=0; j<num_hosts; j++) {
615 res = knet_link_get_link_list(instance->
knet_handle,
616 host_list[j], link_list, &num_links);
622 for (i=0; i < num_links; i++) {
637 sizeof(link_status));
639 ptr[j] =
'0' + (link_status.enabled |
640 link_status.connected<<1 |
641 link_status.dynconnected<<2);
645 "totemknet_ifaces_get: Cannot get link status: %s", strerror(errno));
664 static knet_node_id_t nodes[KNET_MAX_HOST];
665 uint8_t links[KNET_MAX_LINK];
677 res = knet_handle_setfwd(instance->
knet_handle, 0);
682 res = knet_host_get_host_list(instance->
knet_handle, nodes, &num_nodes);
690 for (i=0; i<num_nodes; i++) {
692 res = knet_link_get_link_list(instance->
knet_handle, nodes[i], links, &num_links);
697 for (j=0; j<num_links; j++) {
698 res = knet_link_set_enable(instance->
knet_handle, nodes[i], links[j], 0);
702 res = knet_link_clear_config(instance->
knet_handle, nodes[i], links[j]);
707 res = knet_host_remove(instance->
knet_handle, nodes[i]);
719 totemknet_stop_merge_detect_timeout(instance);
721 log_flush_messages(instance);
726 (void)pthread_mutex_destroy(&instance->
log_mutex);
731static int log_deliver_fn (
737 char buffer[
sizeof(
struct knet_log_msg)*4];
738 char *bufptr = buffer;
742 len = read(fd, buffer,
sizeof(buffer));
744 struct knet_log_msg *msg = (
struct knet_log_msg *)bufptr;
745 switch (msg->msglevel) {
748 knet_log_get_subsystem_name(msg->subsystem),
753 knet_log_get_subsystem_name(msg->subsystem),
758 knet_log_get_subsystem_name(msg->subsystem),
763 knet_log_get_subsystem_name(msg->subsystem),
769 knet_log_get_subsystem_name(msg->subsystem),
774 bufptr +=
sizeof(
struct knet_log_msg);
775 done +=
sizeof(
struct knet_log_msg);
780static int data_deliver_fn (
786 struct msghdr msg_hdr;
787 struct iovec iov_recv;
793 iov_recv.iov_len = KNET_MAX_PACKET_SIZE + 1;
795 memset(&msg_hdr, 0,
sizeof(msg_hdr));
797 msg_hdr.msg_namelen =
sizeof (
struct sockaddr_storage);
798 msg_hdr.msg_iov = &iov_recv;
799 msg_hdr.msg_iovlen = 1;
801 msg_len = recvmsg (fd, &msg_hdr,
MSG_NOSIGNAL | MSG_DONTWAIT);
806 if (msg_len >= KNET_MAX_PACKET_SIZE + 1) {
814 "Received truncated packet. Please report this bug. Dropping packet.");
821#ifdef KNET_DATAFD_FLAG_RX_RETURN_INFO
823 struct knet_datafd_header *datafd_header = (
struct knet_datafd_header *)data_ptr;
828 data_ptr += datafd_header->size;
829 msg_len -= datafd_header->size;
846static void timer_function_netif_check_timeout (
870#ifdef HAVE_KNET_ACCESS_LIST
887 int knet_log_mode = KNET_LOG_INFO;
898 switch (logsys_log_mode) {
900 knet_log_mode = KNET_LOG_INFO;
903 knet_log_mode = KNET_LOG_DEBUG;
907 knet_log_mode = KNET_LOG_TRACE;
909 knet_log_mode = KNET_LOG_DEBUG;
915 for (s = 0; s<KNET_MAX_SUBSYSTEMS; s++) {
916 err = knet_log_set_loglevel(
global_instance->knet_handle, s, knet_log_mode);
927static void totemknet_refresh_config(
929 const char *key_name,
938 knet_node_id_t host_ids[KNET_MAX_HOST];
949 if (
icmap_get_uint8(
"config.totemconfig_reload_in_progress", &reloading) ==
CS_OK && reloading) {
953 after_reload = (strcmp(key_name,
"config.totemconfig_reload_in_progress") == 0);
955 knet_set_access_list_config(instance);
957 if (strcmp(key_name,
"totem.knet_pmtud_interval") == 0 || after_reload) {
966 if (strcmp(key_name,
"totem.knet_mtu") == 0 || after_reload) {
975 err = knet_host_get_host_list(instance->
knet_handle, host_ids, &num_nodes);
980 for (i=0; i<num_nodes; i++) {
987 err = knet_link_set_ping_timers(instance->
knet_handle, host_ids[i], link_no,
995 err = knet_link_set_pong_count(instance->
knet_handle, host_ids[i], link_no,
1001 err = knet_link_set_priority(instance->
knet_handle, host_ids[i], link_no,
1010 icmap_set_string(
"config.reload_error_message",
"Failed to set knet ping timers(2)");
1027 totemknet_refresh_config,
1029 &icmap_track_totem);
1033 totemknet_refresh_config,
1035 &icmap_track_reload);
1050 struct knet_handle_crypto_cfg crypto_cfg;
1060#ifdef HAVE_KNET_CRYPTO_RECONF
1063 crypto_cfg.crypto_model,
1064 crypto_cfg.crypto_cipher_type,
1065 crypto_cfg.crypto_hash_type,
1070 if (!totemknet_is_crypto_enabled(instance)) {
1071 res = knet_handle_crypto_rx_clear_traffic(instance->
knet_handle, KNET_CRYPTO_RX_ALLOW_CLEAR_TRAFFIC);
1093 crypto_cfg.crypto_model,
1094 crypto_cfg.crypto_cipher_type,
1095 crypto_cfg.crypto_hash_type
1098 res = knet_handle_crypto(instance->
knet_handle, &crypto_cfg);
1110#ifdef HAVE_KNET_CRYPTO_RECONF
1112 icmap_set_string(
"config.reload_error_message",
"Failed to set crypto parameters");
1134 qb_loop_t *poll_handle,
1135 void **knet_context,
1143 unsigned int msg_len,
1146 int (*iface_change_fn) (
1149 unsigned int link_no),
1151 void (*mtu_changed) (
1155 void (*target_set_completed) (
1161 int allow_knet_handle_fallback=0;
1166 if (instance == NULL) {
1170 totemknet_instance_initialize (instance);
1220 if (fcntl(instance->
logpipes[0], F_SETFL, O_NONBLOCK) == -1 ||
1221 fcntl(instance->
logpipes[1], F_SETFL, O_NONBLOCK) == -1) {
1227 if (strcmp(tmp_str,
"yes") == 0) {
1228 allow_knet_handle_fallback = 1;
1233#if defined(KNET_API_VER) && (KNET_API_VER == 2)
1239 if (allow_knet_handle_fallback && !instance->
knet_handle && errno == ENAMETOOLONG) {
1241#if defined(KNET_API_VER) && (KNET_API_VER == 2)
1253 knet_set_access_list_config(instance);
1263#ifdef HAVE_KNET_SETPRIO_DSCP
1269 res = knet_handle_enable_filter(instance->
knet_handle, instance, dst_host_filter_callback_fn);
1273 res = knet_handle_enable_sock_notify(instance->
knet_handle, instance, socket_error_callback_fn);
1277 res = knet_host_enable_status_change_notify(instance->
knet_handle, instance, host_change_callback_fn);
1281 res = knet_handle_enable_pmtud_notify(instance->
knet_handle, instance, pmtu_change_callback_fn);
1292#ifdef KNET_DATAFD_FLAG_RX_RETURN_INFO
1293 res = knet_handle_add_datafd(instance->
knet_handle, &instance->
knet_fd, &channel, KNET_DATAFD_FLAG_RX_RETURN_INFO);
1298 knet_log_printf(LOG_DEBUG,
"knet_handle_add_datafd failed: %s", strerror(errno));
1303#ifdef HAVE_KNET_CRYPTO_RECONF
1304 if (totemknet_is_crypto_enabled(instance)) {
1305 res = totemknet_set_knet_crypto(instance);
1309 knet_log_printf(LOG_DEBUG,
"knet_handle_crypto_use_config failed: %s", strerror(errno));
1316 res = knet_handle_crypto_rx_clear_traffic(instance->
knet_handle, KNET_CRYPTO_RX_DISALLOW_CLEAR_TRAFFIC);
1318 knet_log_printf(LOG_DEBUG,
"knet_handle_crypto_rx_clear_traffic (DISALLOW) failed: %s", strerror(errno));
1323 res = knet_handle_crypto_rx_clear_traffic(instance->
knet_handle, KNET_CRYPTO_RX_ALLOW_CLEAR_TRAFFIC);
1325 knet_log_printf(LOG_DEBUG,
"knet_handle_crypto_rx_clear_traffic (ALLOW) failed: %s", strerror(errno));
1330 if (totemknet_is_crypto_enabled(instance)) {
1331 res = totemknet_set_knet_crypto(instance);
1342 (void)totemknet_configure_compression(instance,
totem_config);
1347 instance->
link_mode = KNET_LINK_POLICY_PASSIVE;
1349 instance->
link_mode = KNET_LINK_POLICY_ACTIVE;
1352 instance->
link_mode = KNET_LINK_POLICY_RR;
1365 POLLIN, instance, log_deliver_fn);
1370 POLLIN, instance, data_deliver_fn);
1378 100*QB_TIME_NS_IN_MSEC,
1380 timer_function_netif_check_timeout,
1383 totemknet_start_merge_detect_timeout(instance);
1386 totemknet_add_config_notifications(instance);
1397 log_flush_messages(instance);
1405 return malloc(KNET_MAX_PACKET_SIZE + 512);
1415 int processor_count)
1433 unsigned int msg_len)
1438 ucast_sendmsg (instance, &instance->
token_target, msg, msg_len);
1445 unsigned int msg_len)
1450 mcast_sendmsg (instance, msg, msg_len, 0);
1458 unsigned int msg_len)
1463 mcast_sendmsg (instance, msg, msg_len, 1);
1506 struct msghdr msg_hdr;
1507 struct iovec iov_recv;
1510 int msg_processed = 0;
1513 iov_recv.iov_len = KNET_MAX_PACKET_SIZE;
1515 memset(&msg_hdr, 0,
sizeof(msg_hdr));
1517 msg_hdr.msg_namelen =
sizeof (
struct sockaddr_storage);
1518 msg_hdr.msg_iov = &iov_recv;
1519 msg_hdr.msg_iovlen = 1;
1523 ufd.events = POLLIN;
1524 nfds = poll (&ufd, 1, 0);
1525 if (nfds == 1 && ufd.revents & POLLIN) {
1533 }
while (nfds == 1);
1535 return (msg_processed);
1540 unsigned short ip_port,
1541 unsigned int iface_no)
1563 int port = instance->
ip_port[link_no];
1564 struct sockaddr_storage remote_ss;
1565 struct sockaddr_storage local_ss;
1569 knet_node_id_t host_ids[KNET_MAX_HOST];
1570 size_t num_host_ids;
1588 err = knet_host_get_host_list(instance->
knet_handle, host_ids, &num_host_ids);
1593 for (i=0; i<num_host_ids; i++) {
1594 if (host_ids[i] == member->
nodeid) {
1601 if (err != 0 && errno != EEXIST) {
1617 memset(&local_ss, 0,
sizeof(local_ss));
1618 memset(&remote_ss, 0,
sizeof(remote_ss));
1627 KNET_TRANSPORT_LOOPBACK,
1628 &local_ss, &remote_ss, KNET_LINK_FLAG_TRAFFICHIPRIO);
1633 &local_ss, &remote_ss, KNET_LINK_FLAG_TRAFFICHIPRIO);
1661 int saved_errno = errno;
1662 log_flush_messages(instance);
1663 errno = saved_errno;
1666 icmap_set_string(
"config.reload_error_message",
"Failed to set knet ping timers");
1674 int saved_errno = errno;
1675 log_flush_messages(instance);
1676 errno = saved_errno;
1678 icmap_set_string(
"config.reload_error_message",
"Failed to set knet pong count");
1701 uint8_t link_list[KNET_MAX_LINK];
1728 res = knet_link_get_link_list(instance->
knet_handle,
1734 if (num_links == 0) {
1747static int totemknet_configure_compression (
1751 struct knet_handle_compress_cfg compress_cfg;
1760 res = knet_handle_compress(instance->
knet_handle, &compress_cfg);
1774 (void)totemknet_configure_compression(instance,
totem_config);
1776#ifdef HAVE_LIBNOZZLE
1780 (void)setup_nozzle(instance);
1786 res = totemknet_set_knet_crypto(instance);
1793 icmap_set_string(
"config.reload_error_message",
"Failed to set knet crypto");
1805#ifdef HAVE_KNET_CRYPTO_RECONF
1808 int config_to_clear;
1809 struct knet_handle_crypto_cfg crypto_cfg;
1817 if (!totemknet_is_crypto_enabled(instance)) {
1822 res = knet_handle_crypto_use_config(instance->
knet_handle, config_to_use);
1836 strcpy(crypto_cfg.crypto_model,
"none");
1837 strcpy(crypto_cfg.crypto_cipher_type,
"none");
1838 strcpy(crypto_cfg.crypto_hash_type,
"none");
1839 res = knet_handle_crypto_set_config(instance->
knet_handle, &crypto_cfg, config_to_clear);
1848 if (totemknet_is_crypto_enabled(instance)) {
1849 res = knet_handle_crypto_rx_clear_traffic(instance->
knet_handle, KNET_CRYPTO_RX_DISALLOW_CLEAR_TRAFFIC);
1864 (void) knet_handle_clear_stats(instance->
knet_handle, KNET_CLEARSTATS_HANDLE_AND_LINK);
1869 knet_node_id_t node, uint8_t link_no,
1870 struct knet_link_status *status)
1884 res = knet_link_get_status(
global_instance->knet_handle, node, link_no, status,
sizeof(
struct knet_link_status));
1906 struct knet_handle_stats *stats)
1915 res = knet_handle_get_stats(
global_instance->knet_handle, stats,
sizeof(
struct knet_handle_stats));
1923static void timer_function_merge_detect_timeout (
1934 totemknet_start_merge_detect_timeout(instance);
1937static void totemknet_start_merge_detect_timeout(
1946 timer_function_merge_detect_timeout,
1947 &instance->timer_merge_detect_timeout);
1951static void totemknet_stop_merge_detect_timeout(
1970 pfd.events = POLLIN;
1973 if ((poll(&pfd, 1, 0) > 0) &&
1974 (pfd.revents & POLLIN) &&
1975 (log_deliver_fn(instance->
logpipes[0], POLLIN, instance) == 0)) {
1984#ifdef HAVE_LIBNOZZLE
1985#define NOZZLE_NAME "nozzle.name"
1986#define NOZZLE_IPADDR "nozzle.ipaddr"
1987#define NOZZLE_PREFIX "nozzle.ipprefix"
1988#define NOZZLE_MACADDR "nozzle.macaddr"
1990#define NOZZLE_CHANNEL 1
1996 char filename[PATH_MAX + FILENAME_MAX + 1];
1997 static char updown_dirname[PATH_MAX + FILENAME_MAX + 1];
1999 const char *dirname_res;
2004 res = snprintf(filename,
sizeof(filename),
"%s",
2006 if (res >=
sizeof(filename)) {
2011 dirname_res = dirname(filename);
2013 res = snprintf(updown_dirname,
sizeof(updown_dirname),
"%s/%s",
2014 dirname_res,
"updown.d");
2015 if (res >=
sizeof(updown_dirname)) {
2019 return updown_dirname;
2032 if (res == -1 && errno != ENOENT) {
2034 }
else if (res == -2) {
2049 const char *input_addr,
2050 const char *prefix,
int nodeid,
2051 char *output_addr,
size_t output_len)
2055 int max_prefix = 64;
2056 uint32_t nodeid_mask;
2058 uint32_t masked_nodeid;
2059 struct in_addr *
addr;
2062 coloncolon = strstr(input_addr,
"::");
2067 bits = atoi(prefix);
2068 if (bits < 8 || bits > max_prefix) {
2075 memcpy(output_addr, input_addr, coloncolon-input_addr);
2076 sprintf(output_addr + (coloncolon-input_addr),
"::%x",
nodeid);
2083 nodeid_mask = UINT32_MAX & ((1<<(32 - bits)) - 1);
2084 addr_mask = UINT32_MAX ^ nodeid_mask;
2085 masked_nodeid =
nodeid & nodeid_mask;
2091 addr = (
struct in_addr *)&totemip.addr;
2092 addr->s_addr &= htonl(addr_mask);
2093 addr->s_addr |= htonl(masked_nodeid);
2095 inet_ntop(AF_INET,
addr, output_addr, output_len);
2099static int create_nozzle_device(
void *knet_context,
const char *name,
2100 const char *ipaddr,
const char *prefix,
2101 const char *macaddr)
2104 char device_name[IFNAMSIZ+1];
2105 size_t size = IFNAMSIZ;
2107 nozzle_t nozzle_dev;
2111 char parsed_ipaddr[INET6_ADDRSTRLEN];
2114 memset(device_name, 0, size);
2115 memset(&mac, 0,
sizeof(mac));
2116 strncpy(device_name, name, size);
2121 nozzle_dev = nozzle_open(device_name, size, updown_dir);
2128 if (nozzle_set_mac(nozzle_dev, macaddr) < 0) {
2133 if (reparse_nozzle_ip_address(instance, ipaddr, prefix, instance->
our_nodeid, parsed_ipaddr,
sizeof(parsed_ipaddr))) {
2138 if (nozzle_add_ip(nozzle_dev, parsed_ipaddr, prefix) < 0) {
2143 nozzle_fd = nozzle_get_fd(nozzle_dev);
2146#ifdef KNET_DATAFD_FLAG_RX_RETURN_INFO
2147 res = knet_handle_add_datafd(instance->
knet_handle, &nozzle_fd, &channel, 0);
2149 res = knet_handle_add_datafd(instance->
knet_handle, &nozzle_fd, &channel);
2156 run_nozzle_script(instance, NOZZLE_PREUP,
"pre-up");
2158 res = nozzle_set_up(nozzle_dev);
2163 run_nozzle_script(instance, NOZZLE_UP,
"up");
2168 nozzle_close(nozzle_dev);
2184 res = knet_handle_remove_datafd(instance->
knet_handle, datafd);
2190 run_nozzle_script(instance, NOZZLE_DOWN,
"pre-down");
2196 run_nozzle_script(instance, NOZZLE_POSTDOWN,
"post-down");
2221 char *ipaddr_str = NULL;
2222 char *name_str = NULL;
2223 char *prefix_str = NULL;
2224 char *macaddr_str = NULL;
2241 remove_nozzle_device(instance);
2242 free_nozzle(instance);
2261 if (macaddr_str && strlen(macaddr_str) != 17) {
2266 macaddr_str = (
char*)
"54:54:01:00:00:00";
2281 memcpy(mac, macaddr_str, 12);
2282 snprintf(mac+12,
sizeof(mac) - 13,
"%02x:%02x",
2287 if (name_res ==
CS_OK && name_str) {
2290 remove_nozzle_device(instance);
2291 free_nozzle(instance);
2294 res = create_nozzle_device(
knet_context, name_str, ipaddr_str, prefix_str,
2309 free_nozzle(instance);
2317 if (macaddr_res ==
CS_OK) {
unsigned char addr[TOTEMIP_ADDRLEN]
cs_error_t qb_to_cs_error(int result)
qb_to_cs_error
cs_error_t
The cs_error_t enum.
#define corosync_exit_error(err)
@ COROSYNC_DONE_MAINCONFIGREAD
cs_error_t icmap_get_uint8(const char *key_name, uint8_t *u8)
#define ICMAP_TRACK_MODIFY
#define ICMAP_TRACK_DELETE
cs_error_t icmap_track_add(const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track)
Add tracking function for given key_name.
cs_error_t icmap_set_string(const char *key_name, const char *value)
#define ICMAP_TRACK_PREFIX
Whole prefix is tracked, instead of key only (so "totem." tracking means that "totem....
struct icmap_track * icmap_track_t
Track type.
cs_error_t icmap_get_string(const char *key_name, char **str)
Shortcut for icmap_get for string type.
#define CFG_INTERFACE_STATUS_MAX_LEN
#define LOGSYS_LEVEL_ERROR
#define log_printf(level, format, args...)
#define LOGSYS_LEVEL_INFO
#define LOGSYS_LEVEL_CRIT
int logsys_config_debug_get(const char *subsys)
Return the debug flag for this subsys.
#define LOGSYS_DEBUG_TRACE
#define LOGSYS_LEVEL_WARNING
int _logsys_subsys_create(const char *subsys, const char *filename)
_logsys_subsys_create
#define LOGSYS_LEVEL_DEBUG
#define LOGSYS_LEVEL_TRACE
const char * corosync_get_config_file(void)
Structure passed as new_value and old_value in change callback.
char crypto_model[CONFIG_STRING_LEN_MAX]
unsigned int private_key_len
uint32_t knet_compression_threshold
struct totem_logging_configuration totem_logging_configuration
struct totem_interface * interfaces
unsigned int merge_timeout
int knet_compression_level
char knet_compression_model[CONFIG_STRING_LEN_MAX]
unsigned int block_unlisted_ips
unsigned char private_key[TOTEM_PRIVATE_KEY_LEN_MAX]
unsigned int knet_pmtud_interval
char crypto_cipher_type[CONFIG_STRING_LEN_MAX]
char link_mode[TOTEM_LINK_MODE_BYTES]
char crypto_hash_type[CONFIG_STRING_LEN_MAX]
struct totem_ip_address boundto
struct totem_ip_address bindnet
The totem_ip_address struct.
void(* log_printf)(int level, int subsys, const char *function_name, const char *file_name, int file_line, const char *format,...) __attribute__((format(printf
struct knet_link_status link_status[KNET_MAX_LINK]
void(* totemknet_target_set_completed)(void *context)
pthread_mutex_t log_mutex
void(* totemknet_mtu_changed)(void *context, int net_mtu)
struct crypto_instance * crypto_inst
struct totem_config * totem_config
qb_loop_timer_handle timer_netif_check_timeout
char * link_status[INTERFACE_MAX]
void(* totemknet_log_printf)(int level, int subsys, const char *function, const char *file, int line, const char *format,...) __attribute__((format(printf
knet_handle_t knet_handle
uint16_t ip_port[INTERFACE_MAX]
int(* totemknet_iface_change_fn)(void *context, const struct totem_ip_address *iface_address, unsigned int link_no)
int totemknet_log_level_debug
struct knet_handle_crypto_cfg last_good_crypto_cfg
struct totem_ip_address token_target
qb_loop_timer_handle timer_merge_detect_timeout
int totemknet_log_level_warning
struct totem_ip_address my_ids[INTERFACE_MAX]
int(* totemknet_deliver_fn)(void *context, const void *msg, unsigned int msg_len, const struct sockaddr_storage *system_from)
char iov_buffer[KNET_MAX_PACKET_SIZE+1]
unsigned int merge_detect_messages_sent_before_timeout
int send_merge_detect_message
int totemknet_log_level_error
int totemknet_log_level_security
int totemknet_log_level_notice
struct totemknet_instance * instance
cfg_message_crypto_reconfig_phase_t
@ CRYPTO_RECONFIG_PHASE_CLEANUP
@ CRYPTO_RECONFIG_PHASE_ACTIVATE
int totemip_parse(struct totem_ip_address *totemip, const char *addr, enum totem_ip_version_enum ip_version)
void totemip_copy(struct totem_ip_address *addr1, const struct totem_ip_address *addr2)
int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr, uint16_t port, struct sockaddr_storage *saddr, int *addrlen)
const char * totemip_print(const struct totem_ip_address *addr)
int totemknet_mcast_flush_send(void *knet_context, const void *msg, unsigned int msg_len)
int totemknet_iface_set(void *knet_context, const struct totem_ip_address *local_addr, unsigned short ip_port, unsigned int iface_no)
int totemknet_finalize(void *knet_context)
int totemknet_recv_flush(void *knet_context)
int totemknet_member_list_rebind_ip(void *knet_context)
void * totemknet_buffer_alloc(void)
int totemknet_processor_count_set(void *knet_context, int processor_count)
int totemknet_mcast_noflush_send(void *knet_context, const void *msg, unsigned int msg_len)
struct totemknet_instance * global_instance
void totemknet_buffer_release(void *ptr)
int totemknet_initialize(qb_loop_t *poll_handle, void **knet_context, struct totem_config *totem_config, totemsrp_stats_t *stats, void *context, int(*deliver_fn)(void *context, const void *msg, unsigned int msg_len, const struct sockaddr_storage *system_from), int(*iface_change_fn)(void *context, const struct totem_ip_address *iface_address, unsigned int link_no), void(*mtu_changed)(void *context, int net_mtu), void(*target_set_completed)(void *context))
Create an instance.
int totemknet_ifaces_get(void *knet_context, char ***status, unsigned int *iface_count)
int totemknet_member_add(void *knet_context, const struct totem_ip_address *local, const struct totem_ip_address *member, int link_no)
int totemknet_crypto_set(void *knet_context, const char *cipher_type, const char *hash_type)
int totemknet_member_remove(void *knet_context, const struct totem_ip_address *token_target, int link_no)
int totemknet_token_send(void *knet_context, const void *msg, unsigned int msg_len)
int totemknet_link_get_status(knet_node_id_t node, uint8_t link_no, struct knet_link_status *status)
int totemknet_nodestatus_get(void *knet_context, unsigned int nodeid, struct totem_node_status *node_status)
int totemknet_handle_get_stats(struct knet_handle_stats *stats)
void totemknet_stats_clear(void *knet_context)
int totemknet_send_flush(void *knet_context)
void totemknet_net_mtu_adjust(void *knet_context, struct totem_config *totem_config)
#define knet_log_printf(level, format, args...)
int totemknet_token_target_set(void *knet_context, unsigned int nodeid)
#define KNET_LOGSYS_PERROR(err_num, level, fmt, args...)
void totemknet_configure_log_level(void)
int totemknet_reconfigure(void *knet_context, struct totem_config *totem_config)
int totemknet_crypto_reconfigure_phase(void *knet_context, struct totem_config *totem_config, cfg_message_crypto_reconfig_phase_t phase)
#define libknet_log_printf(level, format, args...)
int totemknet_recv_mcast_empty(void *knet_context)
int totemknet_iface_check(void *knet_context)
struct totem_message_header header
struct srp_addr system_from
void stats_knet_add_handle(void)
void stats_knet_del_member(knet_node_id_t nodeid, uint8_t link)
void stats_knet_add_member(knet_node_id_t nodeid, uint8_t link)