41#include <sys/socket.h>
46#include <netinet/in.h>
47#include <net/ethernet.h>
91#define CFG_INTERFACE_STATUS_MAX_LEN 512
109 unsigned int msg_len,
201static int totemknet_configure_compression (
205static void totemknet_start_merge_detect_timeout(
208static void totemknet_stop_merge_detect_timeout(
211static void log_flush_messages (
226#define knet_log_printf_lock(level, subsys, function, file, line, format, args...) \
228 (void)pthread_mutex_lock(&instance->log_mutex); \
229 instance->totemknet_log_printf ( \
230 level, subsys, function, file, line, \
231 (const char *)format, ##args); \
232 (void)pthread_mutex_unlock(&instance->log_mutex); \
235#define knet_log_printf(level, format, args...) \
237 knet_log_printf_lock ( \
238 level, instance->totemknet_subsys_id, \
239 __FUNCTION__, __FILE__, __LINE__, \
240 (const char *)format, ##args); \
243#define libknet_log_printf(level, format, args...) \
245 knet_log_printf_lock ( \
246 level, instance->knet_subsys_id, \
247 __FUNCTION__, "libknet.h", __LINE__, \
248 (const char *)format, ##args); \
251#define KNET_LOGSYS_PERROR(err_num, level, fmt, args...) \
253 char _error_str[LOGSYS_MAX_PERROR_MSG_LEN]; \
254 const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str)); \
255 instance->totemknet_log_printf ( \
256 level, instance->totemknet_subsys_id, \
257 __FUNCTION__, __FILE__, __LINE__, \
258 fmt ": %s (%d)", ##args, _error_ptr, err_num); \
265 return (
addr[0] & 0x01);
302static int dst_host_filter_callback_fn(
void *
private_data,
374static inline void ucast_sendmsg (
378 unsigned int msg_len)
387 iovec.iov_base = (
void *)msg;
388 iovec.iov_len = msg_len;
396#ifdef HAVE_MSGHDR_CONTROL
399#ifdef HAVE_MSGHDR_CONTROLLEN
402#ifdef HAVE_MSGHDR_FLAGS
405#ifdef HAVE_MSGHDR_ACCRIGHTS
408#ifdef HAVE_MSGHDR_ACCRIGHTSLEN
420 "sendmsg(ucast) failed (non-critical)");
424static inline void mcast_sendmsg (
427 unsigned int msg_len,
435 iovec.iov_base = (
void *)msg;
436 iovec.iov_len = msg_len;
446#ifdef HAVE_MSGHDR_CONTROL
449#ifdef HAVE_MSGHDR_CONTROLLEN
452#ifdef HAVE_MSGHDR_FLAGS
455#ifdef HAVE_MSGHDR_ACCRIGHTS
458#ifdef HAVE_MSGHDR_ACCRIGHTSLEN
479static int node_compare(
const void *
aptr,
const void *
bptr)
489#ifndef OWN_INDEX_NONE
490#define OWN_INDEX_NONE -1
526#ifdef HAVE_KNET_ONWIRE_VER
554 sizeof(link_status));
645 sizeof(link_status));
647 ptr[
j] =
'0' + (link_status.enabled |
648 link_status.connected<<1 |
649 link_status.dynconnected<<2);
653 "totemknet_ifaces_get: Cannot get link status: %s",
strerror(
errno));
727 totemknet_stop_merge_detect_timeout(instance);
729 log_flush_messages(instance);
739static int log_deliver_fn (
750 len =
read(fd, buffer,
sizeof(buffer));
753 switch (msg->msglevel) {
788static int data_deliver_fn (
807#ifdef HAVE_MSGHDR_CONTROL
810#ifdef HAVE_MSGHDR_CONTROLLEN
813#ifdef HAVE_MSGHDR_FLAGS
816#ifdef HAVE_MSGHDR_ACCRIGHTS
819#ifdef HAVE_MSGHDR_ACCRIGHTSLEN
830#ifdef HAVE_MSGHDR_FLAGS
846 "Received too big message. This may be because something bad is happening"
847 "on the network (attack?), or you tried join more nodes than corosync is"
848 "compiled with (%u) or bug in the code (bad estimation of "
865static void timer_function_netif_check_timeout (
889#ifdef HAVE_KNET_ACCESS_LIST
946static void totemknet_refresh_config(
948 const char *key_name,
974 knet_set_access_list_config(instance);
1029 icmap_set_string(
"config.reload_error_message",
"Failed to set knet ping timers(2)");
1046 totemknet_refresh_config,
1052 totemknet_refresh_config,
1079#ifdef HAVE_KNET_CRYPTO_RECONF
1089 if (!totemknet_is_crypto_enabled(instance)) {
1129#ifdef HAVE_KNET_CRYPTO_RECONF
1131 icmap_set_string(
"config.reload_error_message",
"Failed to set crypto parameters");
1154 void **knet_context,
1162 unsigned int msg_len,
1174 void (*target_set_completed) (
1185 if (instance ==
NULL) {
1189 totemknet_instance_initialize (instance);
1252#if defined(KNET_API_VER) && (KNET_API_VER == 2)
1260#if defined(KNET_API_VER) && (KNET_API_VER == 2)
1272 knet_set_access_list_config(instance);
1312#ifdef HAVE_KNET_CRYPTO_RECONF
1313 if (totemknet_is_crypto_enabled(instance)) {
1314 res = totemknet_set_knet_crypto(instance);
1339 if (totemknet_is_crypto_enabled(instance)) {
1340 res = totemknet_set_knet_crypto(instance);
1374 POLLIN, instance, log_deliver_fn);
1379 POLLIN, instance, data_deliver_fn);
1389 timer_function_netif_check_timeout,
1392 totemknet_start_merge_detect_timeout(instance);
1395 totemknet_add_config_notifications(instance);
1406 log_flush_messages(instance);
1442 unsigned int msg_len)
1447 ucast_sendmsg (instance, &instance->
token_target, msg, msg_len);
1454 unsigned int msg_len)
1459 mcast_sendmsg (instance, msg, msg_len, 0);
1467 unsigned int msg_len)
1472 mcast_sendmsg (instance, msg, msg_len, 1);
1528#ifdef HAVE_MSGHDR_CONTROL
1531#ifdef HAVE_MSGHDR_CONTROLLEN
1534#ifdef HAVE_MSGHDR_FLAGS
1537#ifdef HAVE_MSGHDR_ACCRIGHTS
1540#ifdef HAVE_MSGHDR_ACCRIGHTSLEN
1556 }
while (
nfds == 1);
1563 unsigned short ip_port,
1685 log_flush_messages(instance);
1689 icmap_set_string(
"config.reload_error_message",
"Failed to set knet ping timers");
1698 log_flush_messages(instance);
1701 icmap_set_string(
"config.reload_error_message",
"Failed to set knet pong count");
1770static int totemknet_configure_compression (
1799#ifdef HAVE_LIBNOZZLE
1809 res = totemknet_set_knet_crypto(instance);
1816 icmap_set_string(
"config.reload_error_message",
"Failed to set knet crypto");
1828#ifdef HAVE_KNET_CRYPTO_RECONF
1840 if (!totemknet_is_crypto_enabled(instance)) {
1871 if (totemknet_is_crypto_enabled(instance)) {
1946static void timer_function_merge_detect_timeout (
1957 totemknet_start_merge_detect_timeout(instance);
1960static void totemknet_start_merge_detect_timeout(
1969 timer_function_merge_detect_timeout,
1970 &instance->timer_merge_detect_timeout);
1974static void totemknet_stop_merge_detect_timeout(
1998 (log_deliver_fn(instance->
logpipes[0],
POLLIN, instance) == 0)) {
2007#ifdef HAVE_LIBNOZZLE
2008#define NOZZLE_NAME "nozzle.name"
2009#define NOZZLE_IPADDR "nozzle.ipaddr"
2010#define NOZZLE_PREFIX "nozzle.ipprefix"
2011#define NOZZLE_MACADDR "nozzle.macaddr"
2013#define NOZZLE_CHANNEL 1
2057 }
else if (
res == -2) {
2073 const char *prefix,
int nodeid,
2123 const char *
ipaddr,
const char *prefix,
2228 free(instance->nozzle_name);
2229 free(instance->nozzle_ipaddr);
2230 free(instance->nozzle_prefix);
2231 free(instance->nozzle_macaddr);
2233 instance->nozzle_name = instance->nozzle_ipaddr = instance->nozzle_prefix =
2234 instance->nozzle_macaddr =
NULL;
2288 if (instance->nozzle_name &&
2292 (instance->nozzle_macaddr ==
NULL ||
2308 if (instance->nozzle_name) {
2320 if (!instance->nozzle_name || !instance->nozzle_ipaddr ||
2321 !instance->nozzle_prefix) {
unsigned char addr[TOTEMIP_ADDRLEN]
#define PROCESSOR_COUNT_MAX
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....
cs_error_t icmap_get_string(const char *key_name, char **str)
Shortcut for icmap_get for string type.
#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
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
void(*) void knet_context)
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]
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))
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)
#define CFG_INTERFACE_STATUS_MAX_LEN
int totemknet_link_get_status(knet_node_id_t node, uint8_t link_no, struct knet_link_status *status)
void totemknet_configure_log_level()
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...)
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)