diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-06-13 16:58:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-13 16:58:08 +0200 |
commit | 64d67529c341832ed8683406760311aa76c480b3 (patch) | |
tree | 3c6129f98bc5d1d8c13e79d021c3c2ee2eab7854 | |
parent | 9cfa2ec772b60b6512815422e3e08cd331f2da33 (diff) | |
parent | aec27085df23bee339bf7ada68283b406a04c3be (diff) | |
download | vyos-1x-64d67529c341832ed8683406760311aa76c480b3.tar.gz vyos-1x-64d67529c341832ed8683406760311aa76c480b3.zip |
Merge pull request #3643 from HollyGurza/T5725-equuleus
T5725: Improve protocol IS-IS config validation
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_isis.py | 35 | ||||
-rwxr-xr-x | src/conf_mode/protocols_isis.py | 13 |
2 files changed, 48 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_protocols_isis.py b/smoketest/scripts/cli/test_protocols_isis.py index 167cd05f8..316443193 100755 --- a/smoketest/scripts/cli/test_protocols_isis.py +++ b/smoketest/scripts/cli/test_protocols_isis.py @@ -37,6 +37,8 @@ class TestProtocolsISIS(VyOSUnitTestSHIM.TestCase): def tearDown(self): self.cli_delete(base_path) + self.cli_delete(['interfaces', 'dummy']) + self.cli_delete(['interfaces', 'tunnel']) self.cli_commit() # Check for running process @@ -222,5 +224,38 @@ class TestProtocolsISIS(VyOSUnitTestSHIM.TestCase): self.assertIn(f' ipv6 router isis {domain}', tmp) self.assertIn(f' isis network {network}', tmp) + def test_isis_06_tunnel_interface(self): + self.cli_set(['interfaces', 'dummy', 'dum0', 'address', '203.0.113.254/32']) + self.cli_set(['interfaces', 'dummy', 'dum0', 'description', 'dum0']) + self.cli_set(['interfaces', 'dummy', 'dum1', 'address', '192.0.2.5/24']) + self.cli_set(['interfaces', 'dummy', 'dum1', 'description', 'LAN']) + + self.cli_set(['interfaces', 'tunnel', 'tun0', 'address', '10.0.0.2/30']) + self.cli_set(['interfaces', 'tunnel', 'tun0', 'description', 'tun-to-192.0.2.1']) + self.cli_set(['interfaces', 'tunnel', 'tun0', 'encapsulation', 'gre']) + self.cli_set(['interfaces', 'tunnel', 'tun0', 'source-address', '192.0.2.5']) + + self.cli_set(base_path + ['interface', 'dum1']) + self.cli_set(base_path + ['interface', 'tun0']) + self.cli_set(base_path + ['lsp-mtu', '1460']) + self.cli_set(base_path + ['net', '49.0001.1920.0200.0011.00']) + self.cli_set(base_path + ['redistribute', 'ipv4', 'connected', 'level-2']) + + with self.assertRaises(ConfigSessionError): + self.cli_commit() + + self.cli_set(['interfaces', 'tunnel', 'tun0', 'remote', '192.0.2.1']) + self.cli_commit() + + frr_config = self.getFRRconfig(f'router isis {domain}', daemon='isisd') + expected_config = "router isis VyOS\n"\ + " net 49.0001.1920.0200.0011.00\n"\ + " lsp-mtu 1460\n"\ + " redistribute ipv4 connected level-2\n"\ + "!" + + self.assertEqual(expected_config, frr_config) + + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/src/conf_mode/protocols_isis.py b/src/conf_mode/protocols_isis.py index 0c179b724..f3098ff71 100755 --- a/src/conf_mode/protocols_isis.py +++ b/src/conf_mode/protocols_isis.py @@ -69,6 +69,15 @@ def get_config(config=None): # Merge policy dict into "regular" config dict isis = dict_merge(tmp, isis) + for interface in isis.get('interface'): + # when we use tunnel interface necessary additional config validate + if interface.startswith('tun'): + isis['tunnel_config'] = conf.get_config_dict( + ['interfaces', 'tunnel'], + key_mangling=('-', '_'), + get_first_key=True) + break + return isis def verify(isis): @@ -103,6 +112,10 @@ def verify(isis): f'Recommended area lsp-mtu {recom_area_mtu} or less ' \ '(calculated on MTU size).') + if interface.startswith('tun'): + if not dict_search(f'tunnel_config.{interface}.remote', isis): + raise ConfigError(f'Option remote for interface {interface} is required.') + # If md5 and plaintext-password set at the same time for password in ['area_password', 'domain_password']: if password in isis: |