From ab9fccdc3a460d731d1a56b576bef537331d8f9b Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sat, 28 Jan 2023 20:51:44 +0100 Subject: vrrp: T1297: improve gratuitous ARP default value handling and help strings --- .../templates/high-availability/keepalived.conf.j2 | 1 + interface-definitions/include/vrrp/garp.xml.i | 46 ++++++++++++---------- src/conf_mode/high-availability.py | 24 +++++++++-- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/data/templates/high-availability/keepalived.conf.j2 b/data/templates/high-availability/keepalived.conf.j2 index 23abb66dc..6ea5f91d0 100644 --- a/data/templates/high-availability/keepalived.conf.j2 +++ b/data/templates/high-availability/keepalived.conf.j2 @@ -2,6 +2,7 @@ # Do not edit this file, all your changes will be lost # on next commit or reboot +# Global definitions configuration block global_defs { dynamic_interfaces script_user root diff --git a/interface-definitions/include/vrrp/garp.xml.i b/interface-definitions/include/vrrp/garp.xml.i index b321c9591..b56b490df 100644 --- a/interface-definitions/include/vrrp/garp.xml.i +++ b/interface-definitions/include/vrrp/garp.xml.i @@ -4,38 +4,42 @@ Gratuitous ARP parameters - + - Delay for second set of gratuitous ARPs after transition to MASTER + Interval between Gratuitous ARP - u32:1-1000 - Delay for second set of gratuitous ARPs after transition to MASTER + <0.000-1000> + Interval in seconds, resolution microseconds - + - 5 + 0 - + - Number of gratuitous ARP messages to send at a time after transition to MASTER + Delay for second set of gratuitous ARPs after transition to master - u32:1-255 - Number of gratuitous ARP messages to send at a time after transition to MASTER + u32:1-1000 + Delay in seconds - + 5 - Minimum time interval for refreshing gratuitous ARPs while MASTER. 0 means no refresh + Minimum time interval for refreshing gratuitous ARPs while beeing master + + u32:0 + No refresh + u32:1-255 - Minimum time interval for refreshing gratuitous ARPs while MASTER. 0 means no refresh + Interval in seconds @@ -45,10 +49,10 @@ - Number of gratuitous ARP messages to send at a time while MASTER + Number of gratuitous ARP messages to send at a time while beeing master u32:1-255 - Number of gratuitous ARP messages to send at a time while MASTER + Number of gratuitous ARP messages @@ -56,18 +60,18 @@ 1 - + - Delay between gratuitous ARP messages sent on an interface + Number of gratuitous ARP messages to send at a time after transition to master - <0.000-1000> - Delay between gratuitous ARP messages sent on an interface + u32:1-255 + Number of gratuitous ARP messages - + - 0 + 5 diff --git a/src/conf_mode/high-availability.py b/src/conf_mode/high-availability.py index bc3e67b40..79e407efd 100755 --- a/src/conf_mode/high-availability.py +++ b/src/conf_mode/high-availability.py @@ -28,6 +28,7 @@ from vyos.template import render from vyos.template import is_ipv4 from vyos.template import is_ipv6 from vyos.util import call +from vyos.util import dict_search from vyos.xml import defaults from vyos import ConfigError from vyos import airbag @@ -49,12 +50,27 @@ def get_config(config=None): # We have gathered the dict representation of the CLI, but there are default # options which we need to update into the dictionary retrived. if 'vrrp' in ha: + if dict_search('vrrp.global_parameters.garp', ha) != None: + default_values = defaults(base_vrrp + ['global-parameters', 'garp']) + ha['vrrp']['global_parameters']['garp'] = dict_merge( + default_values, ha['vrrp']['global_parameters']['garp']) + if 'group' in ha['vrrp']: - default_values_vrrp = defaults(base_vrrp + ['group']) - if 'garp' in default_values_vrrp: - del default_values_vrrp['garp'] + default_values = defaults(base_vrrp + ['group']) + default_values_garp = defaults(base_vrrp + ['group', 'garp']) + + # XXX: T2665: we can not safely rely on the defaults() when there are + # tagNodes in place, it is better to blend in the defaults manually. + if 'garp' in default_values: + del default_values['garp'] for group in ha['vrrp']['group']: - ha['vrrp']['group'][group] = dict_merge(default_values_vrrp, ha['vrrp']['group'][group]) + ha['vrrp']['group'][group] = dict_merge(default_values, ha['vrrp']['group'][group]) + + # XXX: T2665: we can not safely rely on the defaults() when there are + # tagNodes in place, it is better to blend in the defaults manually. + if 'garp' in ha['vrrp']['group'][group]: + ha['vrrp']['group'][group]['garp'] = dict_merge( + default_values_garp, ha['vrrp']['group'][group]['garp']) # Merge per virtual-server default values if 'virtual_server' in ha: -- cgit v1.2.3