diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-10-18 17:34:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-10-18 17:34:58 +0200 |
| commit | ca3da19e47f0b3db2db0c3bdf239bb761618d557 (patch) | |
| tree | 905357fecc9a2a0cef9011502e6a2b4441cce23e /src/migration-scripts | |
| parent | a1df1f372a35d07058fbfab139a221f30668c772 (diff) | |
| parent | 20a57113117b5db6d54c8da3eb08fa29b9398947 (diff) | |
| download | vyos-1x-ca3da19e47f0b3db2db0c3bdf239bb761618d557.tar.gz vyos-1x-ca3da19e47f0b3db2db0c3bdf239bb761618d557.zip | |
Merge pull request #5543 from alexk37/ospf-opaque-canonical
ospf: T9441: drop "parameters opaque-lsa" (migrated to "capability opaque") and render "compatible rfc1583" as FRR prints it
Diffstat (limited to 'src/migration-scripts')
| -rw-r--r-- | src/migration-scripts/ospf/2-to-3 | 54 |
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 + ) |
