keepalived: add new uci section config interface_up_down_delays

If an interface that is being used (or tracked) by a VRRP instance goes to
down state, the VRRP instance(s) will, by default, immediately transition to
FAULT state, and when all relevant interfaces are back up again the VRRP
instance(s) will immediately transition to BACKUP state.

This can cause problems if interfaces are bouncing, and so delays can be
specified between the interface state change and the transition to
FAULT/BACKUP state. If the interface returns to its original state before
the delay expires, no associated VRRP instance state transition will occur.

New uci section 'interface_up_down_delay':

config interface_up_down_delays
	option device <device>
	option down_delay <number in seconds>
	option up_delay <number in seconds>

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2025-02-04 13:01:53 +01:00 committed by Florian Eckert
parent f02a1df129
commit ae038d0773
1 changed files with 23 additions and 0 deletions

View File

@ -287,6 +287,25 @@ static_routes() {
done
}
interface_up_down_delays() {
local device
local down_delay
local up_delay
local line
config_get device "$1" device
config_get down_delay "$1" down_delay
config_get up_delay "$1" up_delay
[ -z "$device" ] && return
[ -z "$down_delay" ] && return
line="${device} ${down_delay}"
[ -z "$up_delay" ] || line="${line} ${up_delay}"
printf '%b%s\n' "$INDENT_1" "$line" >> "$KEEPALIVED_CONF"
}
# Count 'vrrp_instance' with the given name ; called by vrrp_instance_check()
vrrp_instance_name_count() {
local name
@ -613,6 +632,10 @@ process_config() {
config_foreach_wrapper static_routes
config_section_close
config_section_open "interface_up_down_delays"
config_foreach_wrapper interface_up_down_delays
config_section_close
config_foreach_wrapper vrrp_script
config_foreach_wrapper bfd_instance
config_foreach_wrapper vrrp_sync_group