summaryrefslogtreecommitdiff
path: root/src/migration-scripts
diff options
context:
space:
mode:
authorAlex Kudentsov <43482574+alexk37@users.noreply.github.com>2026-10-08 22:27:36 +0700
committerAlex Kudentsov <43482574+alexk37@users.noreply.github.com>2026-10-18 16:34:21 +0700
commit60aabdc9587700a326c8e9df06f09ba0c60c5435 (patch)
treefcb9598c8d52d3472eb3628b677d62baf7611dc7 /src/migration-scripts
parentdb29bdc899e4b4c27569d3c5705839b924393fe6 (diff)
downloadvyos-1x-60aabdc9587700a326c8e9df06f09ba0c60c5435.tar.gz
vyos-1x-60aabdc9587700a326c8e9df06f09ba0c60c5435.zip
ospf: T9441: migrate "parameters opaque-lsa" to "capability opaque"
"protocols ospf parameters opaque-lsa" and "protocols ospf capability opaque" are two CLI nodes for one FRR setting, FRR's "capability opaque". Keep "capability opaque" only. The migration script ospf/2-to-3 sets "capability opaque" where "parameters opaque-lsa" exists in the default VRF, and deletes the old node (and the "parameters" node when it is left empty). FRR refuses opaque LSAs outside the default VRF, so in a VRF instance the option never took effect: for a VRF the migration drops both "parameters opaque-lsa" and a plain "capability opaque" instead of moving the value into a node FRR would refuse at the next commit. The template renders the line from "capability opaque" only; it rendered the alias form "ospf opaque-lsa" for the old node, which frr-reload found missing in the running config on every reload: while only the old node was set, every commit that reloads FRR reset all adjacencies of that OSPF instance. Tests: a migration unit test (global instance, VRF instance, a VRF with "capability opaque" set directly, both nodes set together in a VRF, and global+VRF independence), the vrf-ospf config test (now carries "parameters opaque-lsa" in both the default instance and a VRF instance; the VRF instance is expected to lose it with no replacement), test_ospf_02 uses the new node, and test_ospf_21 checks the generated FRR config.
Diffstat (limited to 'src/migration-scripts')
-rw-r--r--src/migration-scripts/ospf/2-to-354
1 files changed, 54 insertions, 0 deletions
diff --git a/src/migration-scripts/ospf/2-to-3 b/src/migration-scripts/ospf/2-to-3
new file mode 100644
index 000000000..271dbd58e
--- /dev/null
+++ b/src/migration-scripts/ospf/2-to-3
@@ -0,0 +1,54 @@
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
+#
+# 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/>.
+
+# T9441: "parameters opaque-lsa" and "capability opaque" are two CLI nodes for
+# the same FRR setting. Keep "capability opaque" only. FRR supports
+# opaque LSAs only in the default VRF and refuses the setting in a VRF,
+# so in VRF instances it never took effect: drop it there.
+
+from vyos.configtree import ConfigTree
+
+
+def opaque_lsa_migration(config: ConfigTree, ospf_base: list, vrf: bool) -> None:
+ parameters = ospf_base + ['parameters']
+ if config.exists(parameters + ['opaque-lsa']):
+ config.delete(parameters + ['opaque-lsa'])
+
+ # do not leave an empty "parameters" node behind
+ if config.list_nodes(parameters) == []:
+ config.delete(parameters)
+
+ if not vrf:
+ config.set(ospf_base + ['capability', 'opaque'])
+
+ # FRR refuses "capability opaque" outside the default VRF; drop a value
+ # that would otherwise fail every commit (it never took effect anyway)
+ capability = ospf_base + ['capability']
+ if vrf and config.exists(capability + ['opaque']):
+ config.delete(capability + ['opaque'])
+ if config.list_nodes(capability) == []:
+ config.delete(capability)
+
+
+def migrate(config: ConfigTree) -> None:
+ # OSPF in the default VRF
+ opaque_lsa_migration(config, ['protocols', 'ospf'], vrf=False)
+
+ # OSPF in every VRF
+ if config.exists(['vrf', 'name']):
+ for name in config.list_nodes(['vrf', 'name']):
+ opaque_lsa_migration(
+ config, ['vrf', 'name', name, 'protocols', 'ospf'], vrf=True
+ )