diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-12-25 12:19:33 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-12-25 12:19:33 +0100 |
commit | 4abca54698edb09b76e7d059dd35cdcef3512ec4 (patch) | |
tree | b7ed643cf492423078a69b065dcfc583e1390f4c | |
parent | 8449ee5f95ffbf1901202e04ee6e1216f54d8ff8 (diff) | |
download | vyos-1x-4abca54698edb09b76e7d059dd35cdcef3512ec4.tar.gz vyos-1x-4abca54698edb09b76e7d059dd35cdcef3512ec4.zip |
ospfv3: T4102: add support for NSSA area-type
-rw-r--r-- | data/templates/frr/ospf6d.frr.tmpl | 2 | ||||
-rw-r--r-- | interface-definitions/include/ospfv3/no-summary.xml.i | 6 | ||||
-rw-r--r-- | interface-definitions/include/ospfv3/protocol-common-config.xml.i | 17 | ||||
-rw-r--r-- | op-mode-definitions/show-ipv6-ospfv3.xml.in | 24 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_ospfv3.py | 41 | ||||
-rwxr-xr-x | src/conf_mode/protocols_ospfv3.py | 10 |
6 files changed, 91 insertions, 9 deletions
diff --git a/data/templates/frr/ospf6d.frr.tmpl b/data/templates/frr/ospf6d.frr.tmpl index c366326bf..3576c4b22 100644 --- a/data/templates/frr/ospf6d.frr.tmpl +++ b/data/templates/frr/ospf6d.frr.tmpl @@ -54,7 +54,7 @@ router ospf6 {{ 'vrf ' + vrf if vrf is defined and vrf is not none }} {% for area_id, area_config in area.items() %} {% if area_config.area_type is defined and area_config.area_type is not none %} {% for type, type_config in area_config.area_type.items() %} - area {{ area_id }} {{ type }} {{ 'no-summary' if type_config.no_summary is defined }} + area {{ area_id }} {{ type }} {{ 'no-summary' if type_config.no_summary is defined }} {{ 'default-information-originate' if type_config.default_information_originate is defined }} {% endfor %} {% endif %} {% if area_config.range is defined and area_config.range is not none %} diff --git a/interface-definitions/include/ospfv3/no-summary.xml.i b/interface-definitions/include/ospfv3/no-summary.xml.i new file mode 100644 index 000000000..df9a456ba --- /dev/null +++ b/interface-definitions/include/ospfv3/no-summary.xml.i @@ -0,0 +1,6 @@ + <leafNode name="no-summary"> + <properties> + <help>Do not inject inter-area routes into the stub</help> + <valueless/> + </properties> + </leafNode> diff --git a/interface-definitions/include/ospfv3/protocol-common-config.xml.i b/interface-definitions/include/ospfv3/protocol-common-config.xml.i index a93939a34..00a6dcca7 100644 --- a/interface-definitions/include/ospfv3/protocol-common-config.xml.i +++ b/interface-definitions/include/ospfv3/protocol-common-config.xml.i @@ -21,17 +21,26 @@ <help>OSPFv3 Area type</help> </properties> <children> - <node name="stub"> + <node name="nssa"> <properties> - <help>Stub OSPFv3 area</help> + <help>NSSA OSPFv3 area</help> </properties> <children> - <leafNode name="no-summary"> + <leafNode name="default-information-originate"> <properties> - <help>Do not inject inter-area routes into the stub</help> + <help>Originate Type 7 default into NSSA area</help> <valueless/> </properties> </leafNode> + #include <include/ospfv3/no-summary.xml.i> + </children> + </node> + <node name="stub"> + <properties> + <help>Stub OSPFv3 area</help> + </properties> + <children> + #include <include/ospfv3/no-summary.xml.i> </children> </node> </children> diff --git a/op-mode-definitions/show-ipv6-ospfv3.xml.in b/op-mode-definitions/show-ipv6-ospfv3.xml.in index 82d6b5f4c..a63465472 100644 --- a/op-mode-definitions/show-ipv6-ospfv3.xml.in +++ b/op-mode-definitions/show-ipv6-ospfv3.xml.in @@ -26,7 +26,7 @@ <path>protocols ospfv3 area</path> </completionHelp> </properties> - <command>vtysh -c "show ipv6 ospf6 spf tree"</command> + <command>vtysh -c "show ipv6 ospf6 area $5 spf tree"</command> <children> <tagNode name="router"> <properties> @@ -35,7 +35,7 @@ <list><x.x.x.x></list> </completionHelp> </properties> - <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ spf tree</command> + <command>vtysh -c "show ipv6 ospf6 simulate spf-tree $7 $4 $5"</command> </tagNode> </children> </tagNode> @@ -72,6 +72,26 @@ </properties> <command>vtysh -c "show ipv6 ospf6 vrf $5 spf tree"</command> </node> + <tagNode name="area"> + <properties> + <help>Area ID (as an IPv4 notation)</help> + <completionHelp> + <path>protocols ospfv3 area</path> + </completionHelp> + </properties> + <command>vtysh -c "show ipv6 ospf6 vrf $5 area $7 spf tree"</command> + <children> + <tagNode name="router"> + <properties> + <help> Simulate view point (Router ID)</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>vtysh -c "show ipv6 ospf6 vrf $5 simulate spf-tree $9 $6 $7"</command> + </tagNode> + </children> + </tagNode> #include <include/ospfv3/border-routers.xml.i> #include <include/ospfv3/database.xml.i> #include <include/ospfv3/interface.xml.i> diff --git a/smoketest/scripts/cli/test_protocols_ospfv3.py b/smoketest/scripts/cli/test_protocols_ospfv3.py index 40dd254a8..1cc3a8aa4 100755 --- a/smoketest/scripts/cli/test_protocols_ospfv3.py +++ b/smoketest/scripts/cli/test_protocols_ospfv3.py @@ -18,6 +18,7 @@ import unittest from base_vyostest_shim import VyOSUnitTestSHIM +from vyos.configsession import ConfigSessionError from vyos.ifconfig import Section from vyos.util import process_named_running @@ -28,6 +29,9 @@ router_id = '192.0.2.1' default_area = '0' class TestProtocolsOSPFv3(VyOSUnitTestSHIM.TestCase): + def setUp(self): + self.debug = True + def tearDown(self): # Check for running process self.assertTrue(process_named_running(PROCESS_NAME)) @@ -109,6 +113,7 @@ class TestProtocolsOSPFv3(VyOSUnitTestSHIM.TestCase): for protocol in redistribute: self.assertIn(f' redistribute {protocol} route-map {route_map}', frrconfig) + def test_ospfv3_04_interfaces(self): bfd_profile = 'vyos-ipv6' @@ -170,7 +175,39 @@ class TestProtocolsOSPFv3(VyOSUnitTestSHIM.TestCase): self.assertIn(f' area {area_stub_nosum} stub no-summary', frrconfig) - def test_ospfv3_06_vrfs(self): + def test_ospfv3_05_area_nssa(self): + area_nssa = '1.1.1.1' + area_nssa_nosum = '2.2.2.2' + area_nssa_default = '3.3.3.3' + + self.cli_set(base_path + ['area', area_nssa, 'area-type', 'nssa']) + self.cli_set(base_path + ['area', area_nssa, 'area-type', 'stub']) + # can only set one area-type per OSPFv3 area + with self.assertRaises(ConfigSessionError): + self.cli_commit() + self.cli_delete(base_path + ['area', area_nssa, 'area-type', 'stub']) + + self.cli_set(base_path + ['area', area_nssa_nosum, 'area-type', 'nssa', 'no-summary']) + self.cli_set(base_path + ['area', area_nssa_nosum, 'area-type', 'nssa', 'default-information-originate']) + + # can not set both no-summary and default-information-originate at the same time + with self.assertRaises(ConfigSessionError): + self.cli_commit() + self.cli_delete(base_path + ['area', area_nssa_nosum, 'area-type', 'nssa', 'default-information-originate']) + + self.cli_set(base_path + ['area', area_nssa_default, 'area-type', 'nssa', 'default-information-originate']) + + # commit changes + self.cli_commit() + + # Verify FRR ospfd configuration + frrconfig = self.getFRRconfig('router ospf6') + self.assertIn(f'router ospf6', frrconfig) + self.assertIn(f' area {area_nssa} nssa', frrconfig) + self.assertIn(f' area {area_nssa_nosum} nssa no-summary', frrconfig) + self.assertIn(f' area {area_nssa_default} nssa default-information-originate', frrconfig) + + def test_ospfv3_07_vrfs(self): # It is safe to assume that when the basic VRF test works, all # other OSPF related features work, as we entirely inherit the CLI # templates and Jinja2 FRR template. @@ -209,4 +246,4 @@ class TestProtocolsOSPFv3(VyOSUnitTestSHIM.TestCase): self.cli_delete(['interfaces', 'ethernet', vrf_iface, 'vrf']) if __name__ == '__main__': - unittest.main(verbosity=2) + unittest.main(verbosity=2, failfast=True) diff --git a/src/conf_mode/protocols_ospfv3.py b/src/conf_mode/protocols_ospfv3.py index d0460b830..c338c98b3 100755 --- a/src/conf_mode/protocols_ospfv3.py +++ b/src/conf_mode/protocols_ospfv3.py @@ -83,6 +83,16 @@ def verify(ospfv3): verify_common_route_maps(ospfv3) + if 'area' in ospfv3: + for area, area_config in ospfv3['area'].items(): + if 'area_type' in area_config: + if len(area_config['area_type']) > 1: + raise ConfigError(f'Can only configure one area-type for OSPFv3 area "{area}"!') + for area_type, area_type_config in area_config['area_type'].items(): + if {'default_information_originate', 'no_summary'} <= set(area_type_config): + raise ConfigError(f'Can either set "default-information-originate" '\ + f'or "no-summary", but not both!') + if 'interface' in ospfv3: for interface, interface_config in ospfv3['interface'].items(): if 'ifmtu' in interface_config: |