diff options
-rw-r--r-- | data/templates/frr/pimd.frr.j2 | 17 | ||||
-rw-r--r-- | interface-definitions/include/pim/keep-alive-timer.xml.i | 1 | ||||
-rw-r--r-- | interface-definitions/include/policy/prefix-list.xml.i | 14 | ||||
-rw-r--r-- | interface-definitions/protocols-pim.xml.in | 78 | ||||
-rw-r--r-- | op-mode-definitions/show-ip-pim.xml.in | 2 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_pim.py | 54 | ||||
-rwxr-xr-x | src/conf_mode/protocols_pim.py | 4 |
7 files changed, 110 insertions, 60 deletions
diff --git a/data/templates/frr/pimd.frr.j2 b/data/templates/frr/pimd.frr.j2 index 97c5ff58b..b01fb5ec7 100644 --- a/data/templates/frr/pimd.frr.j2 +++ b/data/templates/frr/pimd.frr.j2 @@ -58,13 +58,13 @@ ip pim ecmp {{ 'rebalance' if ecmp.rebalance is vyos_defined }} ip pim join-prune-interval {{ join_prune_interval }} {% endif %} {% if keep_alive_timer is vyos_defined %} -ip pim rp keep-alive-timer {{ keep_alive_timer }} +ip pim keep-alive-timer {{ keep_alive_timer }} {% endif %} {% if packets is vyos_defined %} ip pim packets {{ packets }} {% endif %} -{% if register_accept_list is vyos_defined %} -ip pim register-accept-list {{ register_accept_list }} +{% if register_accept_list.prefix_list is vyos_defined %} +ip pim register-accept-list {{ register_accept_list.prefix_list }} {% endif %} {% if register_suppress_time is vyos_defined %} ip pim register-suppress-time {{ register_suppress_time }} @@ -76,14 +76,17 @@ ip pim rp {{ address }} {{ group }} {% endfor %} {% endfor %} {% endif %} -{% if send_v6_secondary is vyos_defined %} -ip pim send-v6-secondary +{% if rp.keep_alive_timer is vyos_defined %} +ip pim rp keep-alive-timer {{ rp.keep_alive_timer }} +{% endif %} +{% if no_v6_secondary is vyos_defined %} +no ip pim send-v6-secondary {% endif %} {% if spt_switchover.infinity_and_beyond is vyos_defined %} ip pim spt-switchover infinity-and-beyond {{ 'prefix-list ' ~ spt_switchover.infinity_and_beyond.prefix_list if spt_switchover.infinity_and_beyond.prefix_list is defined }} {% endif %} -{% if ssm is vyos_defined %} -ip pim ssm {{ ssm }} +{% if ssm.prefix_list is vyos_defined %} +ip pim ssm prefix-list {{ ssm.prefix_list }} {% endif %} ! {% if igmp.watermark_warning is vyos_defined %} diff --git a/interface-definitions/include/pim/keep-alive-timer.xml.i b/interface-definitions/include/pim/keep-alive-timer.xml.i index 9e71b7a14..0dd27d6e7 100644 --- a/interface-definitions/include/pim/keep-alive-timer.xml.i +++ b/interface-definitions/include/pim/keep-alive-timer.xml.i @@ -10,6 +10,5 @@ <validator name="numeric" argument="--range 1-65535"/> </constraint> </properties> - <defaultValue>210</defaultValue> </leafNode> <!-- include end --> diff --git a/interface-definitions/include/policy/prefix-list.xml.i b/interface-definitions/include/policy/prefix-list.xml.i new file mode 100644 index 000000000..5d7980ee2 --- /dev/null +++ b/interface-definitions/include/policy/prefix-list.xml.i @@ -0,0 +1,14 @@ +<!-- include start from policy/prefix-list.xml.i --> +<leafNode name="prefix-list"> + <properties> + <help>Prefix-list to use</help> + <valueHelp> + <format>txt</format> + <description>Prefix-list to apply (IPv4)</description> + </valueHelp> + <completionHelp> + <path>policy prefix-list</path> + </completionHelp> + </properties> +</leafNode> +<!-- include end --> diff --git a/interface-definitions/protocols-pim.xml.in b/interface-definitions/protocols-pim.xml.in index c1fa1b489..bbdb00cae 100644 --- a/interface-definitions/protocols-pim.xml.in +++ b/interface-definitions/protocols-pim.xml.in @@ -130,18 +130,14 @@ #include <include/pim/keep-alive-timer.xml.i> #include <include/pim/packets.xml.i> #include <include/pim/register-suppress-time.xml.i> - <leafNode name="register-accept-list"> + <node name="register-accept-list"> <properties> <help>Only accept registers from a specific source prefix list</help> - <valueHelp> - <format>txt</format> - <description>Prefix-list to apply</description> - </valueHelp> - <completionHelp> - <path>policy prefix-list</path> - </completionHelp> </properties> - </leafNode> + <children> + #include <include/policy/prefix-list.xml.i> + </children> + </node> <node name="rp"> <properties> <help>Rendezvous Point</help> @@ -174,50 +170,36 @@ </leafNode> </children> </tagNode> - <leafNode name="send-v6-secondary"> - <properties> - <help>Send v6 secondary addresses</help> - <valueless/> - </properties> - </leafNode> - <node name="spt-switchover"> + #include <include/pim/keep-alive-timer.xml.i> + </children> + </node> + <leafNode name="no-v6-secondary"> + <properties> + <help>Disable IPv6 secondary address in hello packets</help> + <valueless/> + </properties> + </leafNode> + <node name="spt-switchover"> + <properties> + <help>Send v6 secondary addresses</help> + </properties> + <children> + <node name="infinity-and-beyond"> <properties> - <help>Send v6 secondary addresses</help> + <help>Never switch to SPT Tree</help> </properties> <children> - <node name="infinity-and-beyond"> - <properties> - <help>Never switch to SPT Tree</help> - </properties> - <children> - <leafNode name="prefix-list"> - <properties> - <help>Prefix-List to control which groups to switch</help> - <valueHelp> - <format>txt</format> - <description>Prefix-list to apply</description> - </valueHelp> - <completionHelp> - <path>policy prefix-list</path> - </completionHelp> - </properties> - </leafNode> - </children> - </node> + #include <include/policy/prefix-list.xml.i> </children> </node> - <leafNode name="ssm"> - <properties> - <help>Source-Specific Multicast</help> - <completionHelp> - <path>policy prefix-list</path> - </completionHelp> - <valueHelp> - <format>txt</format> - <description>Prefix-list to apply</description> - </valueHelp> - </properties> - </leafNode> + </children> + </node> + <node name="ssm"> + <properties> + <help>Source-Specific Multicast</help> + </properties> + <children> + #include <include/policy/prefix-list.xml.i> </children> </node> </children> diff --git a/op-mode-definitions/show-ip-pim.xml.in b/op-mode-definitions/show-ip-pim.xml.in index 3e0bff064..9deba1f07 100644 --- a/op-mode-definitions/show-ip-pim.xml.in +++ b/op-mode-definitions/show-ip-pim.xml.in @@ -63,7 +63,7 @@ </properties> <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command> </leafNode> - <leafNode name="interfaces"> + <leafNode name="interface"> <properties> <help>PIM interfaces information</help> </properties> diff --git a/smoketest/scripts/cli/test_protocols_pim.py b/smoketest/scripts/cli/test_protocols_pim.py index ef134b195..ccfced138 100755 --- a/smoketest/scripts/cli/test_protocols_pim.py +++ b/smoketest/scripts/cli/test_protocols_pim.py @@ -73,7 +73,55 @@ class TestProtocolsPIM(VyOSUnitTestSHIM.TestCase): self.cli_commit() - def test_02_pim_igmp_proxy(self): + def test_02_pim_advanced(self): + rp = '127.0.0.2' + group = '224.0.0.0/4' + join_prune_interval = '123' + rp_keep_alive_timer = '190' + keep_alive_timer = '180' + packets = '10' + prefix_list = 'pim-test' + register_suppress_time = '300' + + self.cli_set(base_path + ['rp', 'address', rp, 'group', group]) + self.cli_set(base_path + ['rp', 'keep-alive-timer', rp_keep_alive_timer]) + + self.cli_set(base_path + ['ecmp', 'rebalance']) + self.cli_set(base_path + ['join-prune-interval', join_prune_interval]) + self.cli_set(base_path + ['keep-alive-timer', keep_alive_timer]) + self.cli_set(base_path + ['packets', packets]) + self.cli_set(base_path + ['register-accept-list', 'prefix-list', prefix_list]) + self.cli_set(base_path + ['register-suppress-time', register_suppress_time]) + self.cli_set(base_path + ['no-v6-secondary']) + self.cli_set(base_path + ['spt-switchover', 'infinity-and-beyond', 'prefix-list', prefix_list]) + self.cli_set(base_path + ['ssm', 'prefix-list', prefix_list]) + + # check validate() - PIM require defined interfaces! + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + interfaces = Section.interfaces('ethernet') + for interface in interfaces: + self.cli_set(base_path + ['interface', interface]) + + # commit changes + self.cli_commit() + + # Verify FRR pimd configuration + frrconfig = self.getFRRconfig(daemon=PROCESS_NAME) + self.assertIn(f'ip pim rp {rp} {group}', frrconfig) + self.assertIn(f'ip pim rp keep-alive-timer {rp_keep_alive_timer}', frrconfig) + self.assertIn(f'ip pim ecmp rebalance', frrconfig) + self.assertIn(f'ip pim join-prune-interval {join_prune_interval}', frrconfig) + self.assertIn(f'ip pim keep-alive-timer {keep_alive_timer}', frrconfig) + self.assertIn(f'ip pim packets {packets}', frrconfig) + self.assertIn(f'ip pim register-accept-list {prefix_list}', frrconfig) + self.assertIn(f'ip pim register-suppress-time {register_suppress_time}', frrconfig) + self.assertIn(f'no ip pim send-v6-secondary', frrconfig) + self.assertIn(f'ip pim spt-switchover infinity-and-beyond prefix-list {prefix_list}', frrconfig) + self.assertIn(f'ip pim ssm prefix-list {prefix_list}', frrconfig) + + def test_03_pim_igmp_proxy(self): igmp_proxy = ['protocols', 'igmp-proxy'] rp = '127.0.0.1' group = '224.0.0.0/4' @@ -95,7 +143,7 @@ class TestProtocolsPIM(VyOSUnitTestSHIM.TestCase): # commit changes self.cli_commit() - def test_03_igmp(self): + def test_04_igmp(self): watermark_warning = '2000' query_interval = '1000' query_max_response_time = '200' @@ -141,4 +189,4 @@ class TestProtocolsPIM(VyOSUnitTestSHIM.TestCase): self.assertIn(f' ip igmp join {join}', frrconfig) if __name__ == '__main__': - unittest.main(verbosity=2, failfast=True) + unittest.main(verbosity=2) diff --git a/src/conf_mode/protocols_pim.py b/src/conf_mode/protocols_pim.py index fbe95c404..5e6225f6f 100755 --- a/src/conf_mode/protocols_pim.py +++ b/src/conf_mode/protocols_pim.py @@ -25,6 +25,7 @@ from vyos.config import config_dict_merge from vyos.configdict import dict_merge from vyos.configdict import node_changed from vyos.utils.dict import dict_search +from vyos.configverify import verify_interface_exists from vyos.utils.process import process_named_running from vyos.utils.process import call from vyos.template import render_to_string @@ -93,6 +94,9 @@ def verify(pim): if 'interface' not in pim: raise ConfigError('PIM require defined interfaces!') + for interface in pim['interface']: + verify_interface_exists(interface) + if 'rp' in pim: if 'address' not in pim['rp']: raise ConfigError('PIM rendezvous point needs to be defined!') |