From 09064990b9e3ed0a19c1ca4257b385f92d25af2a Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 27 Nov 2021 10:32:01 +0100 Subject: ospfv3: T3753: adjust to CLI options new in FRR 8.0 --- src/migration-scripts/ospf/0-to-1 | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 src/migration-scripts/ospf/0-to-1 (limited to 'src/migration-scripts/ospf/0-to-1') diff --git a/src/migration-scripts/ospf/0-to-1 b/src/migration-scripts/ospf/0-to-1 new file mode 100755 index 000000000..ff3a84b2c --- /dev/null +++ b/src/migration-scripts/ospf/0-to-1 @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2021 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# T3753: upgrade to FRR8 and move CLI options to better fit with the new FRR CLI + +from sys import argv +from vyos.configtree import ConfigTree + +if (len(argv) < 1): + print("Must specify file name!") + exit(1) + +file_name = argv[1] + +with open(file_name, 'r') as f: + config_file = f.read() + +ospfv3_base = ['protocols', 'ospfv3'] +config = ConfigTree(config_file) + +if config.exists(ospfv3_base): + area_base = ospfv3_base + ['area'] + if config.exists(area_base): + for area in config.list_nodes(area_base): + if not config.exists(area_base + [area, 'interface']): + continue + + for interface in config.return_values(area_base + [area, 'interface']): + config.set(ospfv3_base + ['interface', interface, 'area', area]) + config.set_tag(ospfv3_base + ['interface']) + + config.delete(area_base + [area, 'interface']) + +try: + with open(file_name, 'w') as f: + f.write(config.to_string()) +except OSError as e: + print(f'Failed to save the modified config: {e}') + exit(1) -- cgit v1.2.3 From 1c15e9de76f81383a32e60d2af54444dbb0474a1 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 27 Nov 2021 10:32:01 +0100 Subject: ospf: T3753: adjust to CLI options new in FRR 8.0 FRR 7.5 router ospf passive-interface default no passive-interface eth0.202 Changed int FRR 8 to interface eth0.202 no ip ospf passive ! router ospf ospf router-id 172.18.254.202 log-adjacency-changes detail passive-interface default --- data/templates/frr/ospfd.frr.tmpl | 12 +++----- .../include/generic-disable-node.xml.i | 2 +- .../include/ospf/protocol-common-config.xml.i | 27 +++++++++--------- smoketest/scripts/cli/test_protocols_ospf.py | 17 +++++------ src/migration-scripts/ospf/0-to-1 | 33 ++++++++++++++++++++-- 5 files changed, 59 insertions(+), 32 deletions(-) (limited to 'src/migration-scripts/ospf/0-to-1') diff --git a/data/templates/frr/ospfd.frr.tmpl b/data/templates/frr/ospfd.frr.tmpl index f65bb6e74..37d6f394b 100644 --- a/data/templates/frr/ospfd.frr.tmpl +++ b/data/templates/frr/ospfd.frr.tmpl @@ -49,10 +49,8 @@ interface {{ iface }} {{ 'vrf ' + vrf if vrf is defined and vrf is not none }} {% if iface_config.network is defined and iface_config.network is not none %} ip ospf network {{ iface_config.network }} {% endif %} -{% if passive_interface_exclude is defined and passive_interface_exclude is not none %} -{% if iface in passive_interface_exclude %} - no ip ospf passive -{% endif %} +{% if iface_config.passive is defined %} + {{ 'no ' if iface_config.passive.disable is defined }}ip ospf passive {% endif %} ! {% endfor %} @@ -163,10 +161,8 @@ router ospf {{ 'vrf ' + vrf if vrf is defined and vrf is not none }} ospf router-id {{ parameters.router_id }} {% endif %} {% endif %} -{% if passive_interface is defined and passive_interface is not none %} -{% for interface in passive_interface %} - passive-interface {{ interface }} -{% endfor %} +{% if passive_interface is defined and passive_interface.default is defined %} + passive-interface default {% endif %} {% if redistribute is defined and redistribute is not none %} {% for protocol, protocols_options in redistribute.items() %} diff --git a/interface-definitions/include/generic-disable-node.xml.i b/interface-definitions/include/generic-disable-node.xml.i index bb4fa5c4b..97a328ecc 100644 --- a/interface-definitions/include/generic-disable-node.xml.i +++ b/interface-definitions/include/generic-disable-node.xml.i @@ -1,7 +1,7 @@ - Temporary disable + Disable instance diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i index 982e519a9..ac165a157 100644 --- a/interface-definitions/include/ospf/protocol-common-config.xml.i +++ b/interface-definitions/include/ospf/protocol-common-config.xml.i @@ -436,6 +436,14 @@ Must be broadcast, non-broadcast, point-to-multipoint or point-to-point + + + Suppress routing updates on an interface + + + #include + + #include @@ -597,26 +605,19 @@ #include -#include - + - Interface to exclude when using 'passive-interface default' + Suppress routing updates on an interface - + default - txt - Interface to exclude when suppressing routing updates - - - vlinkN - Virtual-link interface to exclude when suppressing routing updates + default + Default to suppress routing updates on all interfaces - - ^(vlink[0-9]+)$ + ^(default)$ - diff --git a/smoketest/scripts/cli/test_protocols_ospf.py b/smoketest/scripts/cli/test_protocols_ospf.py index 65bfd1824..3942219e7 100755 --- a/smoketest/scripts/cli/test_protocols_ospf.py +++ b/smoketest/scripts/cli/test_protocols_ospf.py @@ -254,14 +254,15 @@ class TestProtocolsOSPF(VyOSUnitTestSHIM.TestCase): self.cli_set(base_path + ['passive-interface', 'default']) for interface in interfaces: - self.cli_set(base_path + ['interface', interface, 'authentication', 'plaintext-password', password]) - self.cli_set(base_path + ['interface', interface, 'bandwidth', bandwidth]) - self.cli_set(base_path + ['interface', interface, 'bfd']) - self.cli_set(base_path + ['interface', interface, 'cost', cost]) - self.cli_set(base_path + ['interface', interface, 'mtu-ignore']) - self.cli_set(base_path + ['interface', interface, 'network', network]) - self.cli_set(base_path + ['interface', interface, 'priority', priority]) - self.cli_set(base_path + ['passive-interface-exclude', interface]) + base_interface = base_path + ['interface', interface] + self.cli_set(base_interface + ['authentication', 'plaintext-password', password]) + self.cli_set(base_interface + ['bandwidth', bandwidth]) + self.cli_set(base_interface + ['bfd']) + self.cli_set(base_interface + ['cost', cost]) + self.cli_set(base_interface + ['mtu-ignore']) + self.cli_set(base_interface + ['network', network]) + self.cli_set(base_interface + ['priority', priority]) + self.cli_set(base_interface + ['passive', 'disable']) # commit changes self.cli_commit() diff --git a/src/migration-scripts/ospf/0-to-1 b/src/migration-scripts/ospf/0-to-1 index ff3a84b2c..678569d9e 100755 --- a/src/migration-scripts/ospf/0-to-1 +++ b/src/migration-scripts/ospf/0-to-1 @@ -19,6 +19,24 @@ from sys import argv from vyos.configtree import ConfigTree +def ospf_passive_migration(config, ospf_base): + if config.exists(ospf_base): + if config.exists(ospf_base + ['passive-interface']): + default = False + for interface in config.return_values(ospf_base + ['passive-interface']): + if interface == 'default': + default = True + continue + config.set(ospf_base + ['interface', interface, 'passive']) + + config.delete(ospf_base + ['passive-interface']) + config.set(ospf_base + ['passive-interface'], value='default') + + if config.exists(ospf_base + ['passive-interface-exclude']): + for interface in config.return_values(ospf_base + ['passive-interface-exclude']): + config.set(ospf_base + ['interface', interface, 'passive', 'disable']) + config.delete(ospf_base + ['passive-interface-exclude']) + if (len(argv) < 1): print("Must specify file name!") exit(1) @@ -28,9 +46,9 @@ file_name = argv[1] with open(file_name, 'r') as f: config_file = f.read() -ospfv3_base = ['protocols', 'ospfv3'] config = ConfigTree(config_file) +ospfv3_base = ['protocols', 'ospfv3'] if config.exists(ospfv3_base): area_base = ospfv3_base + ['area'] if config.exists(area_base): @@ -39,11 +57,22 @@ if config.exists(ospfv3_base): continue for interface in config.return_values(area_base + [area, 'interface']): - config.set(ospfv3_base + ['interface', interface, 'area', area]) + config.set(ospfv3_base + ['interface', interface, 'area'], value=area) config.set_tag(ospfv3_base + ['interface']) config.delete(area_base + [area, 'interface']) +# Migrate OSPF syntax in default VRF +ospf_base = ['protocols', 'ospf'] +ospf_passive_migration(config, ospf_base) + +vrf_base = ['vrf', 'name'] +if config.exists(vrf_base): + for vrf in config.list_nodes(vrf_base): + vrf_ospf_base = vrf_base + [vrf, 'protocols', 'ospf'] + if config.exists(vrf_ospf_base): + ospf_passive_migration(config, vrf_ospf_base) + try: with open(file_name, 'w') as f: f.write(config.to_string()) -- cgit v1.2.3