Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T5725: Improve protocol IS-IS config validation #3643

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions smoketest/scripts/cli/test_protocols_isis.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def setUpClass(cls):

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
Expand Down Expand Up @@ -222,5 +224,38 @@ def test_isis_06_spf_delay(self):
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)
13 changes: 13 additions & 0 deletions src/conf_mode/protocols_isis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down