summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Yatsenko <hedrok@gmail.com>2026-11-12 23:02:07 +0200
committerGitHub <noreply@github.com>2026-11-12 23:02:07 +0200
commit95afe65e7dc8a0b3d620dda7bdf758e7f0245a45 (patch)
tree161eaf164ccb094444a3893b2be7a351f1d2bd8a
parentfb1e6941824f43832535a6c08c1a11cddadaf583 (diff)
parentbffa7c48f7e8724c1fba21cbb32a7b8ab0d40def (diff)
downloadvyos-1x-95afe65e7dc8a0b3d620dda7bdf758e7f0245a45.tar.gz
vyos-1x-95afe65e7dc8a0b3d620dda7bdf758e7f0245a45.zip
Merge pull request #5648 from c-po/T9606-ospf-compatible
ospf: T9606: add "compatible" node for RFC1583 and RFC7474 options
-rw-r--r--data/templates/frr/ospfd.frr.j26
-rw-r--r--interface-definitions/include/ospf/protocol-common-config.xml.i25
-rw-r--r--interface-definitions/include/version/ospf-version.xml.i2
-rw-r--r--smoketest/configs/assert/vrf-ospf2
-rw-r--r--smoketest/configs/vrf-ospf2
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_ospf.py62
-rw-r--r--src/migration-scripts/ospf/3-to-444
7 files changed, 128 insertions, 15 deletions
diff --git a/data/templates/frr/ospfd.frr.j2 b/data/templates/frr/ospfd.frr.j2
index 77bd901b3..2d62e205c 100644
--- a/data/templates/frr/ospfd.frr.j2
+++ b/data/templates/frr/ospfd.frr.j2
@@ -211,9 +211,13 @@ 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 %}
+{# 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 d11178135..ec06c3827 100644
--- a/interface-definitions/include/ospf/protocol-common-config.xml.i
+++ b/interface-definitions/include/ospf/protocol-common-config.xml.i
@@ -334,6 +334,25 @@
</leafNode>
</children>
</node>
+<node name="compatible">
+ <properties>
+ <help>OSPF compatibility list</help>
+ </properties>
+ <children>
+ <leafNode name="rfc1583">
+ <properties>
+ <help>Enable RFC1583 criteria for handling AS external routes</help>
+ <valueless/>
+ </properties>
+ </leafNode>
+ <leafNode name="rfc7474">
+ <properties>
+ <help>Enable strict RFC7474 sequence number validation for cryptographic authentication</help>
+ <valueless/>
+ </properties>
+ </leafNode>
+ </children>
+</node>
#include <include/ospf/default-information.xml.i>
<leafNode name="default-metric">
<properties>
@@ -635,12 +654,6 @@
</properties>
<defaultValue>cisco</defaultValue>
</leafNode>
- <leafNode name="rfc1583-compatibility">
- <properties>
- <help>Enable RFC1583 criteria for handling AS external routes</help>
- <valueless/>
- </properties>
- </leafNode>
#include <include/router-id.xml.i>
</children>
</node>
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 @@
<!-- include start from include/version/ospf-version.xml.i -->
-<syntaxVersion component='ospf' version='3'></syntaxVersion>
+<syntaxVersion component='ospf' version='4'></syntaxVersion>
<!-- include end -->
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..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'
@@ -86,7 +87,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 +743,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 +781,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)
@@ -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())
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 <http://www.gnu.org/licenses/>.
+
+# 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'])