|
|
ad0d7c |
From fce93460597d27a86798c57ec410f63e4bd33be9 Mon Sep 17 00:00:00 2001
|
|
|
ad0d7c |
From: YAMAMOTO Masaya <pandax381@gmail.com>
|
|
|
ad0d7c |
Date: Fri, 7 Jul 2017 19:27:16 +0900
|
|
|
ad0d7c |
Subject: [PATCH 3/8] Implement comparison of checkers
|
|
|
ad0d7c |
|
|
|
ad0d7c |
---
|
|
|
ad0d7c |
keepalived/check/check_api.c | 29 ++++++++++++++++++++++++-
|
|
|
ad0d7c |
keepalived/check/check_daemon.c | 7 +++++-
|
|
|
ad0d7c |
keepalived/check/check_dns.c | 24 +++++++++++++++++++--
|
|
|
ad0d7c |
keepalived/check/check_http.c | 35 +++++++++++++++++++++++++++++-
|
|
|
ad0d7c |
keepalived/check/check_misc.c | 22 ++++++++++++++++++-
|
|
|
ad0d7c |
keepalived/check/check_smtp.c | 33 +++++++++++++++++++++++++++-
|
|
|
ad0d7c |
keepalived/check/check_tcp.c | 22 +++++++++++++++++--
|
|
|
ad0d7c |
keepalived/check/ipwrapper.c | 38 +++++++++++++++++++++++++--------
|
|
|
ad0d7c |
keepalived/include/check_api.h | 5 +++++
|
|
|
ad0d7c |
9 files changed, 197 insertions(+), 18 deletions(-)
|
|
|
ad0d7c |
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_api.c b/keepalived/check/check_api.c
|
|
|
ad0d7c |
index b7081fd0..a722fc84 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_api.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_api.c
|
|
|
ad0d7c |
@@ -42,8 +42,9 @@
|
|
|
ad0d7c |
#include "check_dns.h"
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* Global vars */
|
|
|
ad0d7c |
-static checker_id_t ncheckers = 0;
|
|
|
ad0d7c |
+checker_id_t ncheckers = 0;
|
|
|
ad0d7c |
list checkers_queue;
|
|
|
ad0d7c |
+list old_checkers_queue;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* free checker data */
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
@@ -80,6 +81,7 @@ dump_conn_opts(void *data)
|
|
|
ad0d7c |
void
|
|
|
ad0d7c |
queue_checker(void (*free_func) (void *), void (*dump_func) (void *)
|
|
|
ad0d7c |
, int (*launch) (thread_t *)
|
|
|
ad0d7c |
+ , int (*compare) (void *, void *)
|
|
|
ad0d7c |
, void *data
|
|
|
ad0d7c |
, conn_opts_t *co)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
@@ -96,6 +98,7 @@ queue_checker(void (*free_func) (void *), void (*dump_func) (void *)
|
|
|
ad0d7c |
checker->free_func = free_func;
|
|
|
ad0d7c |
checker->dump_func = dump_func;
|
|
|
ad0d7c |
checker->launch = launch;
|
|
|
ad0d7c |
+ checker->compare = compare;
|
|
|
ad0d7c |
checker->vs = vs;
|
|
|
ad0d7c |
checker->rs = rs;
|
|
|
ad0d7c |
checker->data = data;
|
|
|
ad0d7c |
@@ -117,6 +120,30 @@ queue_checker(void (*free_func) (void *), void (*dump_func) (void *)
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
+int
|
|
|
ad0d7c |
+compare_conn_opts(conn_opts_t *a, conn_opts_t *b)
|
|
|
ad0d7c |
+{
|
|
|
ad0d7c |
+ if (a == b)
|
|
|
ad0d7c |
+ return 0;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ if (!a || !b)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (!sockstorage_equal(&a->dst, &b->dst))
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (!sockstorage_equal(&a->bindto, &b->bindto))
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ //if (a->connection_to != b->connection_to)
|
|
|
ad0d7c |
+ // goto err;
|
|
|
ad0d7c |
+#ifdef _WITH_SO_MARK_
|
|
|
ad0d7c |
+ if (a->fwmark != b->fwmark)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+#endif
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ return 0;
|
|
|
ad0d7c |
+err:
|
|
|
ad0d7c |
+ return -1;
|
|
|
ad0d7c |
+}
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
checker_set_dst_port(struct sockaddr_storage *dst, uint16_t port)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_daemon.c b/keepalived/check/check_daemon.c
|
|
|
ad0d7c |
index a3ff8cab..462360e6 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_daemon.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_daemon.c
|
|
|
ad0d7c |
@@ -233,7 +233,11 @@ reload_check_thread(__attribute__((unused)) thread_t * thread)
|
|
|
ad0d7c |
thread_cleanup_master(master);
|
|
|
ad0d7c |
free_global_data(global_data);
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- free_checkers_queue();
|
|
|
ad0d7c |
+ /* Save previous checker data */
|
|
|
ad0d7c |
+ old_checkers_queue = checkers_queue;
|
|
|
ad0d7c |
+ checkers_queue = NULL;
|
|
|
ad0d7c |
+ ncheckers = 0;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
free_ssl();
|
|
|
ad0d7c |
ipvs_stop();
|
|
|
ad0d7c |
|
|
|
ad0d7c |
@@ -246,6 +250,7 @@ reload_check_thread(__attribute__((unused)) thread_t * thread)
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* free backup data */
|
|
|
ad0d7c |
free_check_data(old_check_data);
|
|
|
ad0d7c |
+ free_list(&old_checkers_queue);
|
|
|
ad0d7c |
UNSET_RELOAD;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
return 0;
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_dns.c b/keepalived/check/check_dns.c
|
|
|
ad0d7c |
index 96328027..84a5f56d 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_dns.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_dns.c
|
|
|
ad0d7c |
@@ -388,6 +388,26 @@ dns_dump(void *data)
|
|
|
ad0d7c |
log_message(LOG_INFO, " Name = %s", dns_check->name);
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
+static int
|
|
|
ad0d7c |
+dns_compare(void *a, void *b)
|
|
|
ad0d7c |
+{
|
|
|
ad0d7c |
+ dns_check_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
+ dns_check_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ if (compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->retry != new->retry)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (strcmp(old->type, new->type) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (strcmp(old->name, new->name) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ return 0;
|
|
|
ad0d7c |
+err:
|
|
|
ad0d7c |
+ return -1;
|
|
|
ad0d7c |
+}
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
dns_check_handler(__attribute__((unused)) vector_t * strvec)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
@@ -396,8 +416,8 @@ dns_check_handler(__attribute__((unused)) vector_t * strvec)
|
|
|
ad0d7c |
dns_check->attempts = 0;
|
|
|
ad0d7c |
dns_check->type = DNS_DEFAULT_TYPE;
|
|
|
ad0d7c |
dns_check->name = DNS_DEFAULT_NAME;
|
|
|
ad0d7c |
- queue_checker(dns_free, dns_dump, dns_connect_thread, dns_check,
|
|
|
ad0d7c |
- CHECKER_NEW_CO());
|
|
|
ad0d7c |
+ queue_checker(dns_free, dns_dump, dns_connect_thread,
|
|
|
ad0d7c |
+ dns_compare, dns_check, CHECKER_NEW_CO());
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_http.c b/keepalived/check/check_http.c
|
|
|
ad0d7c |
index 05e29b23..c2089a3b 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_http.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_http.c
|
|
|
ad0d7c |
@@ -123,6 +123,38 @@ alloc_http_get(char *proto)
|
|
|
ad0d7c |
return http_get_chk;
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
+static int
|
|
|
ad0d7c |
+compare_http_get_check(void *a, void *b)
|
|
|
ad0d7c |
+{
|
|
|
ad0d7c |
+ http_checker_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
+ http_checker_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
+ size_t n;
|
|
|
ad0d7c |
+ url_t *u1, *u2;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ if (compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->nb_get_retry != new->nb_get_retry)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->delay_before_retry != new->delay_before_retry)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (LIST_SIZE(old->url) != LIST_SIZE(new->url))
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ for (n = 0; n < LIST_SIZE(new->url); n++) {
|
|
|
ad0d7c |
+ u1 = (url_t *)list_element(old->url, n);
|
|
|
ad0d7c |
+ u2 = (url_t *)list_element(new->url, n);
|
|
|
ad0d7c |
+ if (strcmp(u1->path, u2->path) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (strcmp(u1->digest, u2->digest) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (u1->status_code != u2->status_code)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ }
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ return 0;
|
|
|
ad0d7c |
+err:
|
|
|
ad0d7c |
+ return -1;
|
|
|
ad0d7c |
+}
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
http_get_handler(vector_t *strvec)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
@@ -132,7 +164,8 @@ http_get_handler(vector_t *strvec)
|
|
|
ad0d7c |
/* queue new checker */
|
|
|
ad0d7c |
http_get_chk = alloc_http_get(str);
|
|
|
ad0d7c |
queue_checker(free_http_get_check, dump_http_get_check,
|
|
|
ad0d7c |
- http_connect_thread, http_get_chk, CHECKER_NEW_CO());
|
|
|
ad0d7c |
+ http_connect_thread, compare_http_get_check,
|
|
|
ad0d7c |
+ http_get_chk, CHECKER_NEW_CO());
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_misc.c b/keepalived/check/check_misc.c
|
|
|
ad0d7c |
index 10ac1e23..311a1127 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_misc.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_misc.c
|
|
|
ad0d7c |
@@ -72,6 +72,26 @@ dump_misc_check(void *data)
|
|
|
ad0d7c |
log_message(LOG_INFO, " insecure = %s", misck_checker->insecure ? "Yes" : "No");
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
+static int
|
|
|
ad0d7c |
+compare_misc_check(void *a, void *b)
|
|
|
ad0d7c |
+{
|
|
|
ad0d7c |
+ misc_checker_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
+ misc_checker_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ if (strcmp(old->path, new->path) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->timeout != new->timeout)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->dynamic != new->dynamic)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->uid != new->uid || new->gid != new->gid)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ return 0;
|
|
|
ad0d7c |
+err:
|
|
|
ad0d7c |
+ return -1;
|
|
|
ad0d7c |
+}
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
misc_check_handler(__attribute__((unused)) vector_t *strvec)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
@@ -149,7 +169,7 @@ log_message(LOG_INFO, "Setting uid.gid");
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* queue new checker */
|
|
|
ad0d7c |
- queue_checker(free_misc_check, dump_misc_check, misc_check_thread, misck_checker, NULL);
|
|
|
ad0d7c |
+ queue_checker(free_misc_check, dump_misc_check, misc_check_thread, compare_misc_check, misck_checker, NULL);
|
|
|
ad0d7c |
misck_checker = NULL;
|
|
|
ad0d7c |
log_message(LOG_INFO, "Leaving misc_end_handler");
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_smtp.c b/keepalived/check/check_smtp.c
|
|
|
ad0d7c |
index 901b77f5..e19511cc 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_smtp.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_smtp.c
|
|
|
ad0d7c |
@@ -82,6 +82,37 @@ dump_smtp_check(void *data)
|
|
|
ad0d7c |
dump_list(smtp_checker->host);
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
+static int
|
|
|
ad0d7c |
+compare_smtp_check(void *a, void *b)
|
|
|
ad0d7c |
+{
|
|
|
ad0d7c |
+ smtp_checker_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
+ smtp_checker_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
+ size_t n;
|
|
|
ad0d7c |
+ smtp_host_t *h1, *h2;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ if (strcmp(old->helo_name, new->helo_name) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->retry != new->retry)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->db_retry != new->db_retry)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (LIST_SIZE(old->host) != LIST_SIZE(new->host))
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ for (n = 0; n < LIST_SIZE(new->host); n++) {
|
|
|
ad0d7c |
+ h1 = (smtp_host_t *)list_element(old->host, n);
|
|
|
ad0d7c |
+ h2 = (smtp_host_t *)list_element(new->host, n);
|
|
|
ad0d7c |
+ if (compare_conn_opts(h1, h2) != 0) {
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ }
|
|
|
ad0d7c |
+ }
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ return 0;
|
|
|
ad0d7c |
+err:
|
|
|
ad0d7c |
+ return -1;
|
|
|
ad0d7c |
+}
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
/* Allocates a default host structure */
|
|
|
ad0d7c |
static smtp_host_t *
|
|
|
ad0d7c |
smtp_alloc_host(void)
|
|
|
ad0d7c |
@@ -136,7 +167,7 @@ smtp_check_handler(__attribute__((unused)) vector_t *strvec)
|
|
|
ad0d7c |
* void *data, conn_opts_t *)
|
|
|
ad0d7c |
*/
|
|
|
ad0d7c |
queue_checker(free_smtp_check, dump_smtp_check, smtp_connect_thread,
|
|
|
ad0d7c |
- smtp_checker, smtp_checker->default_co);
|
|
|
ad0d7c |
+ compare_smtp_check, smtp_checker, smtp_checker->default_co);
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/*
|
|
|
ad0d7c |
* Last, allocate the list that will hold all the per host
|
|
|
ad0d7c |
diff --git a/keepalived/check/check_tcp.c b/keepalived/check/check_tcp.c
|
|
|
ad0d7c |
index 078ba705..026a0e3c 100644
|
|
|
ad0d7c |
--- a/keepalived/check/check_tcp.c
|
|
|
ad0d7c |
+++ b/keepalived/check/check_tcp.c
|
|
|
ad0d7c |
@@ -62,6 +62,24 @@ dump_tcp_check(void *data)
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
+static int
|
|
|
ad0d7c |
+compare_tcp_check(void *a, void *b)
|
|
|
ad0d7c |
+{
|
|
|
ad0d7c |
+ tcp_check_t *old = CHECKER_DATA(a);
|
|
|
ad0d7c |
+ tcp_check_t *new = CHECKER_DATA(b);
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ if (compare_conn_opts(CHECKER_CO(a), CHECKER_CO(b)) != 0)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->n_retry != new->n_retry)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+ if (old->delay_before_retry != new->delay_before_retry)
|
|
|
ad0d7c |
+ goto err;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ return 0;
|
|
|
ad0d7c |
+err:
|
|
|
ad0d7c |
+ return -1;
|
|
|
ad0d7c |
+}
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
tcp_check_handler(__attribute__((unused)) vector_t *strvec)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
@@ -72,8 +90,8 @@ tcp_check_handler(__attribute__((unused)) vector_t *strvec)
|
|
|
ad0d7c |
tcp_check->delay_before_retry = 1 * TIMER_HZ;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* queue new checker */
|
|
|
ad0d7c |
- queue_checker(free_tcp_check, dump_tcp_check, tcp_connect_thread
|
|
|
ad0d7c |
- ,tcp_check, CHECKER_NEW_CO());
|
|
|
ad0d7c |
+ queue_checker(free_tcp_check, dump_tcp_check, tcp_connect_thread,
|
|
|
ad0d7c |
+ compare_tcp_check, tcp_check, CHECKER_NEW_CO());
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
diff --git a/keepalived/check/ipwrapper.c b/keepalived/check/ipwrapper.c
|
|
|
ad0d7c |
index 6acf18ba..49262e25 100644
|
|
|
ad0d7c |
--- a/keepalived/check/ipwrapper.c
|
|
|
ad0d7c |
+++ b/keepalived/check/ipwrapper.c
|
|
|
ad0d7c |
@@ -626,20 +626,40 @@ rs_exist(real_server_t * old_rs, list l)
|
|
|
ad0d7c |
static void
|
|
|
ad0d7c |
migrate_failed_checkers(real_server_t *old_rs, real_server_t *new_rs)
|
|
|
ad0d7c |
{
|
|
|
ad0d7c |
- element e;
|
|
|
ad0d7c |
- checker_t *checker;
|
|
|
ad0d7c |
+ list l;
|
|
|
ad0d7c |
+ element e, e1;
|
|
|
ad0d7c |
+ checker_t *old_c, *new_c;
|
|
|
ad0d7c |
checker_id_t *id;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
- /* Notes: It's a provisional implementation */
|
|
|
ad0d7c |
- (void)old_rs;
|
|
|
ad0d7c |
+ l = alloc_list(NULL, NULL);
|
|
|
ad0d7c |
+ for (e = LIST_HEAD(old_checkers_queue); e; ELEMENT_NEXT(e)) {
|
|
|
ad0d7c |
+ old_c = ELEMENT_DATA(e);
|
|
|
ad0d7c |
+ if (old_c->rs == old_rs) {
|
|
|
ad0d7c |
+ list_add(l, old_c);
|
|
|
ad0d7c |
+ }
|
|
|
ad0d7c |
+ }
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
+ if (LIST_ISEMPTY(l))
|
|
|
ad0d7c |
+ goto end;
|
|
|
ad0d7c |
+
|
|
|
ad0d7c |
for (e = LIST_HEAD(checkers_queue); e; ELEMENT_NEXT(e)) {
|
|
|
ad0d7c |
- checker = ELEMENT_DATA(e);
|
|
|
ad0d7c |
- if (checker->rs == new_rs) {
|
|
|
ad0d7c |
- id = (checker_id_t *) MALLOC(sizeof(checker_id_t));
|
|
|
ad0d7c |
- *id = checker->id;
|
|
|
ad0d7c |
- list_add(new_rs->failed_checkers, id);
|
|
|
ad0d7c |
+ new_c = ELEMENT_DATA(e);
|
|
|
ad0d7c |
+ if (new_c->rs != new_rs || !new_c->compare)
|
|
|
ad0d7c |
+ continue;
|
|
|
ad0d7c |
+ for (e1 = LIST_HEAD(l); e1; ELEMENT_NEXT(e1)) {
|
|
|
ad0d7c |
+ old_c = ELEMENT_DATA(e1);
|
|
|
ad0d7c |
+ if (old_c->compare == new_c->compare && new_c->compare(old_c, new_c) == 0) {
|
|
|
ad0d7c |
+ if (svr_checker_up(old_c->id, old_rs) == 0) {
|
|
|
ad0d7c |
+ id = (checker_id_t *) MALLOC(sizeof(checker_id_t));
|
|
|
ad0d7c |
+ *id = old_c->id;
|
|
|
ad0d7c |
+ list_add(new_rs->failed_checkers, id);
|
|
|
ad0d7c |
+ }
|
|
|
ad0d7c |
+ break;
|
|
|
ad0d7c |
+ }
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
+end:
|
|
|
ad0d7c |
+ free_list(&l);
|
|
|
ad0d7c |
}
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* Clear the diff rs of the old vs */
|
|
|
ad0d7c |
diff --git a/keepalived/include/check_api.h b/keepalived/include/check_api.h
|
|
|
ad0d7c |
index 359c794a..4a10a36b 100644
|
|
|
ad0d7c |
--- a/keepalived/include/check_api.h
|
|
|
ad0d7c |
+++ b/keepalived/include/check_api.h
|
|
|
ad0d7c |
@@ -36,6 +36,7 @@ typedef struct _checker {
|
|
|
ad0d7c |
void (*free_func) (void *);
|
|
|
ad0d7c |
void (*dump_func) (void *);
|
|
|
ad0d7c |
int (*launch) (struct _thread *);
|
|
|
ad0d7c |
+ int (*compare) (void *, void *);
|
|
|
ad0d7c |
virtual_server_t *vs; /* pointer to the checker thread virtualserver */
|
|
|
ad0d7c |
real_server_t *rs; /* pointer to the checker thread realserver */
|
|
|
ad0d7c |
void *data;
|
|
|
ad0d7c |
@@ -46,7 +47,9 @@ typedef struct _checker {
|
|
|
ad0d7c |
} checker_t;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* Checkers queue */
|
|
|
ad0d7c |
+extern checker_id_t ncheckers;
|
|
|
ad0d7c |
extern list checkers_queue;
|
|
|
ad0d7c |
+extern list old_checkers_queue;
|
|
|
ad0d7c |
|
|
|
ad0d7c |
/* utility macro */
|
|
|
ad0d7c |
#define CHECKER_ARG(X) ((X)->data)
|
|
|
ad0d7c |
@@ -68,8 +71,10 @@ extern void init_checkers_queue(void);
|
|
|
ad0d7c |
extern void dump_conn_opts(void *);
|
|
|
ad0d7c |
extern void queue_checker(void (*free_func) (void *), void (*dump_func) (void *)
|
|
|
ad0d7c |
, int (*launch) (thread_t *)
|
|
|
ad0d7c |
+ , int (*compare) (void *, void *)
|
|
|
ad0d7c |
, void *
|
|
|
ad0d7c |
, conn_opts_t *);
|
|
|
ad0d7c |
+extern int compare_conn_opts(conn_opts_t *, conn_opts_t *);
|
|
|
ad0d7c |
extern void dump_checkers_queue(void);
|
|
|
ad0d7c |
extern void free_checkers_queue(void);
|
|
|
ad0d7c |
extern void register_checkers_thread(void);
|
|
|
ad0d7c |
--
|
|
|
ad0d7c |
2.20.1
|
|
|
ad0d7c |
|