From 1ef6d477f4bd4b8e8c61748205352b6ff34936d3 Mon Sep 17 00:00:00 2001
From: Quentin Armitage <quentin@armitage.org.uk>
Date: Tue, 7 Apr 2020 23:47:16 +0100
Subject: [PATCH 006/691] Fix interfaaces coming up during vrrp_script init
 phase

Issue #1532 reported that if a tracked interface transitioned from
down to up while a vrrp_script was running for the first time, the
tracking vrrp instances would never come up. This commit resolves
the issue.

Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
---
 keepalived/vrrp/vrrp_scheduler.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/keepalived/vrrp/vrrp_scheduler.c b/keepalived/vrrp/vrrp_scheduler.c
index 6eac8fd..6f3586d 100644
--- a/keepalived/vrrp/vrrp_scheduler.c
+++ b/keepalived/vrrp/vrrp_scheduler.c
@@ -623,8 +623,17 @@ try_up_instance(vrrp_t *vrrp, bool leaving_init)
 		if (vrrp->num_script_if_fault)
 			return;
 	}
-	else if (--vrrp->num_script_if_fault || vrrp->num_script_init)
+	else if (--vrrp->num_script_if_fault || vrrp->num_script_init) {
+		if (!vrrp->num_script_if_fault) {
+			if (vrrp->sync) {
+				vrrp->sync->num_member_fault--;
+				vrrp->sync->state = VRRP_STATE_INIT;
+			}
+			vrrp->wantstate = VRRP_STATE_BACK;
+		}
+
 		return;
+	}
 
 	if (vrrp->wantstate == VRRP_STATE_MAST && vrrp->base_priority == VRRP_PRIO_OWNER) {
 		vrrp->wantstate = VRRP_STATE_MAST;
-- 
1.8.3.1

