From 3e2fd043d69076fda9bf688adfa70fd894b310ec Mon Sep 17 00:00:00 2001 From: bizhiyuan Date: Fri, 14 Jun 2024 15:58:23 +0800 Subject: [PATCH] pacemaker Store booth cfg name attribute transport Fix _find_myself for kernel 6.9 --- ...maker-Store-booth-cfg-name-attribute.patch | 50 +++++++++++++ ...port-Fix-_find_myself-for-kernel-6.9.patch | 72 +++++++++++++++++++ booth.spec | 10 ++- 3 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 backport-pacemaker-Store-booth-cfg-name-attribute.patch create mode 100644 backport-transport-Fix-_find_myself-for-kernel-6.9.patch diff --git a/backport-pacemaker-Store-booth-cfg-name-attribute.patch b/backport-pacemaker-Store-booth-cfg-name-attribute.patch new file mode 100644 index 0000000..3f7526a --- /dev/null +++ b/backport-pacemaker-Store-booth-cfg-name-attribute.patch @@ -0,0 +1,50 @@ +From 27bb52addacda19bb028aecfca7ff52a56c209c5 Mon Sep 17 00:00:00 2001 +From: Jan Friesse +Date: Thu, 30 May 2024 17:09:02 +0200 +Subject: [PATCH 14/20] pacemaker: Store booth-cfg-name attribute + +This can be useful to find out if ticket is managed by booth and what +specific booth instance. So cluster configuration tools can delete CIB +ticket when removing ticket from booth configuration. + +Fixes #135 + +Signed-off-by: Jan Friesse +--- +src/pacemaker.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/pacemaker.c b/src/pacemaker.c +index 80aa1a3..9239fdf 100644 +--- a/src/pacemaker.c ++++ b/src/pacemaker.c +@@ -133,14 +133,16 @@ static int pcmk_write_ticket_atomic(struct ticket_config *tk, int grant) + "%s --force " + "-S owner --attr-value=%" PRIi32 " " + "-S expires --attr-value=%" PRIi64 " " +- "-S term --attr-value=%" PRIi64, ++ "-S term --attr-value=%" PRIi64 " " ++ "-S booth-cfg-name --attr-value=%s", + tk->name, + (grant > 0 ? "-g" : + grant < 0 ? "-r" : + ""), + (int32_t)get_node_id(tk->leader), + (int64_t)wall_ts(&tk->term_expires), +- (int64_t)tk->current_term); ++ (int64_t)tk->current_term, ++ booth_conf->name); + + if (rv < 0 || rv >= COMMAND_MAX) { + log_error("pcmk_write_ticket_atomic: cannot format crm_ticket cmdline (probably too long)"); +@@ -359,6 +361,7 @@ struct attr_tab attr_handlers[] = { + { "owner", save_owner}, + { "id", ignore_attr}, + { "last-granted", ignore_attr}, ++ { "booth-cfg-name", ignore_attr}, + { NULL, 0}, + }; + +-- +2.33.0 + diff --git a/backport-transport-Fix-_find_myself-for-kernel-6.9.patch b/backport-transport-Fix-_find_myself-for-kernel-6.9.patch new file mode 100644 index 0000000..798a020 --- /dev/null +++ b/backport-transport-Fix-_find_myself-for-kernel-6.9.patch @@ -0,0 +1,72 @@ +From 7d93365197f3df144ea007a0ce27cff3b59af8d3 Mon Sep 17 00:00:00 2001 +From: Jan Friesse +Date: Tue, 23 Apr 2024 18:01:02 +0200 +Subject: [PATCH 13/20] transport: Fix _find_myself for kernel 6.9 + +Kernel 6.9 seems to have changed AF_NETLINK behavior slightly making +booth unable to start. + +Previously it was expected only first item in +the message can be NLMSG_DONE or NLMSG_ERROR type. And it looks this was +true for Kernel < 6.9. + +With kernel 6.9 this is no longer true, so any item can be type +NLMSG_DONE or NLMSG_ERROR. + +Result was loop was never terminated and booth was waiting for more +messages from kernel which never arrived. + +Solution is to change loop a bit so NLMSG_DONE, NLMSG_ERROR and +RTM_NEWADDR are handled correctly. + +Signed-off-by: Jan Friesse +--- + src/transport.c | 21 ++++++++++----------- + 1 file changed, 10 insertions(+), 11 deletions(-) + +diff --git a/src/transport.c b/src/transport.c +index 0d17f18..817a4dc 100644 +--- a/src/transport.c ++++ b/src/transport.c +@@ -208,17 +208,16 @@ int _find_myself(int family, struct booth_site **mep, int fuzzy_allowed) + return 0; + } + +- h = (struct nlmsghdr *)rcvbuf; +- if (h->nlmsg_type == NLMSG_DONE) +- break; +- +- if (h->nlmsg_type == NLMSG_ERROR) { +- close(fd); +- log_error("netlink socket recvmsg error"); +- return 0; +- } ++ for (h = (struct nlmsghdr *)rcvbuf; NLMSG_OK(h, status); h = NLMSG_NEXT(h, status)) { ++ if (h->nlmsg_type == NLMSG_DONE) ++ goto out; ++ ++ if (h->nlmsg_type == NLMSG_ERROR) { ++ close(fd); ++ log_error("netlink socket recvmsg error"); ++ return 0; ++ } + +- while (NLMSG_OK(h, status)) { + if (h->nlmsg_type == RTM_NEWADDR) { + struct ifaddrmsg *ifa = NLMSG_DATA(h); + struct rtattr *tb[IFA_MAX+1]; +@@ -271,10 +270,10 @@ int _find_myself(int family, struct booth_site **mep, int fuzzy_allowed) + } + } + } +- h = NLMSG_NEXT(h, status); + } + } + ++out: + close(fd); + + if (!me) +-- +2.25.1 + diff --git a/booth.spec b/booth.spec index fe222ce..7512c4b 100644 --- a/booth.spec +++ b/booth.spec @@ -24,7 +24,7 @@ %bcond_with run_build_tests %bcond_with include_unit_test -%global release 7 +%global release 8 ## User and group to use for nonprivileged services (should be in sync with pacemaker) %global uname hacluster @@ -54,8 +54,8 @@ Patch2: pacemaker-Use-long-format-for-crm_ticket-v.patch Patch3: pacemaker-Check-snprintf-return-values.patch Patch0004: backport-CVE-2024-3049.patch Patch0005: backport-Add-support-for-GnuTLS.patch - - +Patch0006: backport-transport-Fix-_find_myself-for-kernel-6.9.patch +Patch0007: backport-pacemaker-Store-booth-cfg-name-attribute.patch # direct build process dependencies BuildRequires: autoconf @@ -304,6 +304,10 @@ VERBOSE=1 make check %{_usr}/lib/ocf/resource.d/booth/sharedrsc %changelog +* Thu Jun 13 2024 bizhiyuan -1.1-8 +- pacemaker store booth cfg name attribute +- transport fix find_myself for kernel 6.9 + * Tue Jun 11 2024 zouzhimin -1.1-7 - Add support for GnuTLS as and alternative for mcrypt and gcrypt -- Gitee