From 94ab5fc768dea1b78e50bddb7c73e6ddb971b9c6 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Thu, 12 Nov 2026 17:41:31 +0100 Subject: ospf: T9606: move "parameters rfc1583-compatibility" to "compatible rfc1583" The RFC1583 option sat under "parameters" although FRR groups it with its other "compatible" commands. It now lives under "compatible rfc1583" for the default and VRF instances. Migration moves an existing setting and drops a "parameters" node left empty by the move. --- data/templates/frr/ospfd.frr.j2 | 2 +- .../include/ospf/protocol-common-config.xml.i | 19 +++++++--- .../include/version/ospf-version.xml.i | 2 +- smoketest/configs/assert/vrf-ospf | 2 + smoketest/configs/vrf-ospf | 2 + smoketest/scripts/cli/test_protocols_ospf.py | 14 +++---- src/migration-scripts/ospf/3-to-4 | 44 ++++++++++++++++++++++ 7 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 src/migration-scripts/ospf/3-to-4 diff --git a/data/templates/frr/ospfd.frr.j2 b/data/templates/frr/ospfd.frr.j2 index 77bd901b3..fcd969d28 100644 --- a/data/templates/frr/ospfd.frr.j2 +++ b/data/templates/frr/ospfd.frr.j2 @@ -211,7 +211,7 @@ router ospf {{ 'vrf ' ~ vrf if vrf is vyos_defined }} {% if parameters.abr_type is vyos_defined %} ospf abr-type {{ parameters.abr_type }} {% endif %} -{% if parameters.rfc1583_compatibility is vyos_defined %} +{% if compatible.rfc1583 is vyos_defined %} compatible rfc1583 {% endif %} {% if parameters.router_id is vyos_defined %} diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i index d11178135..175b6e2f1 100644 --- a/interface-definitions/include/ospf/protocol-common-config.xml.i +++ b/interface-definitions/include/ospf/protocol-common-config.xml.i @@ -334,6 +334,19 @@ + + + OSPF compatibility list + + + + + Enable RFC1583 criteria for handling AS external routes + + + + + #include @@ -635,12 +648,6 @@ cisco - - - Enable RFC1583 criteria for handling AS external routes - - - #include diff --git a/interface-definitions/include/version/ospf-version.xml.i b/interface-definitions/include/version/ospf-version.xml.i index 8ba074e81..3adb84b82 100644 --- a/interface-definitions/include/version/ospf-version.xml.i +++ b/interface-definitions/include/version/ospf-version.xml.i @@ -1,3 +1,3 @@ - + diff --git a/smoketest/configs/assert/vrf-ospf b/smoketest/configs/assert/vrf-ospf index d9c598654..52bc5f4e6 100644 --- a/smoketest/configs/assert/vrf-ospf +++ b/smoketest/configs/assert/vrf-ospf @@ -6,6 +6,7 @@ set interfaces ethernet eth2 offload gro set interfaces ethernet eth2 vrf 'blue' set protocols ospf area 0 network '192.0.2.0/24' set protocols ospf capability opaque +set protocols ospf compatible rfc1583 set protocols ospf interface eth0 authentication md5 key-id 10 md5-key 'ospfkey' set protocols ospf interface eth0 passive disable set protocols ospf log-adjacency-changes @@ -34,6 +35,7 @@ set system syslog local facility all level 'info' set system syslog local facility local7 level 'debug' set system time-zone 'Europe/Berlin' set vrf name blue protocols ospf area 0 network '172.18.201.0/24' +set vrf name blue protocols ospf compatible rfc1583 set vrf name blue protocols ospf interface eth2 authentication md5 key-id 30 md5-key 'vyoskey456' set vrf name blue protocols ospf interface eth2 dead-interval '40' set vrf name blue protocols ospf interface eth2 hello-interval '10' diff --git a/smoketest/configs/vrf-ospf b/smoketest/configs/vrf-ospf index 2363355c7..32844a8c3 100644 --- a/smoketest/configs/vrf-ospf +++ b/smoketest/configs/vrf-ospf @@ -28,6 +28,7 @@ protocols { parameters { abr-type cisco opaque-lsa + rfc1583-compatibility router-id 1.2.3.4 } passive-interface default @@ -97,6 +98,7 @@ vrf { } parameters { abr-type cisco + rfc1583-compatibility router-id 5.6.7.8 } passive-interface default diff --git a/smoketest/scripts/cli/test_protocols_ospf.py b/smoketest/scripts/cli/test_protocols_ospf.py index 28568ecbb..07e6b9c46 100755 --- a/smoketest/scripts/cli/test_protocols_ospf.py +++ b/smoketest/scripts/cli/test_protocols_ospf.py @@ -86,7 +86,7 @@ class TestProtocolsOSPF(VyOSUnitTestSHIM.TestCase): self.cli_set(base_path + ['parameters', 'router-id', router_id]) self.cli_set(base_path + ['parameters', 'abr-type', abr_type]) self.cli_set(base_path + ['capability', 'opaque']) - self.cli_set(base_path + ['parameters', 'rfc1583-compatibility']) + self.cli_set(base_path + ['compatible', 'rfc1583']) self.cli_set(base_path + ['log-adjacency-changes', 'detail']) self.cli_set(base_path + ['default-metric', metric]) self.cli_set(base_path + ['passive-interface', 'default']) @@ -742,17 +742,17 @@ class TestProtocolsOSPF(VyOSUnitTestSHIM.TestCase): self.assertIn(' ospf router-id 192.0.2.1', frrconfig) def test_ospf_22_rfc1583_canonical_form(self): - # FRR prints "compatible rfc1583". The CLI option "parameters - # rfc1583-compatibility" must be rendered in this form: if the alias - # form "ospf rfc1583compatibility" is rendered, frr-reload finds the - # line missing on every reload, removes the setting and adds it again, + # FRR prints "compatible rfc1583". The CLI option "compatible rfc1583" + # must be rendered in this form: if the alias form + # "ospf rfc1583compatibility" is rendered, frr-reload finds the line + # missing on every reload, removes the setting and adds it again, # which runs an extra SPF on each FRR reload, whatever it changed. # # This reads the generated FRR config file: FRR accepts both forms, so # vtysh cannot tell which one we rendered. frr_conf = '/run/frr/config/vyos.frr.conf' alias_form = r'(?m)^ ospf rfc1583compatibility' - rfc1583 = base_path + ['parameters', 'rfc1583-compatibility'] + rfc1583 = base_path + ['compatible', 'rfc1583'] # the router-id keeps "router ospf" configured when the node is # deleted below, so the delete is tested against a running instance @@ -780,7 +780,7 @@ class TestProtocolsOSPF(VyOSUnitTestSHIM.TestCase): self.cli_set(vrf_base + ['table', '1000']) vrf_params = vrf_base + ['protocols', 'ospf', 'parameters'] self.cli_set(vrf_params + ['router-id', '1.1.1.1']) - self.cli_set(vrf_params + ['rfc1583-compatibility']) + self.cli_set(vrf_base + ['protocols', 'ospf', 'compatible', 'rfc1583']) self.cli_commit() frrconfig = read_file(frr_conf) diff --git a/src/migration-scripts/ospf/3-to-4 b/src/migration-scripts/ospf/3-to-4 new file mode 100644 index 000000000..842e66896 --- /dev/null +++ b/src/migration-scripts/ospf/3-to-4 @@ -0,0 +1,44 @@ +# Copyright (C) VyOS Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library. If not, see . + +# T9606: "parameters rfc1583-compatibility" moves to "compatible rfc1583", +# matching FRR's "compatible" command family. + +from vyos.configtree import ConfigTree + + +def compatible_migration(config: ConfigTree, ospf_base: list) -> None: + if not config.exists(ospf_base): + return + + parameters = ospf_base + ['parameters'] + if config.exists(parameters + ['rfc1583-compatibility']): + config.delete(parameters + ['rfc1583-compatibility']) + + # do not leave an empty "parameters" node behind + if config.list_nodes(parameters) == []: + config.delete(parameters) + + config.set(ospf_base + ['compatible', 'rfc1583']) + + +def migrate(config: ConfigTree) -> None: + # OSPF in the default VRF + compatible_migration(config, ['protocols', 'ospf']) + + # OSPF in every VRF + if config.exists(['vrf', 'name']): + for name in config.list_nodes(['vrf', 'name']): + compatible_migration(config, ['vrf', 'name', name, 'protocols', 'ospf']) -- cgit v1.2.3 From bffa7c48f7e8724c1fba21cbb32a7b8ab0d40def Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Thu, 12 Nov 2026 17:41:36 +0100 Subject: ospf: T9606: add "compatible rfc7474" to control strict sequence number validation FRR now makes strict RFC7474 sequence number validation for OSPF cryptographic authentication optional. It is on by default and only the "no compatible rfc7474" form is shown. The new CLI node "compatible rfc7474" enables strict validation. When it is not set, "no compatible rfc7474" is rendered. Migration does not set it, so the previous behaviour of non-strict sequence number validation is kept on upgraded routers. Users must explicitly enable strict validation. --- data/templates/frr/ospfd.frr.j2 | 4 ++ .../include/ospf/protocol-common-config.xml.i | 6 +++ smoketest/scripts/cli/test_protocols_ospf.py | 48 ++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/data/templates/frr/ospfd.frr.j2 b/data/templates/frr/ospfd.frr.j2 index fcd969d28..2d62e205c 100644 --- a/data/templates/frr/ospfd.frr.j2 +++ b/data/templates/frr/ospfd.frr.j2 @@ -214,6 +214,10 @@ router ospf {{ 'vrf ' ~ vrf if vrf is vyos_defined }} {% if compatible.rfc1583 is vyos_defined %} compatible rfc1583 {% endif %} +{# FRR enables RFC7474 by default and only prints the "no" form #} +{% if compatible.rfc7474 is not vyos_defined %} + no compatible rfc7474 +{% endif %} {% if parameters.router_id is vyos_defined %} ospf router-id {{ parameters.router_id }} {% endif %} diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i index 175b6e2f1..ec06c3827 100644 --- a/interface-definitions/include/ospf/protocol-common-config.xml.i +++ b/interface-definitions/include/ospf/protocol-common-config.xml.i @@ -345,6 +345,12 @@ + + + Enable strict RFC7474 sequence number validation for cryptographic authentication + + + #include diff --git a/smoketest/scripts/cli/test_protocols_ospf.py b/smoketest/scripts/cli/test_protocols_ospf.py index 07e6b9c46..5ea9c8fae 100755 --- a/smoketest/scripts/cli/test_protocols_ospf.py +++ b/smoketest/scripts/cli/test_protocols_ospf.py @@ -75,6 +75,7 @@ class TestProtocolsOSPF(VyOSUnitTestSHIM.TestCase): self.assertIn(f'router ospf', frrconfig) self.assertIn(f' auto-cost reference-bandwidth 100', frrconfig) self.assertIn(f' timers throttle spf 200 1000 10000', frrconfig) # defaults + self.assertIn(f' no compatible rfc7474', frrconfig) def test_ospf_02_simple(self): router_id = '127.0.0.1' @@ -816,5 +817,52 @@ class TestProtocolsOSPF(VyOSUnitTestSHIM.TestCase): self.cli_delete(vrf_base) + def test_ospf_24_compatible(self): + # FRR enables "compatible rfc7474" by default and prints only the + # "no" form - rendered when the CLI node is not set + vrf = 'blue' + vrf_base = ['vrf', 'name', vrf] + instances = { + 'router ospf': base_path, + f'router ospf vrf {vrf}': vrf_base + base_path, + } + + def verify(rfc1583: bool, rfc7474: bool): + for header in instances: + frrconfig = self.getFRRconfig(header, stop_section='^exit') + self.assertIn(' ospf router-id 192.0.2.1', frrconfig) + if rfc1583: + self.assertIn(' compatible rfc1583', frrconfig) + else: + self.assertNotIn(' compatible rfc1583', frrconfig) + self.assertNotRegex(frrconfig, r'(?m)^ compatible rfc7474$') + if rfc7474: + self.assertNotIn(' no compatible rfc7474', frrconfig) + else: + self.assertIn(' no compatible rfc7474', frrconfig) + + self.cli_set(vrf_base + ['table', '1000']) + for path in instances.values(): + self.cli_set(path + ['parameters', 'router-id', '192.0.2.1']) + self.cli_commit() + verify(rfc1583=False, rfc7474=False) + + for path in instances.values(): + self.cli_set(path + ['compatible', 'rfc7474']) + self.cli_commit() + verify(rfc1583=False, rfc7474=True) + + for path in instances.values(): + self.cli_set(path + ['compatible', 'rfc1583']) + self.cli_commit() + verify(rfc1583=True, rfc7474=True) + + for path in instances.values(): + self.cli_delete(path + ['compatible']) + self.cli_commit() + verify(rfc1583=False, rfc7474=False) + + self.cli_delete(vrf_base) + if __name__ == '__main__': unittest.main(verbosity=2, failfast=VyOSUnitTestSHIM.TestCase.debug_on()) -- cgit v1.2.3