summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Fort <nicolasfort1988@gmail.com>2024-01-09 09:52:07 +0000
committerNicolas Fort <nicolasfort1988@gmail.com>2024-01-09 09:52:07 +0000
commit56141ca2165f58dcfd7ef47afcdb1b227827d416 (patch)
tree9db35fffafdcc737609141aed547f2dfe20b31da
parentd6b2144b3c017d9fd5b3bf8e69c17de7b80f0fa6 (diff)
downloadvyos-1x-56141ca2165f58dcfd7ef47afcdb1b227827d416.tar.gz
vyos-1x-56141ca2165f58dcfd7ef47afcdb1b227827d416.zip
T1297: vrrp: backport VRRP GARP options to Equuleus
-rw-r--r--data/templates/vrrp/keepalived.conf.tmpl38
-rw-r--r--interface-definitions/include/vrrp/garp.xml.i74
-rw-r--r--interface-definitions/vrrp.xml.in2
-rwxr-xr-xsmoketest/scripts/cli/test_ha_vrrp.py28
-rwxr-xr-xsrc/conf_mode/vrrp.py2
5 files changed, 144 insertions, 0 deletions
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 @@
+<!-- include start from vrrp/garp.xml.i -->
+<node name="garp">
+ <properties>
+ <help>Gratuitous ARP parameters</help>
+ </properties>
+ <children>
+ <leafNode name="master-delay">
+ <properties>
+ <help>Delay for second set of gratuitous ARPs after transition to MASTER</help>
+ <valueHelp>
+ <format>u32:1-1000</format>
+ <description>Delay for second set of gratuitous ARPs after transition to MASTER</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 1-1000"/>
+ </constraint>
+ </properties>
+ <defaultValue>5</defaultValue>
+ </leafNode>
+ <leafNode name="master-repeat">
+ <properties>
+ <help>Number of gratuitous ARP messages to send at a time after transition to MASTER</help>
+ <valueHelp>
+ <format>u32:1-255</format>
+ <description>Number of gratuitous ARP messages to send at a time after transition to MASTER</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 1-255"/>
+ </constraint>
+ </properties>
+ <defaultValue>5</defaultValue>
+ </leafNode>
+ <leafNode name="master-refresh">
+ <properties>
+ <help>Minimum time interval for refreshing gratuitous ARPs while MASTER. 0 means no refresh</help>
+ <valueHelp>
+ <format>u32:1-255</format>
+ <description>Minimum time interval for refreshing gratuitous ARPs while MASTER. 0 means no refresh</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 1-255"/>
+ </constraint>
+ </properties>
+ <defaultValue>5</defaultValue>
+ </leafNode>
+ <leafNode name="master-refresh-repeat">
+ <properties>
+ <help>Number of gratuitous ARP messages to send at a time while MASTER</help>
+ <valueHelp>
+ <format>u32:1-255</format>
+ <description>Number of gratuitous ARP messages to send at a time while MASTER</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 1-255"/>
+ </constraint>
+ </properties>
+ <defaultValue>1</defaultValue>
+ </leafNode>
+ <leafNode name="interval">
+ <properties>
+ <help>Delay between gratuitous ARP messages sent on an interface</help>
+ <valueHelp>
+ <format>&lt;0.000-1000&gt;</format>
+ <description>Delay between gratuitous ARP messages sent on an interface</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 0.000-1000 --float"/>
+ </constraint>
+ </properties>
+ <defaultValue>0</defaultValue>
+ </leafNode>
+ </children>
+</node>
+<!-- include end --> \ 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 @@
<help>VRRP global parameters</help>
</properties>
<children>
+ #include <include/vrrp/garp.xml.i>
<leafNode name="startup-delay">
<properties>
<help>Time VRRP startup process (in seconds)</help>
@@ -51,6 +52,7 @@
<help>VRRP group</help>
</properties>
<children>
+ #include <include/vrrp/garp.xml.i>
<leafNode name="interface">
<properties>
<help>Network interface</help>
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])