Revert patch that changed VRRP notify scripts to list (#1232073)

This commit is contained in:
Ryan O'Hara 2015-06-23 08:22:14 -05:00
parent d957efe698
commit e63d0ad226
3 changed files with 501 additions and 1 deletions

View File

@ -0,0 +1,202 @@
From bde088a433219ff8f966f53f1a4cb5a504f24fd5 Mon Sep 17 00:00:00 2001
From: Ryan O'Hara <rohara@redhat.com>
Date: Wed, 17 Jun 2015 20:58:31 -0500
Subject: [PATCH 1/2] Revert "Fix notify upon reload"
This reverts commit 89f910217097c1201ff15922a52facc668aa4ab4.
---
keepalived/include/vrrp.h | 8 -----
keepalived/include/vrrp_notify.h | 1 -
keepalived/vrrp/vrrp.c | 9 -----
keepalived/vrrp/vrrp_data.c | 8 ++---
keepalived/vrrp/vrrp_notify.c | 71 ----------------------------------------
keepalived/vrrp/vrrp_scheduler.c | 3 +-
6 files changed, 5 insertions(+), 95 deletions(-)
diff --git a/keepalived/include/vrrp.h b/keepalived/include/vrrp.h
index 12f44e1..8c8b3f3 100644
--- a/keepalived/include/vrrp.h
+++ b/keepalived/include/vrrp.h
@@ -230,14 +230,6 @@ typedef struct _vrrp_t {
/* IPSEC AH counter def (only valid for VRRPv2) --rfc2402.3.3.2 */
seq_counter_t *ipsecah_counter;
list script;
- list pscript[2]; /*
- * previous scripts:
- * [0] contains pointer to list of scripts
- * configured before reload.
- * [1] contains pointer to list of scripts
- * configured two reloads ago. The list
- * pointed to here gets freed during reload.
- */
} vrrp_t;
/* VRRP state machine -- rfc2338.6.4 */
diff --git a/keepalived/include/vrrp_notify.h b/keepalived/include/vrrp_notify.h
index fa0770f..692f10f 100644
--- a/keepalived/include/vrrp_notify.h
+++ b/keepalived/include/vrrp_notify.h
@@ -28,7 +28,6 @@
#include "vrrp.h"
extern int notify_instance_exec(vrrp_t *, int);
-extern int notify_instance_exec_init(vrrp_t *, int);
extern int notify_group_exec(vrrp_sgroup_t *, int);
extern void alloc_notify_script(list, vector_t *);
extern void dump_notify_script(void *);
diff --git a/keepalived/vrrp/vrrp.c b/keepalived/vrrp/vrrp.c
index 8020302..e0715be 100644
--- a/keepalived/vrrp/vrrp.c
+++ b/keepalived/vrrp/vrrp.c
@@ -1758,14 +1758,6 @@ clear_diff_vrrp(void)
netlink_link_del_vmac(vrrp);
}
- /* Obtain reference to list of scripts used before reload
- * to enable a comparison later on to avoid making redundant
- * notifications.
- */
- new_vrrp->pscript[1] = vrrp->pscript[0];
- new_vrrp->pscript[0] = vrrp->script;
- vrrp->script = NULL;
-
/* reset the state */
reset_vrrp_state(vrrp);
}
@@ -1795,4 +1787,3 @@ clear_diff_script(void)
}
}
}
-
diff --git a/keepalived/vrrp/vrrp_data.c b/keepalived/vrrp/vrrp_data.c
index 78d3fdb..42d7af0 100644
--- a/keepalived/vrrp/vrrp_data.c
+++ b/keepalived/vrrp/vrrp_data.c
@@ -213,10 +213,10 @@ free_vrrp(void *data)
FREE(ELEMENT_DATA(e));
free_list(vrrp->track_script);
- if (!LIST_ISEMPTY(vrrp->pscript[1]))
- for (e = LIST_HEAD(vrrp->pscript[1]); e; ELEMENT_NEXT(e))
- FREE(ELEMENT_DATA(e));
- free_list(vrrp->pscript[1]);
+ if (!LIST_ISEMPTY(vrrp->script))
+ for (e = LIST_HEAD(vrrp->script); e; ELEMENT_NEXT(e))
+ FREE(ELEMENT_DATA(e));
+ free_list(vrrp->script);
free_list(vrrp->unicast_peer);
free_list(vrrp->vip);
diff --git a/keepalived/vrrp/vrrp_notify.c b/keepalived/vrrp/vrrp_notify.c
index 935f726..f830341 100644
--- a/keepalived/vrrp/vrrp_notify.c
+++ b/keepalived/vrrp/vrrp_notify.c
@@ -22,7 +22,6 @@
/* system include */
#include <ctype.h>
-#include <stdbool.h>
/* local include */
#include "vrrp_notify.h"
@@ -160,76 +159,6 @@ notify_script_exec(char* script, char *type, int state_num, char* name, int prio
return 1;
}
-/* This function acts as a proxy, temporarily changing each VRRP's notify
- * list. It should be called when we are in the init state. We get to this
- * stage if our daemon has just been initialized, or if we perform a reload
- * on the daemon. In the latter situation, this causes us to leave and then
- * re-enter the state we just left. We do not want to notify when we go
- * from, for example, master->master.
- *
- * This function prevents the above from happening by comparing our current
- * configured notify script list with the previous scripts we had configured.
- * We create a new list that contains scripts that are in our current
- * configuration AND were not in our configuration before reload.
- * We then update our vrrp instance to point to this list temporarily before
- * calling notify_instance_exec(...). After this call has returned, we then
- * update our vrrp reference to point back to the original, currently configured
- * list.
- */
-int
-notify_instance_exec_init(vrrp_t * vrrp, int state)
-{
- bool match = false;
- char *cur_script, *prev_script;
- element e_cur, e_prev = NULL;
- int ret;
- list l_temp = alloc_list(NULL, dump_notify_script);
- list l_orig = vrrp->script;
- notify_sc_t *nsc_cur, *nsc_prev = NULL;
-
- /* The algorithm here is essentially:
- * for each element in our currently configured list
- * if this element did not exist in our previous configuration
- * add this element to our temporary list
- *
- * NOTE: this loop can be optimised if scripts are stored in an
- * alphabetical order. The inner loop can be exited early if
- * strcmp returns > 0.
- */
- if (!LIST_ISEMPTY(vrrp->script) && !LIST_ISEMPTY(vrrp->pscript[0])) {
- for (e_cur = LIST_HEAD(vrrp->script); e_cur; ELEMENT_NEXT(e_cur)) {
- nsc_cur = e_cur->data;
- cur_script = nsc_cur->sname;
- for (e_prev = LIST_HEAD(vrrp->pscript[0]); e_prev; ELEMENT_NEXT(e_prev)) {
- nsc_prev = e_prev->data;
- prev_script = nsc_prev->sname;
- if (strcmp(cur_script, prev_script) == 0) {
- match = true;
- break;
- }
- }
- if (match == false)
- list_add(l_temp, nsc_cur);
- match = false;
- }
- /* Change our reference to temp list. This means the call to
- * notify_instance_exec(...) will only invoke the scripts that we
- * have not previously been configured with.
- */
- vrrp->script = l_temp;
- }
- ret = notify_instance_exec(vrrp, state);
-
- /* Reset our reference back to our original list containing all our
- * configured scripts. This means subsequent state changes will cause
- * all of our configured scripts to be executed
- */
- vrrp->script = l_orig;
-
- free_list(l_temp);
- return ret;
-}
-
int
notify_instance_exec(vrrp_t * vrrp, int state)
{
diff --git a/keepalived/vrrp/vrrp_scheduler.c b/keepalived/vrrp/vrrp_scheduler.c
index b87a93c..7f31032 100644
--- a/keepalived/vrrp/vrrp_scheduler.c
+++ b/keepalived/vrrp/vrrp_scheduler.c
@@ -240,7 +240,6 @@ vrrp_init_state(list l)
vrrp->vrid);
#endif
vrrp->state = VRRP_STATE_GOTO_MASTER;
- notify_instance_exec_init(vrrp, VRRP_STATE_MAST);
} else {
vrrp->ms_down_timer = 3 * vrrp->adver_int
+ VRRP_TIMER_SKEW(vrrp);
@@ -258,7 +257,7 @@ vrrp_init_state(list l)
vrrp_restore_interface(vrrp, 0);
vrrp->state = VRRP_STATE_BACK;
vrrp_smtp_notifier(vrrp);
- notify_instance_exec_init(vrrp, VRRP_STATE_BACK);
+ notify_instance_exec(vrrp, VRRP_STATE_BACK);
#ifdef _WITH_SNMP_
vrrp_snmp_instance_trap(vrrp);
#endif
--
1.9.3

View File

@ -0,0 +1,291 @@
From cc57912f2f947194522d0030ed34fb37d8ab2c17 Mon Sep 17 00:00:00 2001
From: Ryan O'Hara <rohara@redhat.com>
Date: Wed, 17 Jun 2015 20:59:24 -0500
Subject: [PATCH 2/2] Revert "Enhance keepalived vrrp to configure
mltp-scripts"
This reverts commit 5c4177381bee24f9f7fbe33b8dc20c2d9cc2bccb.
---
keepalived/include/vrrp.h | 2 +-
keepalived/include/vrrp_data.h | 1 -
keepalived/include/vrrp_notify.h | 7 -------
keepalived/include/vrrp_print.h | 1 -
keepalived/vrrp/vrrp_data.c | 25 ++++-------------------
keepalived/vrrp/vrrp_notify.c | 43 ++++++++++++----------------------------
keepalived/vrrp/vrrp_parser.c | 4 +++-
keepalived/vrrp/vrrp_print.c | 16 +++------------
keepalived/vrrp/vrrp_snmp.c | 4 ++--
9 files changed, 26 insertions(+), 77 deletions(-)
diff --git a/keepalived/include/vrrp.h b/keepalived/include/vrrp.h
index 8c8b3f3..2d6dded 100644
--- a/keepalived/include/vrrp.h
+++ b/keepalived/include/vrrp.h
@@ -205,6 +205,7 @@ typedef struct _vrrp_t {
char *script_master;
char *script_fault;
char *script_stop;
+ char *script;
/* rfc2336.6.2 */
uint32_t ms_down_timer;
@@ -229,7 +230,6 @@ typedef struct _vrrp_t {
/* IPSEC AH counter def (only valid for VRRPv2) --rfc2402.3.3.2 */
seq_counter_t *ipsecah_counter;
- list script;
} vrrp_t;
/* VRRP state machine -- rfc2338.6.4 */
diff --git a/keepalived/include/vrrp_data.h b/keepalived/include/vrrp_data.h
index bfbcc20..2bbc6a2 100644
--- a/keepalived/include/vrrp_data.h
+++ b/keepalived/include/vrrp_data.h
@@ -79,7 +79,6 @@ extern void alloc_vrrp_unicast_peer(vector_t *);
extern void alloc_vrrp_track(vector_t *);
extern void alloc_vrrp_script(char *);
extern void alloc_vrrp_track_script(vector_t *);
-extern void alloc_vrrp_notify_script(vector_t *);
extern void alloc_vrrp_vip(vector_t *);
extern void alloc_vrrp_evip(vector_t *);
extern void alloc_vrrp_vroute(vector_t *);
diff --git a/keepalived/include/vrrp_notify.h b/keepalived/include/vrrp_notify.h
index 692f10f..8f60c45 100644
--- a/keepalived/include/vrrp_notify.h
+++ b/keepalived/include/vrrp_notify.h
@@ -29,12 +29,5 @@
extern int notify_instance_exec(vrrp_t *, int);
extern int notify_group_exec(vrrp_sgroup_t *, int);
-extern void alloc_notify_script(list, vector_t *);
-extern void dump_notify_script(void *);
-
-/* Notify script structure definition */
-typedef struct _notify_sc {
- char *sname;
-} notify_sc_t;
#endif
diff --git a/keepalived/include/vrrp_print.h b/keepalived/include/vrrp_print.h
index 52ba26f..8307260 100644
--- a/keepalived/include/vrrp_print.h
+++ b/keepalived/include/vrrp_print.h
@@ -30,7 +30,6 @@ extern void vrrp_print_stats(void);
extern void vrrp_print(FILE *file, void *d);
extern void vgroup_print(FILE *file, void *d);
extern void vscript_print(FILE *file, void *d);
-extern void nscript_print(FILE *file, void *d);
extern void address_print(FILE *file, void *d);
extern void route_print(FILE *file, void *d);
extern void if_print(FILE *file, void *d);
diff --git a/keepalived/vrrp/vrrp_data.c b/keepalived/vrrp/vrrp_data.c
index 42d7af0..c79f1b5 100644
--- a/keepalived/vrrp/vrrp_data.c
+++ b/keepalived/vrrp/vrrp_data.c
@@ -30,7 +30,6 @@
#include "utils.h"
#include "logger.h"
#include "bitops.h"
-#include "vrrp_notify.h"
/* global vars */
vrrp_data_t *vrrp_data = NULL;
@@ -200,6 +199,7 @@ free_vrrp(void *data)
FREE_PTR(vrrp->script_master);
FREE_PTR(vrrp->script_fault);
FREE_PTR(vrrp->script_stop);
+ FREE_PTR(vrrp->script);
FREE_PTR(vrrp->stats);
FREE(vrrp->ipsecah_counter);
@@ -213,11 +213,6 @@ free_vrrp(void *data)
FREE(ELEMENT_DATA(e));
free_list(vrrp->track_script);
- if (!LIST_ISEMPTY(vrrp->script))
- for (e = LIST_HEAD(vrrp->script); e; ELEMENT_NEXT(e))
- FREE(ELEMENT_DATA(e));
- free_list(vrrp->script);
-
free_list(vrrp->unicast_peer);
free_list(vrrp->vip);
free_list(vrrp->evip);
@@ -316,11 +311,9 @@ dump_vrrp(void *data)
if (vrrp->script_stop)
log_message(LOG_INFO, " Stop state transition script = %s",
vrrp->script_stop);
- if (!LIST_ISEMPTY(vrrp->script)) {
- log_message(LOG_INFO, " Generic state transition scripts = %d\n",
- LIST_SIZE(vrrp->script));
- dump_list(vrrp->script);
- }
+ if (vrrp->script)
+ log_message(LOG_INFO, " Generic state transition script = '%s'",
+ vrrp->script);
if (vrrp->smtp_alert)
log_message(LOG_INFO, " Using smtp notification");
if (__test_bit(VRRP_VMAC_BIT, &vrrp->vmac_flags))
@@ -453,16 +446,6 @@ alloc_vrrp_track_script(vector_t *strvec)
}
void
-alloc_vrrp_notify_script(vector_t *strvec)
-{
- vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
-
- if (LIST_ISEMPTY(vrrp->script))
- vrrp->script = alloc_list(NULL, dump_notify_script);
- alloc_notify_script(vrrp->script, strvec);
-}
-
-void
alloc_vrrp_vip(vector_t *strvec)
{
vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
diff --git a/keepalived/vrrp/vrrp_notify.c b/keepalived/vrrp/vrrp_notify.c
index f830341..61bc7a3 100644
--- a/keepalived/vrrp/vrrp_notify.c
+++ b/keepalived/vrrp/vrrp_notify.c
@@ -44,6 +44,12 @@ get_iscript(vrrp_t * vrrp, int state)
}
static char *
+get_igscript(vrrp_t * vrrp)
+{
+ return vrrp->script;
+}
+
+static char *
get_gscript(vrrp_sgroup_t * vgroup, int state)
{
if (!vgroup->notify_exec)
@@ -163,9 +169,8 @@ int
notify_instance_exec(vrrp_t * vrrp, int state)
{
char *script = get_iscript(vrrp, state);
+ char *gscript = get_igscript(vrrp);
int ret = 0;
- element e;
- notify_sc_t *nsc;
/* Launch the notify_* script */
if (script && script_open(script)) {
@@ -174,16 +179,12 @@ notify_instance_exec(vrrp_t * vrrp, int state)
}
/* Launch the generic notify script */
- if (!LIST_ISEMPTY(vrrp->script)) {
- for (e = LIST_HEAD(vrrp->script); e; ELEMENT_NEXT(e)) {
- nsc = ELEMENT_DATA(e);
- if (nsc->sname && script_open_litteral(nsc->sname)) {
- notify_script_exec(nsc->sname, "INSTANCE", state, vrrp->iname,
- vrrp->effective_priority);
- ret = 1;
- }
- }
- }
+ if (gscript && script_open_litteral(gscript)) {
+ notify_script_exec(gscript, "INSTANCE", state, vrrp->iname,
+ vrrp->effective_priority);
+ ret = 1;
+ }
+
return ret;
}
@@ -208,21 +209,3 @@ notify_group_exec(vrrp_sgroup_t * vgroup, int state)
return ret;
}
-
-/* Notify script dump */
-void
-dump_notify_script(void *data)
-{
- notify_sc_t *nsc = data;
- log_message(LOG_INFO, " %s", nsc->sname);
-}
-
-void
-alloc_notify_script(list notify_list, vector_t *strvec)
-{
- notify_sc_t *nsc = NULL;
- nsc = (notify_sc_t *) MALLOC(sizeof(notify_sc_t));
- nsc->sname = (char *)MALLOC(strlen(vector_slot(strvec, 0)) + 1);
- strncpy(nsc->sname, vector_slot(strvec, 0), strlen(vector_slot(strvec, 0)) + 1);
- list_add(notify_list, nsc);
-}
diff --git a/keepalived/vrrp/vrrp_parser.c b/keepalived/vrrp/vrrp_parser.c
index 78f42d3..270e550 100644
--- a/keepalived/vrrp/vrrp_parser.c
+++ b/keepalived/vrrp/vrrp_parser.c
@@ -364,7 +364,9 @@ vrrp_notify_stop_handler(vector_t *strvec)
static void
vrrp_notify_handler(vector_t *strvec)
{
- alloc_value_block(strvec, alloc_vrrp_notify_script);
+ vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
+ vrrp->script = set_value(strvec);
+ vrrp->notify_exec = 1;
}
static void
vrrp_smtp_handler(vector_t *strvec)
diff --git a/keepalived/vrrp/vrrp_print.c b/keepalived/vrrp/vrrp_print.c
index 3d7861b..66085a3 100644
--- a/keepalived/vrrp/vrrp_print.c
+++ b/keepalived/vrrp/vrrp_print.c
@@ -27,7 +27,6 @@
#include "vrrp_print.h"
#include "vrrp_iproute.h"
#include "vrrp_netlink.h"
-#include "vrrp_notify.h"
void
vrrp_print_list(FILE *file, list l, void (*fptr)(FILE*, void*))
@@ -193,11 +192,9 @@ vrrp_print(FILE *file, void *data)
if (vrrp->script_stop)
fprintf(file, " Stop state transition script = %s\n",
vrrp->script_stop);
- if (!LIST_ISEMPTY(vrrp->script)) {
- fprintf(file, " Generic state transition scripts = %d\n",
- LIST_SIZE(vrrp->script));
- vrrp_print_list(file, vrrp->script, &nscript_print);
- }
+ if (vrrp->script)
+ fprintf(file, " Generic state transition script = '%s'\n",
+ vrrp->script);
if (vrrp->smtp_alert)
fprintf(file, " Using smtp notification\n");
@@ -260,13 +257,6 @@ vscript_print(FILE *file, void *data)
}
void
-nscript_print(FILE *file, void *data)
-{
- notify_sc_t *nsc = data;
- fprintf(file, " VRRP notify Script = %s\n", nsc->sname);
-}
-
-void
address_print(FILE *file, void *data)
{
ip_address_t *ipaddr = data;
diff --git a/keepalived/vrrp/vrrp_snmp.c b/keepalived/vrrp/vrrp_snmp.c
index 7ddcf7d..f5c5e9a 100644
--- a/keepalived/vrrp/vrrp_snmp.c
+++ b/keepalived/vrrp/vrrp_snmp.c
@@ -810,8 +810,8 @@ vrrp_snmp_instance(struct variable *vp, oid *name, size_t *length,
break;
case VRRP_SNMP_INSTANCE_SCRIPT:
if (rt->script) {
- *var_len = 0;
- return (u_char *) NULL;
+ *var_len = strlen(rt->script);
+ return (u_char *)rt->script;
}
break;
case VRRP_SNMP_INSTANCE_ACCEPT:
--
1.9.3

View File

@ -9,7 +9,7 @@
Name: keepalived
Summary: High Availability monitor built upon LVS, VRRP and service pollers
Version: 1.2.17
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv2+
URL: http://www.keepalived.org/
Group: System Environment/Daemons
@ -18,6 +18,8 @@ Source0: http://www.keepalived.org/software/keepalived-%{version}.tar.gz
Source1: keepalived.service
Patch0: bz1232408-fix-multiple-vrrp-instance-configs.patch
Patch1: bz1232073-revert-fix-notify-upon-reload.patch
Patch2: bz1232073-revert-multiple-notify-scripts.patch
Requires(post): systemd
Requires(preun): systemd
@ -50,6 +52,8 @@ infrastructures.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
%configure \
@ -108,6 +112,9 @@ rm -rf %{buildroot}
%{_mandir}/man8/keepalived.8*
%changelog
* Tue Jun 23 2015 Ryan O'Hara <rohara@redhat.com> - 1.2.17-5
- Revert patch that changed VRRP notify scripts to list (#1232073)
* Wed Jun 17 2015 Ryan O'Hara <rohara@redhat.com> - 1.2.17-4
- Fix multiple VRRP instances with same interface (#1232408)