diff --git a/Fail-to-start-if-knet-ping-timers-are-invalid.patch b/Fail-to-start-if-knet-ping-timers-are-invalid.patch new file mode 100644 index 0000000..3476cba --- /dev/null +++ b/Fail-to-start-if-knet-ping-timers-are-invalid.patch @@ -0,0 +1,466 @@ +From 1fb9e940462d393e1946e65dd5b26c416fe0f9e8 Mon Sep 17 00:00:00 2001 +From: zouzhimin +Date: Thu, 26 Oct 2023 15:39:58 +0800 +Subject: [PATCH] Fail to start if knet ping timers are invalid + +--- + exec/totemconfig.c | 16 +++++++++++----- + exec/totemconfig.h | 2 +- + exec/totemknet.c | 37 ++++++++++++++++++++++++++++--------- + exec/totemknet.h | 4 ++-- + exec/totemnet.c | 8 ++++---- + exec/totemnet.h | 4 ++-- + exec/totemsrp.c | 18 ++++++++++-------- + exec/totemudp.c | 8 ++++---- + exec/totemudp.h | 4 ++-- + exec/totemudpu.c | 8 ++++---- + exec/totemudpu.h | 4 ++-- + 11 files changed, 70 insertions(+), 43 deletions(-) + +diff --git a/exec/totemconfig.c b/exec/totemconfig.c +index 568f973..a6394a2 100644 +--- a/exec/totemconfig.c ++++ b/exec/totemconfig.c +@@ -1157,11 +1157,12 @@ static void calc_knet_ping_timers(struct totem_config *totem_config) + * (set to 0), and ips which are only in set1 or set2 remains untouched. + * totempg_node_add/remove is called. + */ +-static void compute_and_set_totempg_interfaces(struct totem_interface *set1, ++static int compute_and_set_totempg_interfaces(struct totem_interface *set1, + struct totem_interface *set2) + { + int ring_no, set1_pos, set2_pos; + struct totem_ip_address empty_ip_address; ++ int res = 0; + + memset(&empty_ip_address, 0, sizeof(empty_ip_address)); + +@@ -1217,10 +1218,13 @@ static void compute_and_set_totempg_interfaces(struct totem_interface *set1, + totemip_print(&set2[ring_no].member_list[set2_pos]), + ring_no); + +- totempg_member_add(&set2[ring_no].member_list[set2_pos], ring_no); ++ if (totempg_member_add(&set2[ring_no].member_list[set2_pos], ring_no)) { ++ res = -1; ++ } + } + } + } ++ return res; + } + + /* +@@ -2414,10 +2418,11 @@ int totemconfig_configure_new_params( + return 0; + } + +-void totemconfig_commit_new_params( ++int totemconfig_commit_new_params( + struct totem_config *totem_config, + icmap_map_t map) + { ++ int res; + struct totem_interface *new_interfaces = NULL; + + new_interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX); +@@ -2427,13 +2432,14 @@ void totemconfig_commit_new_params( + /* Set link parameters including local_ip */ + configure_totem_links(totem_config, map); + +- /* Add & remove nodes */ +- compute_and_set_totempg_interfaces(totem_config->orig_interfaces, new_interfaces); ++ /* Add & remove nodes & link properties */ ++ res = compute_and_set_totempg_interfaces(totem_config->orig_interfaces, new_interfaces); + + /* Does basic global params (like compression) */ + totempg_reconfigure(); + + free(new_interfaces); ++ return res; /* On a reload this is ignored */ + } + + static void add_totem_config_notification(struct totem_config *totem_config) +diff --git a/exec/totemconfig.h b/exec/totemconfig.h +index 2ea338f..a0b2e10 100644 +--- a/exec/totemconfig.h ++++ b/exec/totemconfig.h +@@ -86,7 +86,7 @@ extern int totemconfig_configure_new_params( + icmap_map_t map, + const char **error_string); + +-extern void totemconfig_commit_new_params( ++extern int totemconfig_commit_new_params( + struct totem_config *totem_config, + icmap_map_t map); + +diff --git a/exec/totemknet.c b/exec/totemknet.c +index 55905ee..f280a09 100644 +--- a/exec/totemknet.c ++++ b/exec/totemknet.c +@@ -101,13 +101,13 @@ struct totemknet_instance { + + void *context; + +- void (*totemknet_deliver_fn) ( ++ int (*totemknet_deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from); + +- void (*totemknet_iface_change_fn) ( ++ int (*totemknet_iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int link_no); +@@ -865,14 +865,20 @@ static void timer_function_netif_check_timeout ( + { + struct totemknet_instance *instance = (struct totemknet_instance *)data; + int i; ++ int res = 0; + + for (i=0; i < INTERFACE_MAX; i++) { + if (!instance->totem_config->interfaces[i].configured) { + continue; + } +- instance->totemknet_iface_change_fn (instance->context, +- &instance->my_ids[i], +- i); ++ res = instance->totemknet_iface_change_fn (instance->context, ++ &instance->my_ids[i], ++ i); ++ } ++ if (res != 0) { ++ /* This is only called at startup, so we can quit here. ++ Refresh takes a different path */ ++ corosync_exit_error(COROSYNC_DONE_MAINCONFIGREAD); + } + } + +@@ -1121,13 +1127,13 @@ int totemknet_initialize ( + totemsrp_stats_t *stats, + void *context, + +- void (*deliver_fn) ( ++ int (*deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from), + +- void (*iface_change_fn) ( ++ int (*iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int link_no), +@@ -1634,20 +1640,33 @@ int totemknet_member_add ( + KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_priority for nodeid " CS_PRI_NODE_ID ", link %d failed", member->nodeid, link_no); + } + +- /* ping timeouts maybe 0 here for a newly added interface so we leave this till later, it will +- get done in totemknet_refresh_config */ ++ /* ++ * Ping timeouts may be 0 here for a newly added interface (on a reload), ++ * so we leave this till later, it will get done in totemknet_refresh_config. ++ * For the initial startup, we are all preset and ready to go from here. ++ */ + if (instance->totem_config->interfaces[link_no].knet_ping_interval != 0) { + err = knet_link_set_ping_timers(instance->knet_handle, member->nodeid, link_no, + instance->totem_config->interfaces[link_no].knet_ping_interval, + instance->totem_config->interfaces[link_no].knet_ping_timeout, + instance->totem_config->interfaces[link_no].knet_ping_precision); + if (err) { ++ /* Flush logs before reporting this error so that the knet message prints before ours */ ++ int saved_errno = errno; ++ log_flush_messages(instance); ++ errno = saved_errno; + KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_ping_timers for nodeid " CS_PRI_NODE_ID ", link %d failed", member->nodeid, link_no); ++ return -1; + } + err = knet_link_set_pong_count(instance->knet_handle, member->nodeid, link_no, + instance->totem_config->interfaces[link_no].knet_pong_count); + if (err) { ++ /* Flush logs before reporting this error so that the knet message prints before ours */ ++ int saved_errno = errno; ++ log_flush_messages(instance); ++ errno = saved_errno; + KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_pong_count for nodeid " CS_PRI_NODE_ID ", link %d failed", member->nodeid, link_no); ++ return -1; + } + } + +diff --git a/exec/totemknet.h b/exec/totemknet.h +index 67c0ba6..4d4f61e 100644 +--- a/exec/totemknet.h ++++ b/exec/totemknet.h +@@ -51,13 +51,13 @@ extern int totemknet_initialize ( + totemsrp_stats_t *stats, + void *context, + +- void (*deliver_fn) ( ++ int (*deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from), + +- void (*iface_change_fn) ( ++ int (*iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int ring_no), +diff --git a/exec/totemnet.c b/exec/totemnet.c +index a4b90a3..58992e6 100644 +--- a/exec/totemnet.c ++++ b/exec/totemnet.c +@@ -56,13 +56,13 @@ struct transport { + totemsrp_stats_t *stats, + void *context, + +- void (*deliver_fn) ( ++ int (*deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from), + +- void (*iface_change_fn) ( ++ int (*iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int ring_no), +@@ -321,13 +321,13 @@ int totemnet_initialize ( + totemsrp_stats_t *stats, + void *context, + +- void (*deliver_fn) ( ++ int (*deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from), + +- void (*iface_change_fn) ( ++ int (*iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int ring_no), +diff --git a/exec/totemnet.h b/exec/totemnet.h +index c6a9923..e71d9e0 100644 +--- a/exec/totemnet.h ++++ b/exec/totemnet.h +@@ -61,13 +61,13 @@ extern int totemnet_initialize ( + totemsrp_stats_t *stats, + void *context, + +- void (*deliver_fn) ( ++ int (*deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from), + +- void (*iface_change_fn) ( ++ int (*iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int iface_no), +diff --git a/exec/totemsrp.c b/exec/totemsrp.c +index fd71771..63a47c1 100644 +--- a/exec/totemsrp.c ++++ b/exec/totemsrp.c +@@ -664,13 +664,13 @@ static void *totemsrp_buffer_alloc (struct totemsrp_instance *instance); + static void totemsrp_buffer_release (struct totemsrp_instance *instance, void *ptr); + static const char* gsfrom_to_msg(enum gather_state_from gsfrom); + +-void main_deliver_fn ( ++int main_deliver_fn ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from); + +-void main_iface_change_fn ( ++int main_iface_change_fn ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int iface_no); +@@ -5032,7 +5032,7 @@ static int check_message_header_validity( + } + + +-void main_deliver_fn ( ++int main_deliver_fn ( + void *context, + const void *msg, + unsigned int msg_len, +@@ -5042,7 +5042,7 @@ void main_deliver_fn ( + const struct totem_message_header *message_header = msg; + + if (check_message_header_validity(context, msg, msg_len, system_from) == -1) { +- return ; ++ return -1; + } + + switch (message_header->type) { +@@ -5071,12 +5071,12 @@ void main_deliver_fn ( + (int)message_header->type); + + instance->stats.rx_msg_dropped++; +- return; ++ return 0; + } + /* + * Handle incoming message + */ +- totemsrp_message_handlers.handler_functions[(int)message_header->type] ( ++ return totemsrp_message_handlers.handler_functions[(int)message_header->type] ( + instance, + msg, + msg_len, +@@ -5104,7 +5104,7 @@ int totemsrp_iface_set ( + } + + /* Contrary to its name, this only gets called when the interface is enabled */ +-void main_iface_change_fn ( ++int main_iface_change_fn ( + void *context, + const struct totem_ip_address *iface_addr, + unsigned int iface_no) +@@ -5112,6 +5112,7 @@ void main_iface_change_fn ( + struct totemsrp_instance *instance = context; + int num_interfaces; + int i; ++ int res = 0; + + if (!instance->my_id.nodeid) { + instance->my_id.nodeid = iface_addr->nodeid; +@@ -5154,11 +5155,12 @@ void main_iface_change_fn ( + assert(instance->totem_config->orig_interfaces != NULL); + memset(instance->totem_config->orig_interfaces, 0, sizeof (struct totem_interface) * INTERFACE_MAX); + +- totemconfig_commit_new_params(instance->totem_config, icmap_get_global_map()); ++ res = totemconfig_commit_new_params(instance->totem_config, icmap_get_global_map()); + + memb_state_gather_enter (instance, TOTEMSRP_GSFROM_INTERFACE_CHANGE); + free(instance->totem_config->orig_interfaces); + } ++ return res; + } + + void totemsrp_net_mtu_adjust (struct totem_config *totem_config) { +diff --git a/exec/totemudp.c b/exec/totemudp.c +index fd3215b..0ebe127 100644 +--- a/exec/totemudp.c ++++ b/exec/totemudp.c +@@ -110,13 +110,13 @@ struct totemudp_instance { + + void *context; + +- void (*totemudp_deliver_fn) ( ++ int (*totemudp_deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from); + +- void (*totemudp_iface_change_fn) ( ++ int (*totemudp_iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int ring_no); +@@ -1136,13 +1136,13 @@ int totemudp_initialize ( + + void *context, + +- void (*deliver_fn) ( ++ int (*deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from), + +- void (*iface_change_fn) ( ++ int (*iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int ring_no), +diff --git a/exec/totemudp.h b/exec/totemudp.h +index 7d2abcd..6642472 100644 +--- a/exec/totemudp.h ++++ b/exec/totemudp.h +@@ -51,13 +51,13 @@ extern int totemudp_initialize ( + totemsrp_stats_t *stats, + void *context, + +- void (*deliver_fn) ( ++ int (*deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from), + +- void (*iface_change_fn) ( ++ int (*iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int ring_no), +diff --git a/exec/totemudpu.c b/exec/totemudpu.c +index a7029a4..d3d096c 100644 +--- a/exec/totemudpu.c ++++ b/exec/totemudpu.c +@@ -100,13 +100,13 @@ struct totemudpu_instance { + + void *context; + +- void (*totemudpu_deliver_fn) ( ++ int (*totemudpu_deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from); + +- void (*totemudpu_iface_change_fn) ( ++ int (*totemudpu_iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int ring_no); +@@ -957,13 +957,13 @@ int totemudpu_initialize ( + totemsrp_stats_t *stats, + void *context, + +- void (*deliver_fn) ( ++ int (*deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from), + +- void (*iface_change_fn) ( ++ int (*iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int ring_no), +diff --git a/exec/totemudpu.h b/exec/totemudpu.h +index 07e6345..fe530ca 100644 +--- a/exec/totemudpu.h ++++ b/exec/totemudpu.h +@@ -51,13 +51,13 @@ extern int totemudpu_initialize ( + totemsrp_stats_t *stats, + void *context, + +- void (*deliver_fn) ( ++ int (*deliver_fn) ( + void *context, + const void *msg, + unsigned int msg_len, + const struct sockaddr_storage *system_from), + +- void (*iface_change_fn) ( ++ int (*iface_change_fn) ( + void *context, + const struct totem_ip_address *iface_address, + unsigned int ring_no), +-- +2.33.0 + diff --git a/corosync.spec b/corosync.spec old mode 100755 new mode 100644 index 42fc153..61c91d2 --- a/corosync.spec +++ b/corosync.spec @@ -18,13 +18,14 @@ Name: corosync Summary: The Corosync Cluster Engine and Application Programming Interfaces Version: 3.1.7 -Release: 3 +Release: 4 License: BSD-3-Clause URL: http://corosync.github.io/corosync/ Source0: http://build.clusterlabs.org/corosync/releases/%{name}-%{version}%{?gittarver}.tar.gz # https://github.com/corosync/corosync/pull/717 Patch0: Use-knet-TRACE-logging-level-if-available.patch +Patch1: Fail-to-start-if-knet-ping-timers-are-invalid.patch # Runtime bits # The automatic dependency overridden in favor of explicit version lock @@ -74,6 +75,7 @@ BuildRequires: readline-devel %prep %setup -q -n %{name}-%{version}%{?gittarver} %patch0 -p1 +%patch1 -p1 %build %if %{with runautogen} @@ -291,6 +293,9 @@ network splits) %endif %changelog +* Thu Oct 26 2023 zouzhimin - 3.1.7-4 +- Fail to start if knet ping timers are invalid + * Tue Aug 22 2023 jiangxinyu - 3.1.7-3 - Use knet TRACE logging level if available