Skip to content
Snippets Groups Projects
Commit 02dae290 authored by Christian Hesse's avatar Christian Hesse :stuck_out_tongue_winking_eye:
Browse files

new upstream release

parent 94f06bd2
No related branches found
Tags 2.2.7-3
No related merge requests found
From 3b13dccf2bf66f49e2ff5784d3aa359e56871a42 Mon Sep 17 00:00:00 2001
From: Quentin Armitage <quentin@armitage.org.uk>
Date: Wed, 22 Dec 2021 07:27:24 +0000
Subject: [PATCH 1/1] init: Make parent process exit with meaningful status on
error
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
(cherry picked from commit 367473dd4e54dfea9ca4c0c4aa10260173826f4e)
---
keepalived/bfd/bfd_daemon.c | 5 +++--
keepalived/check/check_daemon.c | 5 +++--
keepalived/core/main.c | 2 +-
keepalived/vrrp/vrrp_daemon.c | 5 +++--
lib/scheduler.c | 33 ++++++++++++++++++++++-----------
lib/scheduler.h | 24 +++++++++++++-----------
6 files changed, 45 insertions(+), 29 deletions(-)
diff --git a/keepalived/bfd/bfd_daemon.c b/keepalived/bfd/bfd_daemon.c
index d49dff55..11bcb5d9 100644
--- a/keepalived/bfd/bfd_daemon.c
+++ b/keepalived/bfd/bfd_daemon.c
@@ -313,12 +313,13 @@ static void
bfd_respawn_thread(thread_ref_t thread)
{
unsigned restart_delay;
+ int ret;
/* We catch a SIGCHLD, handle it */
bfd_child = 0;
- if (report_child_status(thread->u.c.status, thread->u.c.pid, NULL))
- thread_add_terminate_event(thread->master);
+ if ((ret = report_child_status(thread->u.c.status, thread->u.c.pid, NULL)))
+ thread_add_parent_terminate_event(thread->master, ret);
else if (!__test_bit(DONT_RESPAWN_BIT, &debug)) {
log_child_died("BFD", thread->u.c.pid);
diff --git a/keepalived/check/check_daemon.c b/keepalived/check/check_daemon.c
index 13385cad..3d8c09fc 100644
--- a/keepalived/check/check_daemon.c
+++ b/keepalived/check/check_daemon.c
@@ -591,12 +591,13 @@ static void
check_respawn_thread(thread_ref_t thread)
{
unsigned restart_delay;
+ int ret;
/* We catch a SIGCHLD, handle it */
checkers_child = 0;
- if (report_child_status(thread->u.c.status, thread->u.c.pid, NULL))
- thread_add_terminate_event(thread->master);
+ if ((ret = report_child_status(thread->u.c.status, thread->u.c.pid, NULL)))
+ thread_add_parent_terminate_event(thread->master, ret);
else if (!__test_bit(DONT_RESPAWN_BIT, &debug)) {
log_child_died("Healthcheck", thread->u.c.pid);
diff --git a/keepalived/core/main.c b/keepalived/core/main.c
index 9fc0426d..92ef0bfb 100644
--- a/keepalived/core/main.c
+++ b/keepalived/core/main.c
@@ -2717,7 +2717,7 @@ keepalived_main(int argc, char **argv)
#endif
/* Launch the scheduling I/O multiplexer */
- launch_thread_scheduler(master);
+ exit_code = launch_thread_scheduler(master);
/* Finish daemon process */
stop_keepalived();
diff --git a/keepalived/vrrp/vrrp_daemon.c b/keepalived/vrrp/vrrp_daemon.c
index db191344..315a8db9 100644
--- a/keepalived/vrrp/vrrp_daemon.c
+++ b/keepalived/vrrp/vrrp_daemon.c
@@ -909,12 +909,13 @@ static void
vrrp_respawn_thread(thread_ref_t thread)
{
unsigned restart_delay;
+ int ret;
/* We catch a SIGCHLD, handle it */
vrrp_child = 0;
- if (report_child_status(thread->u.c.status, thread->u.c.pid, NULL))
- thread_add_terminate_event(thread->master);
+ if ((ret = report_child_status(thread->u.c.status, thread->u.c.pid, NULL)))
+ thread_add_parent_terminate_event(thread->master, ret);
else if (!__test_bit(DONT_RESPAWN_BIT, &debug)) {
log_child_died("VRRP", thread->u.c.pid);
diff --git a/lib/scheduler.c b/lib/scheduler.c
index 9e7a710c..3e199cc0 100644
--- a/lib/scheduler.c
+++ b/lib/scheduler.c
@@ -509,7 +509,7 @@ log_child_died(const char *process, pid_t pid)
}
/* report_child_status returns true if the exit is a hard error, so unable to continue */
-bool
+int
report_child_status(int status, pid_t pid, char const *prog_name)
{
char const *prog_id = NULL;
@@ -533,7 +533,7 @@ report_child_status(int status, pid_t pid, char const *prog_name)
if (exit_status == KEEPALIVED_EXIT_FATAL ||
exit_status == KEEPALIVED_EXIT_CONFIG) {
log_message(LOG_INFO, "%s exited with permanent error %s. Terminating", prog_id, exit_status == KEEPALIVED_EXIT_CONFIG ? "CONFIG" : "FATAL" );
- return true;
+ return exit_status;
}
if (exit_status != EXIT_SUCCESS)
@@ -576,7 +576,7 @@ report_child_status(int status, pid_t pid, char const *prog_name)
WTERMSIG(status) == SIGKILL ? " - has rlimit_rttime been exceeded?" : "");
}
- return false;
+ return 0;
}
#endif
@@ -1418,7 +1418,7 @@ thread_add_event(thread_master_t * m, thread_func_t func, void *arg, int val)
/* Add terminate event thread. */
static thread_ref_t
-thread_add_generic_terminate_event(thread_master_t * m, thread_type_t type, thread_func_t func)
+thread_add_generic_terminate_event(thread_master_t * m, thread_type_t type, thread_func_t func, int status)
{
thread_t *thread;
@@ -1429,7 +1429,7 @@ thread_add_generic_terminate_event(thread_master_t * m, thread_type_t type, thre
thread->master = m;
thread->func = func;
thread->arg = NULL;
- thread->u.val = 0;
+ thread->u.val = status;
INIT_LIST_HEAD(&thread->e_list);
list_add_tail(&thread->e_list, &m->event);
@@ -1439,13 +1439,19 @@ thread_add_generic_terminate_event(thread_master_t * m, thread_type_t type, thre
thread_ref_t
thread_add_terminate_event(thread_master_t *m)
{
- return thread_add_generic_terminate_event(m, THREAD_TERMINATE, NULL);
+ return thread_add_generic_terminate_event(m, THREAD_TERMINATE, NULL, 0);
+}
+
+thread_ref_t
+thread_add_parent_terminate_event(thread_master_t *m, int status)
+{
+ return thread_add_generic_terminate_event(m, THREAD_TERMINATE, NULL, status);
}
thread_ref_t
thread_add_start_terminate_event(thread_master_t *m, thread_func_t func)
{
- return thread_add_generic_terminate_event(m, THREAD_TERMINATE_START, func);
+ return thread_add_generic_terminate_event(m, THREAD_TERMINATE_START, func, 0);
}
#ifdef USE_SIGNAL_THREADS
@@ -1965,12 +1971,13 @@ thread_call(thread_t * thread)
(*thread->func) (thread);
}
-void
+int
process_threads(thread_master_t *m)
{
thread_t* thread;
list_head_t *thread_list;
int thread_type;
+ int exit_code = 0;
/*
* Processing the master thread queues,
@@ -2025,6 +2032,8 @@ process_threads(thread_master_t *m)
thread->type == THREAD_CHILD_TERMINATED ||
thread->type == THREAD_TIMER_SHUTDOWN ||
thread->type == THREAD_TERMINATE) {
+ exit_code = thread->u.val;
+
if (thread->func)
thread_call(thread);
@@ -2060,8 +2069,10 @@ process_threads(thread_master_t *m)
/* If daemon hanging event is received stop processing */
if (thread_type == THREAD_TERMINATE)
- break;
+ return exit_code;
}
+
+ return 0;
}
static void
@@ -2137,13 +2148,13 @@ thread_add_base_threads(thread_master_t *m,
}
/* Our infinite scheduling loop */
-void
+int
launch_thread_scheduler(thread_master_t *m)
{
// TODO - do this somewhere better
signal_set(SIGCHLD, thread_child_handler, m);
- process_threads(m);
+ return process_threads(m);
}
#ifdef THREAD_DUMP
diff --git a/lib/scheduler.h b/lib/scheduler.h
index 782f06ee..9e2cf7f0 100644
--- a/lib/scheduler.h
+++ b/lib/scheduler.h
@@ -200,16 +200,17 @@ typedef enum {
#define THREAD_CHILD_PID(X) ((X)->u.c.pid)
#define THREAD_CHILD_STATUS(X) ((X)->u.c.status)
-/* Exit codes */
+/* Exit codes. The values comply with the LSB so far as possible,
+ * and are also documented in the systemd.exec(5) man page. */
enum exit_code {
KEEPALIVED_EXIT_OK = EXIT_SUCCESS,
- KEEPALIVED_EXIT_NO_MEMORY = EXIT_FAILURE,
- KEEPALIVED_EXIT_PROGRAM_ERROR,
- KEEPALIVED_EXIT_FATAL,
- KEEPALIVED_EXIT_CONFIG,
- KEEPALIVED_EXIT_CONFIG_TEST,
- KEEPALIVED_EXIT_CONFIG_TEST_SECURITY,
- KEEPALIVED_EXIT_NO_CONFIG,
+ KEEPALIVED_EXIT_NO_MEMORY = 204, // EXIT_MEMORY
+ KEEPALIVED_EXIT_PROGRAM_ERROR = 70, // EX_SOFTWARE
+ KEEPALIVED_EXIT_FATAL = 1, // EXIT_FAILURE
+ KEEPALIVED_EXIT_CONFIG = 2, // EXIT_INVALIDARGUMENT
+ KEEPALIVED_EXIT_CONFIG_TEST = 150,
+ KEEPALIVED_EXIT_CONFIG_TEST_SECURITY = 151,
+ KEEPALIVED_EXIT_NO_CONFIG = 6, // EXIT_NOTCONFIGURED
} ;
#define DEFAULT_CHILD_FINDER ((void *)1)
@@ -240,10 +241,11 @@ extern void log_command_line(unsigned);
#ifndef _ONE_PROCESS_DEBUG_
extern unsigned calc_restart_delay(const timeval_t *, unsigned *, const char *);
extern void log_child_died(const char *, pid_t);
-extern bool report_child_status(int, pid_t, const char *);
+extern int report_child_status(int, pid_t, const char *);
#endif
extern thread_master_t *thread_make_master(void);
extern thread_ref_t thread_add_terminate_event(thread_master_t *);
+extern thread_ref_t thread_add_parent_terminate_event(thread_master_t *, int);
extern thread_ref_t thread_add_start_terminate_event(thread_master_t *, thread_func_t);
#ifdef THREAD_DUMP
extern void dump_thread_data(const thread_master_t *, FILE *);
@@ -272,10 +274,10 @@ extern void snmp_timeout_thread(thread_ref_t);
extern void snmp_epoll_info(thread_master_t *);
extern void snmp_epoll_clear(thread_master_t *);
#endif
-extern void process_threads(thread_master_t *);
+extern int process_threads(thread_master_t *);
extern void thread_child_handler(void *, int);
extern void thread_add_base_threads(thread_master_t *, bool);
-extern void launch_thread_scheduler(thread_master_t *);
+extern int launch_thread_scheduler(thread_master_t *);
#ifndef _ONE_PROCESS_DEBUG_
extern void register_shutdown_function(void (*)(int));
#endif
......@@ -2,28 +2,21 @@
# Contributor: Andrea Zucchelli <zukka77@gmail.com>
pkgname=keepalived
pkgver=2.2.4
pkgrel=2
pkgver=2.2.7
pkgrel=1
pkgdesc='Failover and monitoring daemon for LVS clusters'
arch=('x86_64')
url='https://www.keepalived.org/'
license=('GPL2')
backup=('etc/keepalived/keepalived.conf' 'etc/sysconfig/keepalived')
backup=('etc/keepalived/keepalived.conf'
'etc/sysconfig/keepalived')
makedepends=('ipset')
depends=('glibc' 'libnl' 'openssl' 'file' 'iptables' 'systemd-libs')
optdepends=('ipset: ipset support')
makedepends=('libnfnetlink' 'ipset' 'systemd')
options=('!emptydirs')
source=("https://www.keepalived.org/software/$pkgname-$pkgver.tar.gz"
'0001-init-Make-parent-process-exit-with-meaningful-status.patch')
sha256sums=('0138d69087d44beaaa589527f0cfa6885958b320a837147d02b6b7df73ebc1df'
'573dd42f157293eac74ed214fca7bc0b8725d1f5ae7fd759a7e91a79d1afb81d')
prepare() {
cd "${pkgname}-${pkgver}"
patch -Np1 < ../0001-init-Make-parent-process-exit-with-meaningful-status.patch
}
source=("https://www.keepalived.org/software/$pkgname-$pkgver.tar.gz")
sha256sums=('c61940d874154a560a54627ecf7ef47adebdf832164368d10bf242a4d9b7d49d')
build() {
# trick broken ./configure systemctl test
......@@ -45,10 +38,14 @@ build() {
package() {
cd "${pkgname}-${pkgver}"
make DESTDIR="$pkgdir" install
make DESTDIR="${pkgdir}" install
# move conf file to correct name
mv "${pkgdir}"/etc/keepalived/keepalived.conf{.sample,}
# move examples to /usr/share
install -d -m 755 "$pkgdir/usr/share/$pkgname"
mv "$pkgdir/etc/keepalived/samples" "$pkgdir/usr/share/$pkgname/samples"
install -d -m 0755 "${pkgdir}/usr/share/${pkgname}"
mv "${pkgdir}/etc/keepalived/samples" "${pkgdir}/usr/share/$pkgname/samples"
}
# vim:set ts=2 sw=2 et:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment