From 56141ca2165f58dcfd7ef47afcdb1b227827d416 Mon Sep 17 00:00:00 2001 From: Nicolas Fort Date: Tue, 9 Jan 2024 09:52:07 +0000 Subject: T1297: vrrp: backport VRRP GARP options to Equuleus --- data/templates/vrrp/keepalived.conf.tmpl | 38 ++++++++++++++ interface-definitions/include/vrrp/garp.xml.i | 74 +++++++++++++++++++++++++++ interface-definitions/vrrp.xml.in | 2 + smoketest/scripts/cli/test_ha_vrrp.py | 28 ++++++++++ src/conf_mode/vrrp.py | 2 + 5 files changed, 144 insertions(+) create mode 100644 interface-definitions/include/vrrp/garp.xml.i diff --git a/data/templates/vrrp/keepalived.conf.tmpl b/data/templates/vrrp/keepalived.conf.tmpl index 4bbd56584..4eba3fb16 100644 --- a/data/templates/vrrp/keepalived.conf.tmpl +++ b/data/templates/vrrp/keepalived.conf.tmpl @@ -12,6 +12,25 @@ global_defs { {% if global_parameters.version is defined %} vrrp_version {{ global_parameters.version }} {% endif %} + +{% if global_parameters.garp is defined %} +{% if global_parameters.garp.interval is defined %} + vrrp_garp_interval {{ global_parameters.garp.interval }} +{% endif %} +{% if global_parameters.garp.master_delay is defined %} + vrrp_garp_master_delay {{ global_parameters.garp.master_delay }} +{% endif %} +{% if global_parameters.garp.master_refresh is defined %} + vrrp_garp_master_refresh {{ global_parameters.garp.master_refresh }} +{% endif %} +{% if global_parameters.garp.master_refresh_repeat is defined %} + vrrp_garp_master_refresh_repeat {{ global_parameters.garp.master_refresh_repeat }} +{% endif %} +{% if global_parameters.garp.master_repeat is defined %} + vrrp_garp_master_repeat {{ global_parameters.garp.master_repeat }} +{% endif %} +{% endif %} + {% endif %} notify_fifo /run/keepalived/keepalived_notify_fifo notify_fifo_script /usr/libexec/vyos/system/keepalived-fifo.py @@ -36,6 +55,25 @@ vrrp_instance {{ name }} { virtual_router_id {{ group_config.vrid }} priority {{ group_config.priority }} advert_int {{ group_config.advertise_interval }} + +{% if group_config.garp is defined %} +{% if group_config.garp.interval is defined %} + garp_interval {{ group_config.garp.interval }} +{% endif %} +{% if group_config.garp.master_delay is defined %} + garp_master_delay {{ group_config.garp.master_delay }} +{% endif %} +{% if group_config.garp.master_repeat is defined %} + garp_master_repeat {{ group_config.garp.master_repeat }} +{% endif %} +{% if group_config.garp.master_refresh is defined %} + garp_master_refresh {{ group_config.garp.master_refresh }} +{% endif %} +{% if group_config.garp.master_refresh_repeat is defined %} + garp_master_refresh_repeat {{ group_config.garp.master_refresh_repeat }} +{% endif %} +{% endif %} + {% if group_config.track is defined and group_config.track.exclude_vrrp_interface is defined %} dont_track_primary {% endif %} diff --git a/interface-definitions/include/vrrp/garp.xml.i b/interface-definitions/include/vrrp/garp.xml.i new file mode 100644 index 000000000..847154444 --- /dev/null +++ b/interface-definitions/include/vrrp/garp.xml.i @@ -0,0 +1,74 @@ + + + + Gratuitous ARP parameters + + + + + Delay for second set of gratuitous ARPs after transition to MASTER + + u32:1-1000 + Delay for second set of gratuitous ARPs after transition to MASTER + + + + + + 5 + + + + Number of gratuitous ARP messages to send at a time after transition to MASTER + + u32:1-255 + Number of gratuitous ARP messages to send at a time after transition to MASTER + + + + + + 5 + + + + Minimum time interval for refreshing gratuitous ARPs while MASTER. 0 means no refresh + + u32:1-255 + Minimum time interval for refreshing gratuitous ARPs while MASTER. 0 means no refresh + + + + + + 5 + + + + Number of gratuitous ARP messages to send at a time while MASTER + + u32:1-255 + Number of gratuitous ARP messages to send at a time while MASTER + + + + + + 1 + + + + Delay between gratuitous ARP messages sent on an interface + + <0.000-1000> + Delay between gratuitous ARP messages sent on an interface + + + + + + 0 + + + + \ No newline at end of file diff --git a/interface-definitions/vrrp.xml.in b/interface-definitions/vrrp.xml.in index 2589d61d1..24e547c9f 100644 --- a/interface-definitions/vrrp.xml.in +++ b/interface-definitions/vrrp.xml.in @@ -16,6 +16,7 @@ VRRP global parameters + #include Time VRRP startup process (in seconds) @@ -51,6 +52,7 @@ VRRP group + #include Network interface diff --git a/smoketest/scripts/cli/test_ha_vrrp.py b/smoketest/scripts/cli/test_ha_vrrp.py index 7d8d7c643..8af1a314c 100755 --- a/smoketest/scripts/cli/test_ha_vrrp.py +++ b/smoketest/scripts/cli/test_ha_vrrp.py @@ -88,6 +88,14 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase): priority = '123' preempt_delay = '400' startup_delay = '120' + garp_master_delay = '2' + garp_master_repeat = '3' + garp_master_refresh = '4' + garp_master_refresh_repeat = '5' + garp_interval = '1.5' + group_garp_master_delay = '12' + group_garp_master_repeat = '13' + group_garp_master_refresh = '14' vrrp_version = '3' for group in groups: @@ -113,9 +121,19 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase): self.cli_set(group_base + ['authentication', 'type', 'plaintext-password']) self.cli_set(group_base + ['authentication', 'password', f'{group}']) + # GARP + self.cli_set(group_base + ['garp', 'master-delay', group_garp_master_delay]) + self.cli_set(group_base + ['garp', 'master-repeat', group_garp_master_repeat]) + self.cli_set(group_base + ['garp', 'master-refresh', group_garp_master_refresh]) + # Global parameters self.cli_set(global_param_base + ['startup-delay', f'{startup_delay}']) self.cli_set(global_param_base + ['version', vrrp_version]) + self.cli_set(global_param_base + ['garp', 'interval', f'{garp_interval}']) + self.cli_set(global_param_base + ['garp', 'master-delay', f'{garp_master_delay}']) + self.cli_set(global_param_base + ['garp', 'master-repeat', f'{garp_master_repeat}']) + self.cli_set(global_param_base + ['garp', 'master-refresh', f'{garp_master_refresh}']) + self.cli_set(global_param_base + ['garp', 'master-refresh-repeat', f'{garp_master_refresh_repeat}']) # commit changes self.cli_commit() @@ -124,6 +142,11 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase): config = getConfig(f'global_defs') self.assertIn(f'vrrp_startup_delay {startup_delay}', config) self.assertIn(f'vrrp_version {vrrp_version}', config) + self.assertIn(f'vrrp_garp_interval {garp_interval}', config) + self.assertIn(f'vrrp_garp_master_delay {garp_master_delay}', config) + self.assertIn(f'vrrp_garp_master_repeat {garp_master_repeat}', config) + self.assertIn(f'vrrp_garp_master_refresh {garp_master_refresh}', config) + self.assertIn(f'vrrp_garp_master_refresh_repeat {garp_master_refresh_repeat}', config) for group in groups: vlan_id = group.lstrip('VLAN') @@ -144,6 +167,11 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase): self.assertIn(f'auth_pass "{group}"', config) self.assertIn(f'auth_type PASS', config) + #GARP + self.assertIn(f'garp_master_delay {group_garp_master_delay}', config) + self.assertIn(f'garp_master_refresh {group_garp_master_refresh}', config) + self.assertIn(f'garp_master_repeat {group_garp_master_repeat}', config) + def test_03_sync_group(self): sync_group = 'VyOS' diff --git a/src/conf_mode/vrrp.py b/src/conf_mode/vrrp.py index b53294e64..6a14cd9b6 100755 --- a/src/conf_mode/vrrp.py +++ b/src/conf_mode/vrrp.py @@ -57,6 +57,8 @@ def get_config(config=None): # options which we need to update into the dictionary retrived. if 'group' in vrrp: default_values = defaults(base + ['group']) + if 'garp' in default_values: + del default_values['garp'] for group in vrrp['group']: vrrp['group'][group] = dict_merge(default_values, vrrp['group'][group]) -- cgit v1.2.3