Skip to content

Commit

Permalink
T5725: Improve protocol IS-IS config validation
Browse files Browse the repository at this point in the history
  • Loading branch information
HollyGurza committed Jun 12, 2024
1 parent 9cfa2ec commit d0f49ba
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
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 'tun' in interface:
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 'tun' in interface:
if not isis.get('tunnel_config').get(interface).get('remote'):
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

0 comments on commit d0f49ba

Please sign in to comment.