Skip to content

Commit

Permalink
Merge pull request #3186 from vyos/mergify/bp/sagitta/pr-3185
Browse files Browse the repository at this point in the history
ospf: T6066: can not define the same network in different areas (backport #3185)
  • Loading branch information
c-po committed Mar 24, 2024
2 parents 5f02e43 + 8fa9c92 commit 52f8872
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions smoketest/scripts/cli/test_protocols_ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,5 +540,25 @@ def test_ospf_16_graceful_restart(self):
for router_id in router_ids:
self.assertIn(f' graceful-restart helper enable {router_id}', frrconfig)

def test_ospf_17_duplicate_area_network(self):
area0 = '0'
area1 = '1'
network = '10.0.0.0/8'

self.cli_set(base_path + ['area', area0, 'network', network])

# we can not have the same network defined on two areas
self.cli_set(base_path + ['area', area1, 'network', network])
with self.assertRaises(ConfigSessionError):
self.cli_commit()
self.cli_delete(base_path + ['area', area0])

self.cli_commit()

# Verify FRR ospfd configuration
frrconfig = self.getFRRconfig('router ospf', daemon=PROCESS_NAME)
self.assertIn(f'router ospf', frrconfig)
self.assertIn(f' network {network} area {area1}', frrconfig)

if __name__ == '__main__':
unittest.main(verbosity=2)
7 changes: 7 additions & 0 deletions src/conf_mode/protocols_ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def verify(ospf):

# Validate if configured Access-list exists
if 'area' in ospf:
networks = []
for area, area_config in ospf['area'].items():
if 'import_list' in area_config:
acl_import = area_config['import_list']
Expand All @@ -137,6 +138,12 @@ def verify(ospf):
acl_export = area_config['export_list']
if acl_export: verify_access_list(acl_export, ospf)

if 'network' in area_config:
for network in area_config['network']:
if network in networks:
raise ConfigError(f'Network "{network}" already defined in different area!')
networks.append(network)

if 'interface' in ospf:
for interface, interface_config in ospf['interface'].items():
verify_interface_exists(interface)
Expand Down

0 comments on commit 52f8872

Please sign in to comment.